Account_Default

token_auth = dmda.DomoTokenAuth(
    domo_instance=os.environ['DOMO_DOJO_INSTANCE'],
    domo_access_token=os.environ["DOMO_DOJO_ACCESS_TOKEN"],
)

account = (await account_routes.get_account_by_id(auth =token_auth, account_id = 71)).response

account_id = account['id']
account
{'id': 71,
 'userId': 1893952720,
 'name': 'domo_creds',
 'displayName': 'DomoLibrary - update 2024-12-16 19:20:40.207759',
 'type': 'data',
 'valid': True,
 'dataProviderType': 'abstract-credential-store',
 'credentialsType': 'fields',
 'createdAt': 1684447092000,
 'createdBy': 1893952720,
 'modifiedAt': 1734376840000,
 'modifiedBy': 1893952720,
 'configurations': {},
 'accountId': 71,
 'accountTemplateId': None,
 'accountTemplateAuthorizationId': None}

source

UpsertAccount_MatchCriteria

 UpsertAccount_MatchCriteria (domo_instance)

base exception


source

Account_CanIModify

 Account_CanIModify (account_id, domo_instance)

base exception

DomoAccount


source

DomoAccount_Default

 DomoAccount_Default (id:int, auth:domolibrary.client.DomoAuth.DomoAuth,
                      name:str=None, data_provider_type:str=None,
                      created_dt:datetime.datetime=None,
                      modified_dt:datetime.datetime=None,
                      owners:List[Any]=None, is_admin_summary:bool=True, C
                      onfig:domolibrary.classes.DomoAccount_Config.DomoAcc
                      ount_Config=None, Access:domolibrary.classes.DomoAcc
                      ess.DomoAccess_Account=None)

DomoAccount GET methods


source

DomoAccounConfig_MissingFields

 DomoAccounConfig_MissingFields (domo_instance, missing_keys, account_id)

base exception


source

DomoAccount_Default.get_by_id

 DomoAccount_Default.get_by_id (auth:domolibrary.client.DomoAuth.DomoAuth,
                                account_id:int,
                                is_suppress_no_config:bool=True,
                                session:httpx.AsyncClient=None,
                                return_raw:bool=False,
                                debug_api:bool=False,
                                debug_num_stacks_to_drop=2,
                                is_use_default_account_class=False,
                                **kwargs)

retrieves account metadata and attempts to retrieve config

sample implementation of get_by_id

this implementation returns a result because accoun_id 5 is linked to a data_provider (domo_governance) that has been defined in the DomoAccount_Config.AccountConfig enum

account_id = 71

domo_account = await DomoAccount_Default.get_by_id(
    auth=token_auth,
    account_id=account_id,
    return_raw=False,
    debug_api=False,
    is_suppress_no_config=False,
)

print(domo_account)
print(domo_account.Config)
DomoAccount_Default(id=71, name='DomoLibrary - update 2024-12-16 19:20:40.207759', data_provider_type='abstract-credential-store', created_dt=datetime.datetime(2023, 5, 18, 21, 58, 12), modified_dt=datetime.datetime(2024, 12, 16, 19, 20, 40), owners=None, is_admin_summary=False)
DomoAccount_Config_AbstractCredential(data_provider_type='abstract-credential-store', is_oauth=False, credentials='********')

This implementation fails because the data_provider_type has not been defined in DomoAccount_Config.AccountConfig

DomoAccount CRUD Methods

Create Account

domo_account = await DomoAccount_Default.get_by_id(auth=token_auth, account_id=account_id)
domo_account.name = f"DomoLibrary - update {dt.datetime.now()}"
await domo_account.update_name()
DomoAccount_Default(id=71, name='DomoLibrary - update 2024-12-16 19:22:55.340181', data_provider_type='abstract-credential-store', created_dt=datetime.datetime(2023, 5, 18, 21, 58, 12), modified_dt=datetime.datetime(2024, 12, 16, 19, 22, 55), owners=None, is_admin_summary=False)

DomoAccount Config


source

DomoAccount_Default.update_config

 DomoAccount_Default.update_config
                                    (auth:domolibrary.client.DomoAuth.Domo
                                    Auth=None, debug_api:bool=False, confi
                                    g:domolibrary.classes.DomoAccount_Conf
                                    ig.DomoAccount_Config=None,
                                    is_suppress_no_config=False,
                                    debug_num_stacks_to_drop=2,
                                    session:httpx.AsyncClient=None,
                                    return_raw:bool=False,
                                    is_update_config:bool=False)
