Skip to content

Commit

Permalink
docs(python-sdk): document the sync OpenFgaClient
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Nov 2, 2023
1 parent 660bb33 commit e917417
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config/clients/python/template/README_initializing.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,26 @@ async def main():
await fga_client.close()

```

#### Synchronous Client

To run outside of an async context, the project exports a synchronous client
from `openfga_sdk.sync` that supports all the credential types and calls,
without requiring async/await.

```python
import {{packageName}}
from {{packageName}}.sync.client import OpenFgaClient


def main():
configuration = {{packageName}}.ClientConfiguration(
api_scheme={{appUpperCaseName}}_API_SCHEME, # optional, defaults to "https"
api_host={{appUpperCaseName}}_API_HOST, # required, define without the scheme (e.g. api.{{sampleApiDomain}} instead of https://api.{{sampleApiDomain}})
store_id={{appUpperCaseName}}_STORE_ID, # optional, not needed when calling `CreateStore` or `ListStores`
authorization_model_id={{appUpperCaseName}}_AUTHORIZATION_MODEL_ID, # optional, can be overridden per request
)
# Enter a context with an instance of the OpenFgaClient
with OpenFgaClient(configuration) as fga_client:
api_response = fga_client.read_authorization_models()
```

0 comments on commit e917417

Please sign in to comment.