Updates for PR-202#203
Updates for PR-202#203PaperMtn wants to merge 4 commits intogoogle:chore/modules-request-helper-updatefrom
Conversation
|
Below approach seems more inefficient to me. We are building object and then immediately rebuilding same object, which can lead to extra memory allocation and overhead. Old approach seems better option to me, but there is another option we can look into is having utility method to remove none values (example below) |
|
I think the overhead will be negligable on this scale. The benefit of this approach is when building larger params or body dicts it makes the code a lot more readable, instead of a long list of Replacing it with a helper could potentially make the code more readable by wrapping the comprehension in a function that the user doesn't have to see. |
Understood! |
|
@mihirvala08 I've implemented the helper in my latest commit |
Small adjustments for [#202]
secops/chronicle/utils/format_utils.parse_json_list()helper where appropriatesecops/chronicle/utils/format_utils.format_resource_id()helper where appropriate for consistent parsing of resource ID, regardless of whether a full path is passed or notprojects/12345/locations/eu/instances/.../123-ID-abcis passed, it is extracted to123-ID-abc123-ID-abcis also acceptedPrefer the use of a "None-filtering" pattern for body/param building
When building params or body values, replace the usage of
With a more efficient "None-filtering" pattern, where the dict is defined with all possible variables from the function, then any empty values removed: