Skip to content

Commit 346b18e

Browse files
authored
fix(response-json) print json and improve formatting (#69)
1 parent 1f3c531 commit 346b18e

54 files changed

Lines changed: 132 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export STAX_SECRET_KEY=<your_secret_key>
2626
### Read Accounts
2727
The following code can be used to read accounts within your Stax Organisation:
2828
```python
29+
import json
2930
import os
3031

3132
from staxapp.config import Config
@@ -37,12 +38,12 @@ Config.secret_key = os.getenv("STAX_SECRET_KEY")
3738
# Read all accounts within your Stax Organisation
3839
accounts = StaxClient("accounts")
3940
response = accounts.ReadAccounts()
40-
print(response.json())
41+
print(json.dumps(response, indent=4, sort_keys=True))
4142

4243
# Read all active accounts within your Stax Organisation and include tags in the response
4344
accounts = StaxClient("accounts")
4445
response = accounts.ReadAccounts(filter="ACTIVE", include_tags=True)
45-
print(response.json())
46+
print(json.dumps(response, indent=4, sort_keys=True))
4647
```
4748

4849
## Contributing
@@ -52,4 +53,3 @@ For more information on contributing the to the Stax SDK, please see our [guide]
5253
* If you're having trouble using the Stax SDK, please refer to our [documentation](https://www.stax.io/developer/api-tokens/).<br>
5354
* If you've encountered an issue or found a bug, please [open an issue](https://github.com/stax-labs/lib-stax-python-sdk/issues).<br>
5455
* For any other requests, please contact [Stax support](mailto:support@stax.io).
55-

examples/account_types/create_account_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
45
from staxapp.openapi import StaxClient
5-
6+
67
account_type_name = "sdk-2" #<Account Type Name>
78

89
Config.access_key = os.getenv("STAX_ACCESS_KEY")
@@ -13,4 +14,4 @@
1314
response = accounts.CreateAccountType(
1415
Name=account_type_name
1516
)
16-
print(response.json())
17+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/delete_account_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
45
from staxapp.openapi import StaxClient
5-
6+
67
account_type_id = <Account Type Id>
78

89
Config.access_key = os.getenv("STAX_ACCESS_KEY")
@@ -13,4 +14,4 @@
1314
response = accounts.DeleteAccountType(
1415
account_type_id=account_type_id
1516
)
16-
print(response.json())
17+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/read_account_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -9,4 +10,4 @@
910
# Read all account types within your Stax Organisation
1011
accounts = StaxClient("accounts")
1112
response = accounts.ReadAccountTypes()
12-
print(response.json())
13+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/update_account_type.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -17,4 +18,4 @@
1718
account_type_id = account_type_id,
1819
Name = account_type_name
1920
)
20-
print(response.json())
21+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/update_account_type_access.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -20,4 +21,4 @@
2021
AddRoles= access_roles_to_add,
2122
RemoveRoles=access_roles_to_remove
2223
)
23-
print(response.json())
24+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/update_account_type_members.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -21,4 +22,4 @@
2122
response = accounts.UpdateAccountTypeMembers(
2223
Members=account_type_mappings
2324
)
24-
print(response.json())
25+
print(json.dumps(response, indent=4, sort_keys=True))

examples/account_types/update_policies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -19,4 +20,4 @@
1920
AddPolicies= policies_to_add,
2021
RemovePolicies= policies_to_remove
2122
)
22-
print(response.json())
23+
print(json.dumps(response, indent=4, sort_keys=True))

examples/accounts/create_accounts.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
45
from staxapp.openapi import StaxClient
5-
6+
67
account_name = <Account Name>
78
account_type = <Account Type Id>
89

@@ -15,4 +16,4 @@
1516
Name=account_name,
1617
AccountType=account_type,
1718
)
18-
print(response.json())
19+
print(json.dumps(response, indent=4, sort_keys=True))

examples/accounts/read_accounts.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from staxapp.config import Config
@@ -9,9 +10,9 @@
910
# Read all accounts within your Stax Organisation
1011
accounts = StaxClient("accounts")
1112
response = accounts.ReadAccounts()
12-
print(response.json())
13+
print(json.dumps(response, indent=4, sort_keys=True))
1314

1415
# Read all active accounts within your Stax Organisation and include tags in the response
1516
accounts = StaxClient("accounts")
1617
response = accounts.ReadAccounts(filter="ACTIVE", include_tags=True)
17-
print(response.json())
18+
print(json.dumps(response, indent=4, sort_keys=True))

0 commit comments

Comments
 (0)