Skip to content

Commit

Permalink
fix: correct usage of the sdk method header (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris authored Oct 25, 2024
2 parents 64d19e0 + b6c1f2d commit 9a33c4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 55 deletions.
30 changes: 2 additions & 28 deletions openfga_sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ async def list_stores(self, options: dict[str, int | str] = None):
: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 = await self._api.list_stores(
**kwargs,
Expand All @@ -223,7 +222,6 @@ async def create_store(
: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 = await self._api.create_store(body, **kwargs)
return api_response
Expand All @@ -236,7 +234,6 @@ async def get_store(self, options: dict[str, int | str] = None):
: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 = await self._api.get_store(
**kwargs,
Expand All @@ -251,7 +248,6 @@ async def delete_store(self, options: dict[str, int | str] = None):
: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 = await self._api.delete_store(
**kwargs,
Expand All @@ -270,9 +266,6 @@ async def read_authorization_models(self, options: dict[str, int | str] = None):
: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 = await self._api.read_authorization_models(
**kwargs,
Expand All @@ -290,9 +283,6 @@ async def write_authorization_model(
: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 = await self._api.write_authorization_model(
body,
Expand All @@ -308,9 +298,6 @@ async def read_authorization_model(self, options: dict[str, int | str] = None):
: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 = await self._api.read_authorization_model(
Expand All @@ -330,7 +317,7 @@ async def read_latest_authorization_model(
: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, CLIENT_METHOD_HEADER, "ReadLatestAuthorizationModel"
)
options["page_size"] = 1
api_response = await self.read_authorization_models(options)
Expand All @@ -353,7 +340,6 @@ async def read_changes(
: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 = await self._api.read_changes(
Expand All @@ -373,7 +359,6 @@ async def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None):
: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 @@ -494,7 +479,7 @@ async def write(self, body: ClientWriteRequest, options: dict[str, str] = None):
: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 = await self._write_with_transaction(body, options)
Expand Down Expand Up @@ -561,8 +546,6 @@ async def check(self, body: ClientCheckRequest, options: dict[str, str] = None):
: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 @@ -658,7 +641,6 @@ async def expand(self, body: ClientExpandRequest, options: dict[str, str] = None
: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 All @@ -685,7 +667,6 @@ async def list_objects(
: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 @@ -750,7 +731,6 @@ async def list_users(
: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 @@ -784,9 +764,6 @@ async def read_assertions(self, options: dict[str, str] = None):
: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 @@ -805,9 +782,6 @@ async def write_assertions(
: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
28 changes: 1 addition & 27 deletions openfga_sdk/sync/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def list_stores(self, options: dict[str, int | str] = None):
: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 @@ -223,7 +222,6 @@ def create_store(
: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, **kwargs)
return api_response
Expand All @@ -236,7 +234,6 @@ def get_store(self, options: dict[str, int | str] = None):
: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 @@ -251,7 +248,6 @@ def delete_store(self, options: dict[str, int | str] = None):
: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 @@ -270,9 +266,6 @@ def read_authorization_models(self, options: dict[str, int | str] = None):
: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 @@ -290,9 +283,6 @@ def write_authorization_model(
: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 @@ -308,9 +298,6 @@ def read_authorization_model(self, options: dict[str, int | str] = None):
: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 @@ -328,7 +315,7 @@ def read_latest_authorization_model(self, options: dict[str, int | str] = None):
: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, CLIENT_METHOD_HEADER, "ReadLatestAuthorizationModel"
)
options["page_size"] = 1
api_response = self.read_authorization_models(options)
Expand All @@ -351,7 +338,6 @@ def read_changes(
: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 @@ -371,7 +357,6 @@ def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None):
: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 @@ -554,8 +539,6 @@ def check(self, body: ClientCheckRequest, options: dict[str, str] = None):
: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 @@ -649,7 +632,6 @@ def expand(self, body: ClientExpandRequest, options: dict[str, str] = None):
: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 All @@ -676,7 +658,6 @@ def list_objects(
: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 @@ -739,7 +720,6 @@ def list_users(self, body: ClientListUsersRequest, options: dict[str, str] = Non
: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 @@ -773,9 +753,6 @@ def read_assertions(self, options: dict[str, str] = None):
: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 @@ -794,9 +771,6 @@ def write_assertions(
: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 9a33c4a

Please sign in to comment.