-
Notifications
You must be signed in to change notification settings - Fork 32
/
README_initializing.mustache
83 lines (67 loc) · 3.71 KB
/
README_initializing.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
The documentation below refers to the `{{appShortName}}Client`, to read the documentation for `{{appShortName}}Api`, check out the [`v0.1.1` documentation](https://github.com/{{gitUserId}}/{{gitRepoId}}/tree/v0.1.1#readme).
> The {{appShortName}}Client will by default retry API requests up to {{defaultMaxRetry}} times on 429 and 5xx errors.
#### No Credentials
```python
import {{packageName}}
from {{packageName}}.client import OpenFgaClient
async 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
async with OpenFgaClient(configuration) as fga_client:
api_response = await fga_client.read_authorization_models()
await fga_client.close()
```
#### API Token
```python
import {{packageName}}
from {{packageName}}.client import OpenFgaClient
from {{packageName}}.credentials import Credentials, CredentialConfiguration
async 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
credentials = Credentials(
method='api_token',
configuration=CredentialConfiguration(
api_token= {{appUpperCaseName}}_API_TOKEN,
)
)
)
# Enter a context with an instance of the OpenFgaClient
async with OpenFgaClient(configuration) as fga_client:
api_response = await fga_client.read_authorization_models()
await fga_client.close()
```
#### Client Credentials
```python
import {{packageName}}
from {{packageName}}.client import OpenFgaClient
from {{packageName}}.credentials import Credentials, CredentialConfiguration
async 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
credentials = Credentials(
method='client_credentials',
configuration=CredentialConfiguration(
api_issuer= {{appUpperCaseName}}_API_TOKEN_ISSUER,
api_audience= {{appUpperCaseName}}_API_AUDIENCE,
client_id= {{appUpperCaseName}}_CLIENT_ID,
client_secret= {{appUpperCaseName}}_CLIENT_SECRET,
)
)
)
# Enter a context with an instance of the OpenFgaClient
async with OpenFgaClient(configuration) as fga_client:
api_response = await fga_client.read_authorization_models()
await fga_client.close()
```