Type Default Details
auth DomoAuth None
debug_api bool False
config DomoAccount_Config None
is_suppress_no_config bool False
debug_num_stacks_to_drop int 2
session AsyncClient None
return_raw bool False
is_update_config bool False if calling the Api, Domo will send encrypted values (astericks) in most cases it’s best not to try to retrieve updated values from the API

source

AccountClass_CRUD_Error

 AccountClass_CRUD_Error (cls_instance, message)

base exception

Sample implementation of update_config

to update the account config,

# creates a DomoAccount object
domo_account = await DomoAccount_Default.get_by_id(auth=token_auth, account_id=account_id, debug_api = True)

# old_modified = domo_account.modified_dt
# print(old_modified)

# update domo Account API without passing explicit config object
domo_account.Config.credentials = "any_new_value_goes_here"
await domo_account.update_config(debug_api = False)

# new_modified =domo_account.modified_dt
# print(new_modified)
# old_modified==new_modified
πŸ› debugging get_data
{'body': None,
 'function_name': 'get_traceback',
 'headers': {'Connection': 'keep-alive',
             'Content-Type': 'application/json',
             'accept': 'application/json, text/plain',
             'x-domo-developer-token': '83ece44f1451d4b581e1191f98cd411164f0b5b6ad2755b3'},
 'method': 'GET',
 'params': None,
 'parent_class': 'DomoAccount_Default',
 'url': 'https://domo-community.domo.com/api/data/v1/accounts/71?unmask=true'}
get_data: no body
get_data_response <Response [200 OK]>
πŸ› debugging get_data
{'body': None,
 'function_name': 'get_traceback',
 'headers': {'Connection': 'keep-alive',
             'Content-Type': 'application/json',
             'accept': 'application/json, text/plain',
             'x-domo-developer-token': '83ece44f1451d4b581e1191f98cd411164f0b5b6ad2755b3'},
 'method': 'GET',
 'params': None,
 'parent_class': 'DomoAccount_Default',
 'url': 'https://domo-community.domo.com/api/data/v1/providers/abstract-credential-store/account/71?unmask=true'}
get_data: no body
get_data_response <Response [200 OK]>
DomoAccount_Config_AbstractCredential(data_provider_type='abstract-credential-store', is_oauth=False, credentials='any_new_value_goes_here')

The config can be updated by passing a new AccountConfig object

# import json
domo_account = await DomoAccount_Default.get_by_id(auth=token_auth, account_id=account_id)

# update domo Account API by passing new config object
config = AccountConfig.abstract_credential_store.value(
    credentials=json.dumps({"domo_instance": token_auth.domo_instance})
)
await domo_account.update_config(config=config)
DomoAccount_Config_AbstractCredential(data_provider_type='abstract-credential-store', is_oauth=False, credentials='{"domo_instance": "domo-community"}')

Domo Account Access

