Skip to content

Commit b798c43

Browse files
committed
chore(sdk): add doco
add an example for how to use a config client
1 parent c49a801 commit b798c43

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

examples/auth.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import json
2+
import os
3+
4+
from staxapp.config import Config
5+
from staxapp.openapi import StaxClient
6+
from customscript import get_hostnames
7+
hostname = get_hostnames()
8+
9+
access_key = os.getenv("STAX_ACCESS_KEY")
10+
secret_key = os.getenv("STAX_SECRET_KEY")
11+
12+
Config.hostname = hostname["au1"]
13+
Config.access_key = access_key
14+
Config.secret_key = secret_key
15+
16+
accounts_au1 = StaxClient('accounts')
17+
18+
au1_response = accounts_au1.CreateAccountType(
19+
Name="sdk-au1"
20+
)
21+
22+
print(json.dumps(au1_response, indent=4, sort_keys=True))
23+
24+
access_key_2 = os.getenv("STAX_ACCESS_KEY_2")
25+
secret_key_2 = os.getenv("STAX_SECRET_KEY_2")
26+
config = Config(hostname=hostname["us1"], access_key=access_key_2, secret_key=secret_key_2)
27+
28+
us1_accounts = StaxClient('accounts', config=config)
29+
30+
us1_response = us1_accounts.CreateAccountType(
31+
Name="sdk-us1"
32+
)
33+
print(json.dumps(us1_response, indent=4, sort_keys=True))

0 commit comments

Comments
 (0)