|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import boto3 |
| 4 | + |
| 5 | +from staxapp.config import Config |
| 6 | +from staxapp.openapi import StaxClient |
| 7 | +from staxapp.api import Api |
| 8 | +from staxapp.exceptions import ApiException |
| 9 | + |
| 10 | +sts = boto3.client("sts") |
| 11 | + |
| 12 | +security_account = '750975847145' |
| 13 | +api_token_name = 'dean-token' |
| 14 | + |
| 15 | +response = sts.assume_role(RoleArn=f"arn:aws:iam::{security_account}:role/{api_token_name}-access-role", RoleSessionName=f"{api_token_name}-ssm-role") |
| 16 | +assumed_ssm = boto3.client("ssm", |
| 17 | +aws_access_key_id=response["Credentials"]["AccessKeyId"], |
| 18 | +aws_secret_access_key=response["Credentials"]["SecretAccessKey"], |
| 19 | +aws_session_token=response["Credentials"]["SessionToken"] |
| 20 | +) |
| 21 | +api_token_access_key = assumed_ssm.get_parameter(Name=f"/stax/api-tokens/{api_token_name}/AccessKey", WithDecryption=True) |
| 22 | +api_token_secret_key = assumed_ssm.get_parameter(Name=f"/stax/api-tokens/{api_token_name}/SecretKey", WithDecryption=True) |
| 23 | + |
| 24 | +Config.access_key = api_token_access_key['Parameter']['Value'] |
| 25 | +Config.secret_key = api_token_secret_key['Parameter']['Value'] |
| 26 | + |
| 27 | +Config.access_key = 'fake' |
| 28 | +Config.secret_key = 'fake' |
| 29 | + |
| 30 | + |
| 31 | +# fake_client = StaxClient("fake") |
| 32 | +client = StaxClient("accounts") |
| 33 | + |
| 34 | +allAccounts = client.ReadAccounts() |
| 35 | +print(f'{len(allAccounts["Accounts"])}') |
| 36 | +print(client.ReadAccounts(limit=1, offset=0)) |
| 37 | +print(client.ReadAccounts(account_id="9fc4fd2e-1b4a-49b9-a341-d7ee77ea132d")) |
| 38 | +print(client.ReadAccounts(filter="ERROR", account_id="9fc4fd2e-1b4a-49b9-a341-d7ee77ea132d")) |
| 39 | + |
| 40 | + |
| 41 | +client = StaxClient("workloads") |
| 42 | +# client.FakeMethod() |
| 43 | +# print(client.ReadCatalogueItems()) |
| 44 | +response = client.ReadCatalogueItems(catalogue_id='9c4fc016-5221-460d-8bf8-4104178e9e10') |
| 45 | +print(client.ReadCatalogueVersion(version_id='545489ae-c090-45cd-9322-42f9b2ed7b6a', catalogue_id='9c4fc016-5221-460d-8bf8-4104178e9e10')) |
| 46 | +print(client.ReadCatalogueVersion(version_id='d58ad318-fa36-4310-9766-e7f5e4a34f8d', include_parameters=False, catalogue_id='f13dd683-4aa6-4b88-abc8-ad58a7ee04f9')) |
| 47 | + |
| 48 | +# print(client.DeleteCatalogueVersion(catalogue_id='fake')) |
| 49 | +print(client.ReadCatalogueVersion(version_id='d58ad318-fa36-4310-9766-e7f5e4a34f8d', include_parameters=False)) |
| 50 | + |
| 51 | +# print(fake_client.ReadAccounts(limit=1, offset=0)) |
0 commit comments