Skip to content

Commit fc7638c

Browse files
committed
Change call methods to be private
call_get, call_post, call_put and call_delete are methods that only used inside the subclasses. Other uses of them should probably be better another implementation
1 parent cc8521c commit fc7638c

15 files changed

Lines changed: 126 additions & 126 deletions

msa_sdk/conf_profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def create(self):
8888
"templateUris": self.templateUris,
8989
"attachedManagedEntities": self.attachedManagedEntities
9090
}
91-
self.call_post(params)
91+
self._call_post(params)
9292

9393
def read(self):
9494
"""
@@ -102,7 +102,7 @@ def read(self):
102102
"""
103103
self.action = "Get configuration profile by ID"
104104
self.path = "{}/v2/{}".format(self.api_path, self.profile_id)
105-
self.call_get()
105+
self._call_get()
106106

107107
conf_profile = json.loads(self.content)
108108

@@ -148,7 +148,7 @@ def update(self):
148148
"templateUris": self.templateUris,
149149
"attachedManagedEntities": self.attachedManagedEntities
150150
}
151-
self.call_put(json.dumps(data))
151+
self._call_put(json.dumps(data))
152152

153153
return self.content
154154

@@ -164,4 +164,4 @@ def delete(self):
164164
"""
165165
self.action = 'Delete configuration profile by ID'
166166
self.path = '{}/v2/{}'.format(self.api_path, self.profile_id)
167-
self.call_delete()
167+
self._call_delete()

msa_sdk/customer.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_device_list_by_id(self, id: int) -> list:
3131
return_list = list()
3232

3333
self.path = "/device/v1/customer/{}/device-features".format(id)
34-
self.call_get()
34+
self._call_get()
3535

3636
for device in json.loads(self.content):
3737
return_list.append(device['id'])
@@ -60,7 +60,7 @@ def create_customer_by_prefix(self, prefix, name="", reference=""):
6060
self.path = "{}/{}?name={}&reference={}".format(self.api_path, prefix,
6161
name, reference)
6262
params = {}
63-
self.call_post(params)
63+
self._call_post(params)
6464

6565
def get_customer_by_id(self, id):
6666
"""
@@ -79,7 +79,7 @@ def get_customer_by_id(self, id):
7979
"""
8080
self.action = "Get customer by ID"
8181
self.path = "{}/id/{}".format(self.api_path, id)
82-
self.call_get()
82+
self._call_get()
8383
return self.content
8484

8585
def update_customer_by_id(self, id, name=""):
@@ -102,7 +102,7 @@ def update_customer_by_id(self, id, name=""):
102102
params = {
103103
"name": name
104104
}
105-
self.call_put(params)
105+
self._call_put(params)
106106

107107
def delete_customer_by_id(self, id):
108108
"""
@@ -121,7 +121,7 @@ def delete_customer_by_id(self, id):
121121
"""
122122
self.action = 'Delete customer by ID'
123123
self.path = '{}/id/{}'.format(self.api_path, id)
124-
self.call_delete()
124+
self._call_delete()
125125

126126
def update_variables_by_reference(self, reference, name="", value=""):
127127
"""
@@ -149,7 +149,7 @@ def update_variables_by_reference(self, reference, name="", value=""):
149149
"name": name,
150150
"value": value
151151
}
152-
self.call_put(params)
152+
self._call_put(params)
153153

154154
def attach_profile_by_reference(self, reference, profile=""):
155155
"""
@@ -173,7 +173,7 @@ def attach_profile_by_reference(self, reference, profile=""):
173173
params = {
174174
"profile": profile
175175
}
176-
self.call_put(params)
176+
self._call_put(params)
177177

178178
def detach_profile_by_reference(self, reference, profile=""):
179179
"""
@@ -197,7 +197,7 @@ def detach_profile_by_reference(self, reference, profile=""):
197197
params = {
198198
"profile": profile
199199
}
200-
self.call_put(params)
200+
self._call_put(params)
201201

202202
def get_variables_by_id(self, id):
203203
"""
@@ -216,7 +216,7 @@ def get_variables_by_id(self, id):
216216
"""
217217
self.action = 'Get configuration variables by ID'
218218
self.path = '{}/id/{}/variables'.format(self.api_path, id)
219-
self.call_get()
219+
self._call_get()
220220
return self.content
221221

