Skip to content

Added option to use all HTTP methods #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cpapi/mgmt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def login_as_root(self, domain=None, payload=None):
except (WindowsError) as err:
raise APIClientException("Could not login as root:\n" + str(type(err)) + " - " + str(err))

def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=-1):
def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=-1, method="POST"):
"""
performs a web-service API request to the management server

Expand All @@ -287,6 +287,7 @@ def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=
when wait_for_task=False, it is up to the user to call the "show-task" API and check
the status of the command.
:param timeout: Optional positive timeout (in seconds) before stop waiting for the task even if not completed.
:param method: The HTTP method to use. Defaults is `POST`.
:return: APIResponse object
:side-effects: updates the class's uid and server variables
"""
Expand Down Expand Up @@ -336,7 +337,7 @@ def api_call(self, command, payload=None, sid=None, wait_for_task=True, timeout=
response = None
try:
# Send the data to the server
conn.request("POST", url, _data, _headers)
conn.request(method, url, _data, _headers)
# Get the reply from the server
response = conn.getresponse()
res = APIResponse.from_http_response(response)
Expand Down