コード例 #1
0
def delete_account(name):
    scope_id = kapua_config.get_scope_id()
    try:
        api_client = kapua_config.get_api_client()
        api_instance = swagger_client.AccountsApi(api_client)

        account_id = get_account_id(name)
        api_instance.account_delete(scope_id, account_id)
        print(f'Deleted account id: {account_id}')

    except ApiException as e:
        print(f'Exception when calling API: {e}')
コード例 #2
0
def get_account_id(name):
    scope_id = kapua_config.get_scope_id()
    try:
        api_client = kapua_config.get_api_client()
        api_instance = swagger_client.AccountsApi(api_client)
        api_response = api_instance.account_simple_query(scope_id,
                                                         name=name,
                                                         limit=1)

        if len(api_response.items) > 0:
            account_id = api_response.items[0].id
            print(f'Found account id: {account_id} for {name}')
            return account_id
        else:
            raise NameError(f'No account named {name} found')

    except ApiException as e:
        print(f'Exception when calling API: {e}')
コード例 #3
0
def create_account(name, organization, email):
    scope_id = kapua_config.get_scope_id()
    try:
        api_client = kapua_config.get_api_client()
        api_instance = swagger_client.AccountsApi(api_client)

        # AccountCreator | Provides the information for the new Account to be created
        body = swagger_client.AccountCreator(name=name,
                                             organization_name=organization,
                                             organization_email=email)

        # Create an Account
        api_response = api_instance.account_create(scope_id, body)
        pprint(api_response)
        print(f'Created account with id: {api_response.id}')

    except ApiException as e:
        print(f'Exception when calling API: {e}')