Skip to content

Commit

Permalink
Added option to use all HTTP methods (#54)
Browse files Browse the repository at this point in the history
* Added option to use all rest API methods

* Added comment
  • Loading branch information
chkp-olgami authored May 24, 2023
1 parent 95d476e commit 4597795
Showing 1 changed file with 3 additions and 2 deletions.
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

0 comments on commit 4597795

Please sign in to comment.