47
47
- The file path containing the body of the HTTP request.
48
48
type: path
49
49
aliases: [ config_file ]
50
- page_size:
51
- description:
52
- - The number of items to return in a single page.
53
- type: int
54
- page:
55
- description:
56
- - The page number to return.
57
- type: int
58
50
extends_documentation_fragment:
59
51
- cisco.nd.modules
60
52
- cisco.nd.check_mode
132
124
method: get
133
125
register: query_all
134
126
127
+ - name: Query all Security Domains ordered by name using GET method
128
+ cisco.nd.nd_rest:
129
+ host: nd
130
+ username: admin
131
+ password: SomeSecretPassword
132
+ path: /nexus/infra/api/aaa/v4/securitydomains?orderBy=spec.name
133
+ method: get
134
+ register: query_all_ordered_by_name
135
+
135
136
- name: Remove Security Domain using DELETE method
136
137
cisco.nd.nd_rest:
137
138
host: nd
184
185
import json
185
186
import os
186
187
187
- # Optional, only used for YAML validation and update a URL
188
- try :
189
- from urllib .parse import parse_qsl , urlencode , urlparse , urlunparse
190
- HAS_URLPARSE = True
191
- except Exception :
192
- HAS_URLPARSE = False
188
+ # Optional, only used for YAML validation
193
189
try :
194
190
import yaml
195
191
203
199
from ansible .module_utils ._text import to_text
204
200
205
201
206
- def update_qsl (url , params ):
207
- """Add or update a URL query string"""
208
-
209
- if HAS_URLPARSE :
210
- url_parts = list (urlparse (url ))
211
- query = dict (parse_qsl (url_parts [4 ]))
212
- query .update (params )
213
- url_parts [4 ] = urlencode (query )
214
- return urlunparse (url_parts )
215
- elif "?" in url :
216
- return url + "&" + "&" .join (["%s=%s" % (k , v ) for k , v in params .items ()])
217
- else :
218
- return url + "?" + "&" .join (["%s=%s" % (k , v ) for k , v in params .items ()])
219
-
220
-
221
202
def main ():
222
203
argument_spec = nd_argument_spec ()
223
204
argument_spec .update (
@@ -230,8 +211,6 @@ def main():
230
211
),
231
212
content = dict (type = "raw" , aliases = ["payload" ]),
232
213
file_path = dict (type = "path" , aliases = ["config_file" ]),
233
- page = dict (type = "int" ),
234
- page_size = dict (type = "int" ),
235
214
)
236
215
237
216
module = AnsibleModule (
@@ -242,8 +221,6 @@ def main():
242
221
content = module .params .get ("content" )
243
222
path = module .params .get ("path" )
244
223
file_path = module .params .get ("config_file" )
245
- page = module .params .get ("page" )
246
- page_size = module .params .get ("page_size" )
247
224
248
225
nd = NDModule (module )
249
226
@@ -276,13 +253,6 @@ def main():
276
253
nd .existing = nd .previous = sanitize (nd .query_obj (path , ignore_not_found_error = True ), ND_REST_KEYS_TO_SANITIZE )
277
254
nd .result ["previous" ] = nd .previous
278
255
279
- # Check paginition
280
- if method == "GET" :
281
- if page :
282
- path = update_qsl (path , {"page" : page })
283
- if page_size :
284
- path = update_qsl (path , {"page-size" : page_size })
285
-
286
256
# Perform request
287
257
if module .check_mode :
288
258
nd .result ["jsondata" ] = content
0 commit comments