Skip to content

Commit

Permalink
fix(python): correct usage of the sdk method header
Browse files Browse the repository at this point in the history
This should only be sent by sdk methods that are wrapper methods
  • Loading branch information
ewanharris committed Oct 25, 2024
1 parent 5374fc6 commit 8689b27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
20 changes: 2 additions & 18 deletions config/clients/python/template/src/client/client.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
# convert options to kwargs
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListStores")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.list_stores(
**kwargs,
Expand All @@ -208,7 +207,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "CreateStore")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.create_store(
body,
Expand All @@ -224,7 +222,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "GetStore")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.get_store(
**kwargs,
Expand All @@ -239,7 +236,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "DeleteStore")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.delete_store(
**kwargs,
Expand All @@ -258,7 +254,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAuthorizationModels")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.read_authorization_models(
**kwargs,
Expand All @@ -274,7 +269,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "WriteAuthorizationModel")
kwargs = options_to_kwargs(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.write_authorization_model(
body,
Expand All @@ -290,7 +284,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAuthorizationModel")
kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)
api_response = {{#asyncio}}await {{/asyncio}}self._api.read_authorization_model(
Expand All @@ -307,7 +300,7 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadLatestAuthoriationModel")
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadLatestAuthorizationModel")
options["page_size"] = 1
api_response = {{#asyncio}}await {{/asyncio}}self.read_authorization_models(options)
return ReadAuthorizationModelResponse(api_response.authorization_models[0])
Expand All @@ -327,7 +320,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadChanges")
kwargs = options_to_kwargs(options)
kwargs["type"] = body.type
api_response = {{#asyncio}}await {{/asyncio}}self._api.read_changes(
Expand All @@ -347,7 +339,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Read")
page_size = None
continuation_token = None
if options:
Expand Down Expand Up @@ -449,7 +440,7 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Writes")
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Write")
transaction = options_to_transaction_info(options)
if not transaction.disabled:
results = {{#asyncio}}await {{/asyncio}}self._write_with_transaction(body, options)
Expand Down Expand Up @@ -506,8 +497,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Check")

kwargs = options_to_kwargs(options)

req_body = CheckRequest(
Expand Down Expand Up @@ -594,7 +583,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Expand")
kwargs = options_to_kwargs(options)

req_body = ExpandRequest(
Expand Down Expand Up @@ -622,7 +610,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListObjects")
kwargs = options_to_kwargs(options)

req_body = ListObjectsRequest(
Expand Down Expand Up @@ -677,7 +664,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListUsers")
kwargs = options_to_kwargs(options)

req_body = ListUsersRequest(
Expand Down Expand Up @@ -711,7 +697,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAssertions")

kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)
Expand All @@ -728,7 +713,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "WriteAssertions")
kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
# convert options to kwargs
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListStores")
kwargs = options_to_kwargs(options)
api_response = self._api.list_stores(
**kwargs,
Expand All @@ -194,7 +193,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "CreateStore")
kwargs = options_to_kwargs(options)
api_response = self._api.create_store(
body,
Expand All @@ -210,7 +208,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "GetStore")
kwargs = options_to_kwargs(options)
api_response = self._api.get_store(
**kwargs,
Expand All @@ -225,7 +222,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "DeleteStore")
kwargs = options_to_kwargs(options)
api_response = self._api.delete_store(
**kwargs,
Expand All @@ -244,7 +240,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAuthorizationModels")
kwargs = options_to_kwargs(options)
api_response = self._api.read_authorization_models(
**kwargs,
Expand All @@ -260,7 +255,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "WriteAuthorizationModel")
kwargs = options_to_kwargs(options)
api_response = self._api.write_authorization_model(
body,
Expand All @@ -276,7 +270,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAuthorizationModel")
kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)
api_response = self._api.read_authorization_model(
Expand All @@ -293,7 +286,7 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadLatestAuthoriationModel")
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadLatestAuthorizationModel")
options["page_size"] = 1
api_response = self.read_authorization_models(options)
return ReadAuthorizationModelResponse(api_response.authorization_models[0])
Expand All @@ -313,7 +306,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadChanges")
kwargs = options_to_kwargs(options)
kwargs["type"] = body.type
api_response = self._api.read_changes(
Expand All @@ -333,7 +325,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Read")
page_size = None
continuation_token = None
if options:
Expand Down Expand Up @@ -486,8 +477,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Check")

kwargs = options_to_kwargs(options)

req_body = CheckRequest(
Expand Down Expand Up @@ -565,7 +554,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "Expand")
kwargs = options_to_kwargs(options)

req_body = ExpandRequest(
Expand Down Expand Up @@ -593,7 +581,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListObjects")
kwargs = options_to_kwargs(options)

req_body = ListObjectsRequest(
Expand Down Expand Up @@ -647,7 +634,6 @@ class OpenFgaClient:
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
:param consistency(options) - The type of consistency preferred for the request
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListUsers")
kwargs = options_to_kwargs(options)

req_body = ListUsersRequest(
Expand Down Expand Up @@ -682,7 +668,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ReadAssertions")

kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)
Expand All @@ -699,7 +684,6 @@ class OpenFgaClient:
:param retryParams.maxRetry(options) - Override the max number of retries on each API request
:param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated
"""
options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "WriteAssertions")
kwargs = options_to_kwargs(options)
authorization_model_id=self._get_authorization_model_id(options)

Expand Down

0 comments on commit 8689b27

Please sign in to comment.