await domo_account.Access.get()
[Access_Entity(entity=DomoUser(id='233216585', display_name='test - updated via dl 2024-12-16', email_address='test4@test.com', role_id=3, department=None, title=None, avatar_key='/api/content/v1/avatar/USER/233216585', phone_number=None, web_landing_page=None, web_mobile_landing_page=None, employee_id=None, employee_number=None, hire_date=None, reports_to=None, publisher_domain=None, subscriber_domain=None, virtual_user_id=None, created_dt=datetime.datetime(2024, 11, 18, 17, 26, 50), last_activity_dt=None, custom_attributes={}, role=DomoRole(id=3, name='Editor', description='Can edit Cards, Pages, DataSets, and Dataflows', is_system_role=True, is_default_role=None, grants=[], membership_ls=[]), domo_api_clients=None, domo_access_tokens=None), access_level=<ShareAccount_AccessLevel.CAN_VIEW: 'CAN_VIEW'>),
 Access_Entity(entity=DomoUser(id='55874022', display_name='Grant Smith', email_address='grantsmith@gmail.com', role_id=1, department='', title='', avatar_key='/api/content/v1/avatar/USER/55874022', phone_number='0', web_landing_page=None, web_mobile_landing_page=None, employee_id=None, employee_number=None, hire_date=1618632000000, reports_to='596117551', publisher_domain=None, subscriber_domain=None, virtual_user_id=None, created_dt=datetime.datetime(2020, 5, 8, 17, 55, 28), last_activity_dt=datetime.datetime(2024, 10, 24, 0, 58, 50, 191000), custom_attributes={}, role=DomoRole(id=1, name='Admin', description='Full access to everything', is_system_role=True, is_default_role=None, grants=[], membership_ls=[]), domo_api_clients=None, domo_access_tokens=None), access_level=<ShareAccount_AccessLevel.CAN_VIEW: 'CAN_VIEW'>),
 Access_Entity(entity=DomoUser(id='1893952720', display_name='Jae Wilson1', email_address='jae@datacrew.space', role_id=810756122, department='Business Improvement', title=None, avatar_key='/api/content/v1/avatar/USER/1893952720', phone_number=None, web_landing_page=None, web_mobile_landing_page=None, employee_id=None, employee_number=None, hire_date=None, reports_to=None, publisher_domain=None, subscriber_domain=None, virtual_user_id=None, created_dt=datetime.datetime(2020, 5, 8, 17, 55, 18), last_activity_dt=datetime.datetime(2024, 12, 16, 19, 7, 49, 4000), custom_attributes={}, role=DomoRole(id=810756122, name='super_admin', description='all grants - updated on 2024-11-07', is_system_role=0, is_default_role=None, grants=[], membership_ls=[]), domo_api_clients=None, domo_access_tokens=None), access_level=<ShareAccount_AccessLevel.OWNER: 'OWNER'>),
 Access_Entity(entity=DomoUser(id='1216550715', display_name='8:26 - go to sleep', email_address='test4@domo.com', role_id=2, department='test', title=None, avatar_key='/api/content/v1/avatar/USER/1216550715', phone_number='152', web_landing_page=None, web_mobile_landing_page=None, employee_id=None, employee_number=None, hire_date=None, reports_to=None, publisher_domain=None, subscriber_domain=None, virtual_user_id=None, created_dt=datetime.datetime(2022, 10, 5, 3, 0, 21), last_activity_dt=datetime.datetime(2024, 1, 22, 20, 2, 32, 453000), custom_attributes={}, role=DomoRole(id=2, name='Privileged', description='Full access except for editing users and settings owners', is_system_role=True, is_default_role=None, grants=[], membership_ls=[]), domo_api_clients=None, domo_access_tokens=None), access_level=<ShareAccount_AccessLevel.OWNER: 'OWNER'>),
 Access_Entity(entity=DomoGroup(id=1814479647, name='Admin Test', type='closed', is_system=False, description='', custom_attributes={}), access_level=<ShareAccount_AccessLevel.CAN_VIEW: 'CAN_VIEW'>)]
domo_account = await DomoAccount_Default.get_by_id(account_id=5, auth=token_auth)

try:
    print(
        await domo_account.Access.share(
            access_level=ShareAccount_AccessLevel.OWNER,
            user_id=token_auth.user_id,
            debug_api=False,
        )
    )

except Account_Share_Error as e:
    print(e)
πŸ›‘  Account_Share_Error πŸ›‘ - function: DomoAccess_Account.get_traceback || 5 || status 400 || Bad Request at domo-community
domo_account = await DomoAccount_Default.get_by_id(account_id=45, auth=token_auth)
try:
    print(
        await dmce.gather_with_concurrency(
            *[
                domo_account.Access.share(
                    access_level=ShareAccount_AccessLevel.CAN_EDIT,
                    user_id=token_auth.user_id,
                    debug_api=False,
                )
            ],
            n=10 ))

except Account_Share_Error as e:
    print(e)
πŸ›‘  AccountConfig_UsesOauth πŸ›‘ - function: data provider type google-spreadsheets uses OAuth and therefore wouldn't return a Config object
πŸ›‘  AccountConfig_UsesOauth πŸ›‘ - function: data provider type google-spreadsheets uses OAuth and therefore wouldn't return a Config object
[ResponseGetData(status=200, response='', is_success=True, parent_class=None)]
# import nbdev

nbdev.nbdev_export('./50_DomoAccount_Default.ipynb')