Activity Log Routes

routes for interacting with the activity log

source

get_activity_log_object_types

 get_activity_log_object_types (auth:domolibrary.client.DomoAuth.DomoAuth,
                                parent_class:str=None,
                                debug_num_stacks_to_drop=1,
                                debug_api:bool=False,
                                session:httpx.AsyncClient=None)

retrieves a list of valid objectTypes that can be used to search the activity_log API

sample implementation of get_activity_log_object_types

# import pandas as pd

try:
    token_auth = dmda.DomoTokenAuth(
        domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
        domo_instance=os.environ['DOMO_INSTANCE'],
    )

    al_objecttype_res = await get_activity_log_object_types(auth=token_auth)

    print(pd.DataFrame(al_objecttype_res.response))

    # use to update `ActivityLog_ObjectType` enum
    # [ f"{objecttype.get('translation').upper().replace(' ', '_')} = '{objecttype.get('type')}'" for objecttype in  al_objecttype_res.response]

except Exception as e:
    print(e)
                       type             translation
0                     TOKEN              API Client
1              ACCESS_TOKEN            Access token
2                   ACCOUNT                 Account
3          ACCOUNT_TEMPLATE        Account Template
4              ACTIVITY_LOG            Activity log
..                      ...                     ...
101      Workbench_SCHEDULE      Workbench schedule
102       WORKFLOW_INSTANCE       Workflow Instance
103          WORKFLOW_MODEL          Workflow Model
104  WORKFLOW_MODEL_VERSION  Workflow Model Version
105    WORKFLOW_TIMER_START    Workflow Timer Start

[106 rows x 2 columns]

source

search_activity_log

 search_activity_log (auth:domolibrary.client.DomoAuth.DomoAuth,
                      start_time:int, end_time:int, maximum:int,
                      object_type:str=None, debug_api:bool=False,
                      debug_loop:bool=False, parent_class:str=None,
                      debug_num_stacks_to_drop:int=1,
                      session:httpx.AsyncClient=None)

loops over activity log api to retrieve audit logs

Type Default Details
auth DomoAuth
start_time int epoch time in milliseconds
end_time int epoch time in milliseconds
maximum int
object_type str None
debug_api bool False
debug_loop bool False
parent_class str None
debug_num_stacks_to_drop int 1
session AsyncClient None
Returns ResponseGetData
end_datetime = dt.datetime.today()
start_datetime = end_datetime - dt.timedelta(days=100)

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

page_res = await search_activity_log(
    object_type="PAGE",
    start_time=convert.convert_datetime_to_epoch_millisecond(start_datetime),
    end_time=convert.convert_datetime_to_epoch_millisecond(end_datetime),
    auth=token_auth,
    maximum=16,
    debug_loop=False,
    debug_api=False,
)

pd.DataFrame(page_res.response[0:5])
objectId objectName
0 849137905 Example Cards
1 -100000 Overview
2 1845973736 DomoStats Activity Log App
3 1267639476 Dojo Solutions
4 1759878295 Beast Modes

sample implementation of search_activity_log

# import pandas as pd
# import datetime as dt
# import domolibrary.utils.convert as convert

end_datetime = dt.datetime.today()
start_datetime = end_datetime - dt.timedelta(days=100)

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

activity_log_res = await search_activity_log(
    object_type="ACTIVITY_LOG",
    start_time=convert.convert_datetime_to_epoch_millisecond(start_datetime),
    end_time=convert.convert_datetime_to_epoch_millisecond(end_datetime),
    auth=token_auth,
    maximum=10,
    debug_loop=False,
    debug_api=False,
)

pd.DataFrame(activity_log_res.response[0:5])
userName userId userType actorName actorId actionType objectName objectId objectType additionalComment time eventText clientId authenticationMethod
0 Jae Wilson1 1893952720 USER 0 VIEWED ACCOUNT:94 94 ACCOUNT 1741705032025 Viewed Account None DEV_TOKEN
1 Jae Wilson1 1893952720 USER 0 VIEWED ACCOUNT:88 88 ACCOUNT 1741705032022 Viewed Account None DEV_TOKEN
2 Jae Wilson1 1893952720 USER 0 VIEWED ACCOUNT:92 92 ACCOUNT 1741705032014 Viewed Account None DEV_TOKEN
3 Jae Wilson1 1893952720 USER 0 VIEWED ACCOUNT:100 100 ACCOUNT 1741705032007 Viewed Account None DEV_TOKEN
4 Jae Wilson1 1893952720 USER 0 VIEWED ACCOUNT:100 100 ACCOUNT 1741705029863 Viewed Account None DEV_TOKEN