Skip to content

Commit

Permalink
updated generator and rest_session for delete calls (#278)
Browse files Browse the repository at this point in the history
* Initial Commit

* Editing rest_session to include json param

* editing rest_session to include json

* updating delete to have json metadata

* added json metadata to rest_session delete

* Modified generate_library for delete query params

* Updated delete generator

* removed space
  • Loading branch information
Spierings authored Jan 25, 2025
1 parent 71bbe8a commit 83668cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions generator/generate_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def generate_standard_and_async_functions(

# Function body for DELETE endpoints
elif method == "delete":
call_line, path_params = parse_delete_params(operation, parameters)
call_line, path_params, query_params = parse_delete_params(operation, parameters)

# Add function to files
with open(
Expand Down Expand Up @@ -569,9 +569,14 @@ def parse_post_and_put_params(method: str, operation: str, parameters: dict):


def parse_delete_params(operation: str, parameters: dict):
query_params = parse_params(operation, parameters, "query")
path_params = parse_params(operation, parameters, "path")
call_line = "return self._session.delete(metadata, resource)"
return call_line, path_params

if query_params:
call_line = "return self._session.delete(metadata, resource, params)"
else:
call_line = "return self._session.delete(metadata, resource)"
return call_line, path_params, query_params


def generate_action_batch_functions(
Expand Down
5 changes: 3 additions & 2 deletions meraki/rest_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,11 @@ def put(self, metadata, url, json=None):
response.close()
return ret

def delete(self, metadata, url):
def delete(self, metadata, url, json=None):
metadata['method'] = 'DELETE'
metadata['url'] = url
response = self.request(metadata, 'DELETE', url)
metadata['json'] = json
response = self.request(metadata, 'DELETE', url, json=json)
if response:
response.close()
return None

0 comments on commit 83668cd

Please sign in to comment.