Skip to content

Commit 4274eb5

Browse files
committed
ENH: rename low level API parameters
1 parent 1e26019 commit 4274eb5

File tree

5 files changed

+244
-205
lines changed

5 files changed

+244
-205
lines changed

docs/source/api-reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Synchronous Communication with Save-And-Restore Server
1212
:toctree: generated
1313

1414
SaveRestoreAPI
15+
SaveRestoreAPI.send_request
1516

1617
Authentication
1718
**************

src/save_and_restore_api/_api_async.py

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ async def __aexit__(self, exc_type, exc_value, traceback):
2020
await self.close()
2121

2222
async def send_request(
23-
self, method, url, *, params=None, url_params=None, headers=None, data=None, timeout=None, auth=None
23+
self, method, url, *, body_json=None, params=None, headers=None, data=None, timeout=None, auth=None
2424
):
2525
try:
2626
client_response = None
2727
kwargs = self._prepare_request(
2828
method=method,
29+
body_json=body_json,
2930
params=params,
30-
url_params=url_params,
3131
headers=headers,
3232
data=data,
3333
timeout=timeout,
@@ -36,7 +36,9 @@ async def send_request(
3636
client_response = await self._client.request(method, url, **kwargs)
3737
response = self._process_response(client_response=client_response)
3838
except Exception:
39-
response = self._process_comm_exception(method=method, params=params, client_response=client_response)
39+
response = self._process_comm_exception(
40+
method=method, body_json=body_json, client_response=client_response
41+
)
4042

4143
return response
4244

@@ -60,26 +62,26 @@ async def version_get(self):
6062

6163
async def search(self, allRequestParams):
6264
# Reusing docstrings from the threaded version
63-
method, url, url_params = self._prepare_search(allRequestParams=allRequestParams)
64-
return await self.send_request(method, url, url_params=url_params)
65+
method, url, params = self._prepare_search(allRequestParams=allRequestParams)
66+
return await self.send_request(method, url, params=params)
6567

6668
# =============================================================================================
6769
# HELP-RESOURCE API METHODS
6870
# =============================================================================================
6971

7072
async def help(self, what, *, lang=None):
7173
# Reusing docstrings from the threaded version
72-
method, url, url_params = self._prepare_help(what=what, lang=lang)
73-
return await self.send_request(method, url, url_params=url_params)
74+
method, url, params = self._prepare_help(what=what, lang=lang)
75+
return await self.send_request(method, url, params=params)
7476

7577
# =============================================================================================
7678
# AUTHENTICATION-CONTROLLER API METHODS
7779
# =============================================================================================
7880

7981
async def login(self, *, username=None, password=None):
8082
# Reusing docstrings from the threaded version
81-
method, url, params = self._prepare_login(username=username, password=password)
82-
return await self.send_request(method, url, params=params)
83+
method, url, body_json = self._prepare_login(username=username, password=password)
84+
return await self.send_request(method, url, body_json=body_json)
8385

8486
# =============================================================================================
8587
# NODE-CONTROLLER API METHODS
@@ -92,15 +94,15 @@ async def node_get(self, uniqueNodeId):
9294

9395
async def nodes_get(self, uniqueIds):
9496
# Reusing docstrings from the threaded version
95-
method, url, params = self._prepare_nodes_get(uniqueIds=uniqueIds)
96-
return await self.send_request(method, url, params=params)
97+
method, url, body_json = self._prepare_nodes_get(uniqueIds=uniqueIds)
98+
return await self.send_request(method, url, body_json=body_json)
9799

98100
async def node_add(self, parentNodeId, *, name, nodeType, auth=None, **kwargs):
99101
# Reusing docstrings from the threaded version
100-
method, url, url_params, params = self._prepare_node_add(
102+
method, url, params, body_json = self._prepare_node_add(
101103
parentNodeId=parentNodeId, name=name, nodeType=nodeType, **kwargs
102104
)
103-
return await self.send_request(method, url, url_params=url_params, params=params, auth=auth)
105+
return await self.send_request(method, url, params=params, body_json=body_json, auth=auth)
104106

105107
async def node_delete(self, nodeId, *, auth=None):
106108
# Reusing docstrings from the threaded version
@@ -109,8 +111,8 @@ async def node_delete(self, nodeId, *, auth=None):
109111

110112
async def nodes_delete(self, uniqueIds, *, auth=None):
111113
# Reusing docstrings from the threaded version
112-
method, url, params = self._prepare_nodes_delete(uniqueIds=uniqueIds)
113-
return await self.send_request(method, url, params=params, auth=auth)
114+
method, url, body_json = self._prepare_nodes_delete(uniqueIds=uniqueIds)
115+
return await self.send_request(method, url, body_json=body_json, auth=auth)
114116

115117
async def node_get_children(self, uniqueNodeId):
116118
# Reusing docstrings from the threaded version
@@ -133,17 +135,17 @@ async def config_get(self, uniqueNodeId):
133135

134136
async def config_add(self, parentNodeId, *, configurationNode, configurationData, auth=None):
135137
# Reusing docstrings from the threaded version
136-
method, url, params = self._prepare_config_add(
138+
method, url, body_json = self._prepare_config_add(
137139
parentNodeId=parentNodeId, configurationNode=configurationNode, configurationData=configurationData
138140
)
139-
return await self.send_request(method, url, params=params, auth=auth)
141+
return await self.send_request(method, url, body_json=body_json, auth=auth)
140142

141143
async def config_update(self, *, configurationNode, configurationData, auth=None):
142144
# Reusing docstrings from the threaded version
143-
method, url, params = self._prepare_config_update(
145+
method, url, body_json = self._prepare_config_update(
144146
configurationNode=configurationNode, configurationData=configurationData
145147
)
146-
return await self.send_request(method, url, params=params, auth=auth)
148+
return await self.send_request(method, url, body_json=body_json, auth=auth)
147149

148150
# =============================================================================================
149151
# TAG-CONTROLLER API METHODS
@@ -156,13 +158,13 @@ async def tags_get(self):
156158

157159
async def tags_add(self, *, uniqueNodeIds, tag, auth=None):
158160
# Reusing docstrings from the threaded version
159-
method, url, params = self._prepare_tags_add(uniqueNodeIds=uniqueNodeIds, tag=tag)
160-
return await self.send_request(method, url, params=params, auth=auth)
161+
method, url, body_json = self._prepare_tags_add(uniqueNodeIds=uniqueNodeIds, tag=tag)
162+
return await self.send_request(method, url, body_json=body_json, auth=auth)
161163

162164
async def tags_delete(self, *, uniqueNodeIds, tag, auth=None):
163165
# Reusing docstrings from the threaded version
164-
method, url, params = self._prepare_tags_delete(uniqueNodeIds=uniqueNodeIds, tag=tag)
165-
return await self.send_request(method, url, params=params, auth=auth)
166+
method, url, body_json = self._prepare_tags_delete(uniqueNodeIds=uniqueNodeIds, tag=tag)
167+
return await self.send_request(method, url, body_json=body_json, auth=auth)
166168

167169
# =============================================================================================
168170
# TAKE-SNAPSHOT-CONTROLLER API METHODS
@@ -175,10 +177,10 @@ async def take_snapshot_get(self, uniqueNodeId):
175177

176178
async def take_snapshot_save(self, uniqueNodeId, *, name=None, comment=None, auth=None):
177179
# Reusing docstrings from the threaded version
178-
method, url, url_params = self._prepare_take_snapshot_save(
180+
method, url, params = self._prepare_take_snapshot_save(
179181
uniqueNodeId=uniqueNodeId, name=name, comment=comment
180182
)
181-
return await self.send_request(method, url, url_params=url_params, auth=auth)
183+
return await self.send_request(method, url, params=params, auth=auth)
182184

183185
# =============================================================================================
184186
# SNAPSHOT-CONTROLLER API METHODS
@@ -191,15 +193,17 @@ async def snapshot_get(self, uniqueId):
191193

192194
async def snapshot_add(self, parentNodeId, *, snapshotNode, snapshotData, auth=None):
193195
# Reusing docstrings from the threaded version
194-
method, url, url_params, params = self._prepare_snapshot_add(
196+
method, url, params, body_json = self._prepare_snapshot_add(
195197
parentNodeId=parentNodeId, snapshotNode=snapshotNode, snapshotData=snapshotData
196198
)
197-
return await self.send_request(method, url, params=params, url_params=url_params, auth=auth)
199+
return await self.send_request(method, url, body_json=body_json, params=params, auth=auth)
198200

199201
async def snapshot_update(self, *, snapshotNode, snapshotData, auth=None):
200202
# Reusing docstrings from the threaded version
201-
method, url, params = self._prepare_snapshot_update(snapshotNode=snapshotNode, snapshotData=snapshotData)
202-
return await self.send_request(method, url, params=params, auth=auth)
203+
method, url, body_json = self._prepare_snapshot_update(
204+
snapshotNode=snapshotNode, snapshotData=snapshotData
205+
)
206+
return await self.send_request(method, url, body_json=body_json, auth=auth)
203207

204208
async def snapshots_get(self):
205209
# Reusing docstrings from the threaded version
@@ -229,59 +233,59 @@ async def composite_snapshot_add(
229233
self, parentNodeId, *, compositeSnapshotNode, compositeSnapshotData, auth=None
230234
):
231235
# Reusing docstrings from the threaded version
232-
method, url, url_params, params = self._prepare_composite_snapshot_add(
236+
method, url, params, body_json = self._prepare_composite_snapshot_add(
233237
parentNodeId=parentNodeId,
234238
compositeSnapshotNode=compositeSnapshotNode,
235239
compositeSnapshotData=compositeSnapshotData,
236240
)
237-
return await self.send_request(method, url, url_params=url_params, params=params, auth=auth)
241+
return await self.send_request(method, url, params=params, body_json=body_json, auth=auth)
238242

239243
async def composite_snapshot_update(self, *, compositeSnapshotNode, compositeSnapshotData, auth=None):
240244
# Reusing docstrings from the threaded version
241-
method, url, params = self._prepare_composite_snapshot_update(
245+
method, url, body_json = self._prepare_composite_snapshot_update(
242246
compositeSnapshotNode=compositeSnapshotNode,
243247
compositeSnapshotData=compositeSnapshotData,
244248
)
245-
return await self.send_request(method, url, params=params, auth=auth)
249+
return await self.send_request(method, url, body_json=body_json, auth=auth)
246250

247251
async def composite_snapshot_consistency_check(self, uniqueNodeIds, *, auth=None):
248252
# Reusing docstrings from the threaded version
249-
method, url, params = self._prepare_composite_snapshot_consistency_check(uniqueNodeIds=uniqueNodeIds)
250-
return await self.send_request(method, url, params=params, auth=auth)
253+
method, url, body_json = self._prepare_composite_snapshot_consistency_check(uniqueNodeIds=uniqueNodeIds)
254+
return await self.send_request(method, url, body_json=body_json, auth=auth)
251255

252256
# =============================================================================================
253257
# SNAPSHOT-RESTORE-CONTROLLER API METHODS
254258
# =============================================================================================
255259

256260
async def restore_node(self, nodeId, *, auth=None):
257261
# Reusing docstrings from the threaded version
258-
method, url, url_params = self._prepare_restore_node(nodeId=nodeId)
259-
return await self.send_request(method, url, url_params=url_params, auth=auth)
262+
method, url, params = self._prepare_restore_node(nodeId=nodeId)
263+
return await self.send_request(method, url, params=params, auth=auth)
260264

261265
async def restore_items(self, *, snapshotItems, auth=None):
262266
# Reusing docstrings from the threaded version
263-
method, url, params = self._prepare_restore_items(snapshotItems=snapshotItems)
264-
return await self.send_request(method, url, params=params, auth=auth)
267+
method, url, body_json = self._prepare_restore_items(snapshotItems=snapshotItems)
268+
return await self.send_request(method, url, body_json=body_json, auth=auth)
265269

266270
# =============================================================================================
267271
# COMPARISON-CONTROLLER API METHODS
268272
# =============================================================================================
269273

270274
async def compare(self, nodeId, *, tolerance=None, compareMode=None, skipReadback=None):
271275
# Reusing docstrings from the threaded version
272-
method, url, url_params = self._prepare_compare(
276+
method, url, params = self._prepare_compare(
273277
nodeId=nodeId, tolerance=tolerance, compareMode=compareMode, skipReadback=skipReadback
274278
)
275-
return await self.send_request(method, url, url_params=url_params)
279+
return await self.send_request(method, url, params=params)
276280

277281
# =============================================================================================
278282
# FILTER-CONTROLLER API METHODS
279283
# =============================================================================================
280284

281285
async def filter_add(self, filter, *, auth=None):
282286
# Reusing docstrings from the threaded version
283-
method, url, params = self._prepare_filter_add(filter=filter)
284-
return await self.send_request(method, url, params=params, auth=auth)
287+
method, url, body_json = self._prepare_filter_add(filter=filter)
288+
return await self.send_request(method, url, body_json=body_json, auth=auth)
285289

286290
async def filters_get(self):
287291
# Reusing docstrings from the threaded version
@@ -299,17 +303,17 @@ async def filter_delete(self, name, *, auth=None):
299303

300304
async def structure_move(self, nodeIds, newParentNodeId, *, auth=None):
301305
# Reusing docstrings from the threaded version
302-
method, url, params, url_params = self._prepare_structure_move(
306+
method, url, body_json, params = self._prepare_structure_move(
303307
nodeIds=nodeIds, newParentNodeId=newParentNodeId
304308
)
305-
return await self.send_request(method, url, params=params, url_params=url_params, auth=auth)
309+
return await self.send_request(method, url, body_json=body_json, params=params, auth=auth)
306310

307311
async def structure_copy(self, nodeIds, newParentNodeId, *, auth=None):
308312
# Reusing docstrings from the threaded version
309-
method, url, params, url_params = self._prepare_structure_copy(
313+
method, url, body_json, params = self._prepare_structure_copy(
310314
nodeIds=nodeIds, newParentNodeId=newParentNodeId
311315
)
312-
return await self.send_request(method, url, params=params, url_params=url_params, auth=auth)
316+
return await self.send_request(method, url, body_json=body_json, params=params, auth=auth)
313317

314318
async def structure_path_get(self, uniqueNodeId):
315319
# Reusing docstrings from the threaded version
@@ -318,9 +322,11 @@ async def structure_path_get(self, uniqueNodeId):
318322

319323
async def structure_path_nodes(self, path):
320324
# Reusing docstrings from the threaded version
321-
method, url, url_params = self._prepare_structure_path_nodes(path=path)
322-
return await self.send_request(method, url, url_params=url_params)
325+
method, url, params = self._prepare_structure_path_nodes(path=path)
326+
return await self.send_request(method, url, params=params)
327+
323328

329+
SaveRestoreAPI.send_request.__doc__ = _SaveRestoreAPI_Threads.send_request.__doc__
324330

325331
SaveRestoreAPI.info_get.__doc__ = _SaveRestoreAPI_Threads.info_get.__doc__
326332
SaveRestoreAPI.version_get.__doc__ = _SaveRestoreAPI_Threads.version_get.__doc__

0 commit comments

Comments
 (0)