Skip to content

Commit 43c3c6b

Browse files
committed
chore sdk
Add Examples for each of the exceptions
1 parent e00dff1 commit 43c3c6b

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from staxapp.config import Config
4+
from staxapp.openapi import StaxClient
5+
from staxapp.exceptions import ApiException
6+
7+
Config.access_key = os.getenv("STAX_ACCESS_KEY")
8+
Config.secret_key = os.getenv("STAX_SECRET_KEY")
9+
10+
# Read all workload catalogue items within your Stax Organisation
11+
workloads = StaxClient("workloads")
12+
try:
13+
response = workloads.ReadCatalogueItems()
14+
except ApiException as e:
15+
print(e)
16+
if e.status_code == 404:
17+
print("No accounts exist")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
from staxapp.config import Config
4+
from staxapp.openapi import StaxClient
5+
from staxapp.exceptions import InvalidCredentialsException
6+
7+
Config.access_key = os.getenv("STAX_ACCESS_KEY")
8+
Config.secret_key = os.getenv("STAX_SECRET_KEY")
9+
10+
# Read all workload catalogue items within your Stax Organisation
11+
try:
12+
workloads = StaxClient("workloads")
13+
except InvalidCredentialsException as e:
14+
print(e)
15+
# Try other credentials
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
3+
from staxapp.config import Config
4+
from staxapp.openapi import StaxClient
5+
from staxapp.exceptions import ValidationException
6+
7+
Config.access_key = os.getenv("STAX_ACCESS_KEY")
8+
Config.secret_key = os.getenv("STAX_SECRET_KEY")
9+
10+
# The user's first name
11+
first_name = <User's first Name>
12+
# The user's second name
13+
last_name = <User's last Name>
14+
# The email for the user
15+
user_email = <User's Email>
16+
17+
try:
18+
# Create a Stax User
19+
teams = StaxClient("teams")
20+
response = teams.CreateUser(
21+
FirstName = first_name,
22+
LastName = last_name,
23+
Email = user_email
24+
)
25+
except InvalidCredentialsException as e:
26+
print(e)
27+
# Try adding a missing field or validating the params

0 commit comments

Comments
 (0)