222222
def get_variables_by_name(self, id, name):
@@ -238,7 +238,7 @@ def get_variables_by_name(self, id, name):
238238
"""
239239
self.action = 'Get configuration variable info by variable name'
240240
self.path = '{}/id/{}/variables/{}'.format(self.api_path, id, name)
241-
self.call_get()
241+
self._call_get()
242242
return self.content
243243

244244
def get_customer_by_reference(self, reference):
@@ -258,7 +258,7 @@ def get_customer_by_reference(self, reference):
258258
"""
259259
self.action = "Get customer by reference"
260260
self.path = "{}/reference/{}".format(self.api_path, reference)
261-
self.call_get()
261+
self._call_get()
262262
return self.content
263263

264264
def delete_customer_by_reference(self, reference):
@@ -278,7 +278,7 @@ def delete_customer_by_reference(self, reference):
278278
"""
279279
self.action = "Delete customer by reference"
280280
self.path = "{}/reference/{}".format(self.api_path, reference)
281-
self.call_delete()
281+
self._call_delete()
282282

283283
def delete_variable_by_name(self, id, name):
284284
"""
@@ -299,7 +299,7 @@ def delete_variable_by_name(self, id, name):
299299
"""
300300
self.action = 'Delete configuration variable info by variable name'
301301
self.path = '{}/id/{}/variables/{}'.format(self.api_path, id, name)
302-
self.call_delete()
302+
self._call_delete()
303303

304304
def get_deployment_settings_by_customer_id(self, id: str) -> list:
305305
"""
@@ -318,5 +318,5 @@ def get_deployment_settings_by_customer_id(self, id: str) -> list:
318318
self.action = ("Get deploymnet settings profile "
319319
"attached to the customer")
320320
self.path = "/conf-profile/v2/list/customer/{}".format(id)
321-
self.call_get()
321+
self._call_get()
322322
return json.loads(self.content)

msa_sdk/device.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def create(self):
118118
if self.management_port:
119119
data["managementPort"] = self.management_port
120120

121-
self.call_post(data)
121+
self._call_post(data)
122122
self.fail = not self.response.ok
123123
if self.response.ok:
124124
self.device_id = json.loads(self.content)['id']
@@ -161,7 +161,7 @@ def update(self, field: str, value: str) -> dict:
161161

162162
data[field] = value
163163

164-
self.call_put(json.dumps(data))
164+
self._call_put(json.dumps(data))
165165

166166
return json.loads(self.content)
167167

@@ -181,7 +181,7 @@ def delete(self, by_ref=False):
181181
"""
182182
self.action = 'Delete device'
183183
self._format_path_ref_id(by_ref, self.api_path)
184-
self.call_delete()
184+
self._call_delete()
185185

186186
def activate(self):
187187
"""
@@ -193,7 +193,7 @@ def activate(self):
193193
194194
"""
195195
self.path = "{}/activate/{}".format(self.api_path, self.device_id)
196-
self.call_post()
196+
self._call_post()
197197

198198
def provision(self):
199199
"""
@@ -206,7 +206,7 @@ def provision(self):
206206
"""
207207
self.action = 'Post Provisioning'
208208
self.path = "{}/provisioning/{}".format(self.api_path, self.device_id)
209-
self.call_post()
209+
self._call_post()
210210

211211
def provision_status(self):
212212
"""
@@ -220,7 +220,7 @@ def provision_status(self):
220220
self.action = 'Get provision status'
221221
self.path = "{}/provisioning/status/{}".format(
222222
self.api_path, self.device_id)
223-
self.call_get()
223+
self._call_get()
224224

225225
return json.loads(self.content)
226226

@@ -235,7 +235,7 @@ def is_device(self):
235235
"""
236236
self.action = 'Is device'
237237
self.path = "{}/isDevice/{}".format(self.api_path, self.device_id)
238-
self.call_get()
238+
self._call_get()
239239
return json.loads(self.content)
240240

241241
def read(self, by_ref=False):
@@ -260,7 +260,7 @@ def read(self, by_ref=False):
260260
else:
261261
self.path = '{}/v2/{}'.format(self.api_path, self.device_id)
262262

263-
self.call_get()
263+
self._call_get()
264264
if not self.response.ok:
265265
return False
266266

@@ -295,7 +295,7 @@ def status(self):
295295
self.action = "Get device status"
296296
self.path = "{}/status/{}".format(self.api_path, self.device_id)
297297

298-
self.call_get()
298+
self._call_get()
299299
return self.content
300300

301301
def get_configuration_status(self):
@@ -310,7 +310,7 @@ def get_configuration_status(self):
310310
self.action = 'Get configuration status'
311311
self.path = "{}/configuration/status/id/{}".format(
312312
self.api_path, self.device_id)
313-
self.call_get()
313+
self._call_get()
314314
self.configuration = json.loads(self.content)
315315

316316
def update_config(self):
@@ -325,7 +325,7 @@ def update_config(self):
325325
self.action = 'Update config'
326326
self.path = "{}/configuration/update/{}".format(
327327
self.api_path, self.device_id)
328-
self.call_post()
328+
self._call_post()
329329
return json.dumps(self.content)
330330

331331
def ping(self, address):
@@ -344,7 +344,7 @@ def ping(self, address):
344344
"""
345345
self.action = 'Get ping'
346346
self.path = "{}/ping/{}".format(self.api_path, address)
347-
self.call_get()
347+
self._call_get()
348348

