From 1beb6f433be36b30b7ebdb64ea2045bd3c1501bf Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Wed, 16 Jan 2019 17:15:50 +0100 Subject: [PATCH] Add object_type param to checkpoint_object_facts (#50982) * Add object_type param to checkpoint_object_facts * Add changelog fragment * Fix sanity * Fix sanity * Pass type param to payload Otherwise it does not do what is expected to do * Add ip-only default to docstring --- .../checkpoint-object-facts-type-param.yaml | 3 +++ .../network/checkpoint/checkpoint_object_facts.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/checkpoint-object-facts-type-param.yaml diff --git a/changelogs/fragments/checkpoint-object-facts-type-param.yaml b/changelogs/fragments/checkpoint-object-facts-type-param.yaml new file mode 100644 index 00000000000..c5011067887 --- /dev/null +++ b/changelogs/fragments/checkpoint-object-facts-type-param.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - "add parameter to checkpoint_object_facts to filter out by object type" diff --git a/lib/ansible/modules/network/checkpoint/checkpoint_object_facts.py b/lib/ansible/modules/network/checkpoint/checkpoint_object_facts.py index 96bbd175b0b..096f56f91ef 100644 --- a/lib/ansible/modules/network/checkpoint/checkpoint_object_facts.py +++ b/lib/ansible/modules/network/checkpoint/checkpoint_object_facts.py @@ -50,6 +50,10 @@ options: - Filter only by IP address. type: bool default: false + object_type: + description: + - Type of the object to search. Must be a valid API resource name + type: str """ EXAMPLES = """ @@ -77,12 +81,13 @@ def get_object(module, connection): uid = module.params['uid'] object_filter = module.params['object_filter'] ip_only = module.params['ip_only'] + object_type = module.params['object_type'] if uid: payload = {'uid': uid} code, result = connection.send_request('/web_api/show-object', payload) else: - payload = {'filter': object_filter, 'ip-only': ip_only} + payload = {'filter': object_filter, 'ip-only': ip_only, 'type': object_type} code, result = connection.send_request('/web_api/show-objects', payload) return code, result @@ -91,8 +96,9 @@ def get_object(module, connection): def main(): argument_spec = dict( uid=dict(type='str', default=None), - object_filter=dict(type='str'), - ip_only=dict(type='bool', default=False) + object_filter=dict(type='str', default=None), + ip_only=dict(type='bool', default=False), + object_type=dict(type='str', default=None) ) module = AnsibleModule(argument_spec=argument_spec)