Skip to content

Commit 4597795

Browse files
authored
Added option to use all HTTP methods (#54)
* Added option to use all rest API methods * Added comment
1 parent 95d476e commit 4597795

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cpapi/mgmt_api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def login_as_root(self, domain=None, payload=None):
274274
except (WindowsError) as err:
275275
raise APIClientException("Could not login as root:\n" + str(type(err)) + " - " + str(err))
276276

277-
def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=-1):
277+
def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=-1, method="POST"):
278278
"""
279279
performs a web-service API request to the management server
280280
@@ -287,6 +287,7 @@ def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=
287287
when wait_for_task=False, it is up to the user to call the "show-task" API and check
288288
the status of the command.
289289
:param timeout: Optional positive timeout (in seconds) before stop waiting for the task even if not completed.
290+
:param method: The HTTP method to use. Defaults is `POST`.
290291
:return: APIResponse object
291292
:side-effects: updates the class's uid and server variables
292293
"""
@@ -336,7 +337,7 @@ def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=
336337
response = None
337338
try:
338339
# Send the data to the server
339-
conn.request("POST", url, _data, _headers)
340+
conn.request(method, url, _data, _headers)
340341
# Get the reply from the server
341342
response = conn.getresponse()
342343
res = APIResponse.from_http_response(response)

0 commit comments

Comments
 (0)