349349
return self.content
350350

@@ -359,7 +359,7 @@ def initial_provisioning(self):
359359
"""
360360
self.action = 'Intial provisioning'
361361
self.path = "{}/provisioning/{}".format(self.api_path, self.device_id)
362-
self.call_post()
362+
self._call_post()
363363

364364
def push_configuration_status(self):
365365
"""
@@ -374,7 +374,7 @@ def push_configuration_status(self):
374374
self.path = "{}/push_configuration/status/{}".format(
375375
self.api_path, self.device_id)
376376

377-
self.call_get()
377+
self._call_get()
378378
return json.dumps(self.content)
379379

380380
def push_configuration(self, configuration=None):
@@ -395,7 +395,7 @@ def push_configuration(self, configuration=None):
395395
self.path = "{}/push_configuration/{}".format(
396396
self.api_path, self.device_id)
397397

398-
self.call_put(configuration)
398+
self._call_put(configuration)
399399

400400
def update_ip_address(self, ip_addr, netmask="255.255.255.255"):
401401
"""
@@ -417,7 +417,7 @@ def update_ip_address(self, ip_addr, netmask="255.255.255.255"):
417417
path = "{}/management_ip/update/{}?ip={}&mask={}"
418418
self.path = path.format(self.api_path, self.device_id, ip_addr,
419419
netmask)
420-
self.call_put()
420+
self._call_put()
421421

422422
def profile_switch(self, old_profile, new_profile_ref):
423423
"""
@@ -443,7 +443,7 @@ def profile_switch(self, old_profile, new_profile_ref):
443443
old_profile,
444444
new_profile_ref)
445445
self.path = path
446-
self.call_put()
446+
self._call_put()
447447

448448
def profile_attach(self, profile_reference: str) -> None:
449449
"""
@@ -463,7 +463,7 @@ def profile_attach(self, profile_reference: str) -> None:
463463
'?device={device_reference}').format(
464464
profile_reference=profile_reference,
465465
device_reference=self.device_external)
466-
self.call_put()
466+
self._call_put()
467467

468468
def update_credentials(self, login, password):
469469
"""
@@ -484,7 +484,7 @@ def update_credentials(self, login, password):
484484
self.action = 'Update credentials'
485485
path = "{}/credentials/update/{}?login={}&password={}"
486486
self.path = path.format(self.api_path, self.device_id, login, password)
487-
self.call_put()
487+
self._call_put()
488488

489489
def attach_files(self, uris, position="AUTO"):
490490
"""
@@ -504,7 +504,7 @@ def attach_files(self, uris, position="AUTO"):
504504
self.action = 'Attach files'
505505
self.path = ("{}/attach/{}/files/{}").format(self.api_path,
506506
self.device_id, position)
507-
self.call_put(json.dumps(uris))
507+
self._call_put(json.dumps(uris))
508508

509509
def detach_files(self, uris):
510510
"""
@@ -522,7 +522,7 @@ def detach_files(self, uris):
522522
self.action = 'Detach files'
523523
self.path = ("{}/detach/{}/files").format(self.api_path,
524524
self.device_id)
525-
self.call_put(json.dumps(uris))
525+
self._call_put(json.dumps(uris))
526526

527527
def get_configuration_variable(self, name: str) -> dict:
528528
"""
@@ -540,7 +540,7 @@ def get_configuration_variable(self, name: str) -> dict:
540540
"""
541541
self.path = '/variables/{device_id}/{name}'.format(
542542
device_id=self.device_id, name=name)
543-
self.call_get()
543+
self._call_get()
544544

545545
return json.loads(self.content)
546546

@@ -581,7 +581,7 @@ def create_configuration_variable(
581581
type=conf_type,
582582
comment=comment)
583583

584-
self.call_put()
584+
self._call_put()
585585

586586
if self.get_configuration_variable(name)['value'] == value:
587587
return True

0 commit comments

Comments
 (0)