Skip to content

Commit

Permalink
Fix defaults, filtering and test
Browse files Browse the repository at this point in the history
  • Loading branch information
edudppaz committed Dec 18, 2024
1 parent 8807df1 commit e8bf63a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 14 additions & 6 deletions plugins/modules/aci_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@
description:
- The number of items to return in a single page.
type: int
required: false
page:
description:
- The page number to return.
type: int
required: false
default: 0
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -174,6 +171,17 @@
delegate_to: localhost
register: query_result
- name: Get first 5 tenants using password authentication and pagination
cisco.aci.aci_rest:
host: apic
username: admin
password: SomeSecretPassword
method: get
page_size: 5
path: /api/node/class/fvTenant.json
delegate_to: localhost
register: query_result
- name: Configure contracts
cisco.aci.aci_rest:
host: apic
Expand Down Expand Up @@ -388,8 +396,8 @@ def main():
src=dict(type="path", aliases=["config_file"]),
content=dict(type="raw"),
rsp_subtree_preserve=dict(type="bool", default=False),
page_size=dict(type="int", required=False),
page=dict(type="int", required=False, default=0),
page_size=dict(type="int"),
page=dict(type="int"),
)

module = AnsibleModule(
Expand Down Expand Up @@ -472,7 +480,7 @@ def main():
aci.url = "{0}/{1}".format(aci.base_url, aci.path)

if aci.params.get("method") == "get" and page_size:
aci.path = "{0}?page={1}&page-size={2}".format(aci.path, page, page_size)
aci.path = update_qsl(aci.path, {"page": page, "page-size": page_size})
aci.url = update_qsl(aci.url, {"page": page, "page-size": page_size})

Check warning on line 484 in plugins/modules/aci_rest.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/aci_rest.py#L483-L484

Added lines #L483 - L484 were not covered by tests
if aci.params.get("method") != "get" and not rsp_subtree_preserve:
aci.path = "{0}?rsp-subtree=modified".format(aci.path)
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/targets/aci_rest/tasks/json_inline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,13 @@
output_level: '{{ aci_output_level | default("info") }}'
path: /api/class/uni/fvTenant.json
page_size: 10
page: 0
method: get
register: nm_query_all_tenants_paginated

- name: Query all tenant with pagination - Size 1 / Page 0 (normal mode)
cisco.aci.aci_rest:
<<: *tenant_query_all_paginated
page_size: 1
page: 0
register: nm_query_all_tenants_paginated_1_0

- name: Query all tenant with pagination - Size 1 / Page 1 (normal mode)
Expand All @@ -191,7 +189,6 @@
cisco.aci.aci_rest:
<<: *tenant_query_all_paginated
page_size: 2
page: 0
register: nm_query_all_tenants_paginated_2_0

- name: Verify query_all_tenants_paginated
Expand Down

0 comments on commit e8bf63a

Please sign in to comment.