Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a utility to merge objectFilters, #1468

Merged
merged 3 commits into from Apr 21, 2021

Conversation

allmightyspiff
Copy link
Member

Borrowed from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9 mostly.

SoftLayer.utils.dict_merge(filter1, filter2) will now merge filter2 and filter1, returning a new filter

filter1 = {"virtualGuests":{"hostname":{"operation":"etst"}}}
filter2 = {"virtualGuests":{"id":{"operation":"orderBy","options":[{"name":"sort","value":["DESC"]}]}}}
result = SoftLayer.utils.dict_merge(filter1, filter2)
print(result) # will contain both filter1 and filter2

#1459
Fixes #1461

@allmightyspiff allmightyspiff added the Core Issues dealing with core functionality label Apr 13, 2021
@allmightyspiff allmightyspiff added this to In Progress in Q2 2021 via automation Apr 13, 2021
@allmightyspiff allmightyspiff self-assigned this Apr 13, 2021
Copy link
Contributor

@caberos caberos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ATGE ATGE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing

filter1 = {"virtualGuests": {"hostname": {"operation": "etst"}}}
        filter2 = {"virtualGuests": {"id": {"operation": "orderBy", "options": [{"name": "sort", "value": ["DESC"]}]}}}
        result = SoftLayer.utils.dict_merge(filter1, filter2)
        print(result)
  • ✔️ {'virtualGuests': {'hostname': {'operation': 'etst'}, 'id': {'operation': 'orderBy', 'options': [{'name': 'sort', 'value': ['DESC']}]}}}

looks good

Copy link
Contributor

@FernandoOjeda FernandoOjeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me.

@allmightyspiff allmightyspiff merged commit 225a815 into softlayer:master Apr 21, 2021
Q2 2021 automation moved this from In Progress to Done Apr 21, 2021
@allmightyspiff allmightyspiff deleted the mergeFilter branch April 21, 2021 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issues dealing with core functionality
Projects
No open projects
Q2 2021
  
Done
Development

Successfully merging this pull request may close these issues.

Add a utility function to merge object filters together
4 participants