= dmda.DomoTokenAuth(
token_auth ="domo-alpha",
domo_instance=os.environ["ALPHA_ACCESS_TOKEN"],
domo_access_token )
Job
A job refers to a scheduled task in an application.
For the purposes of this beta class, the only Job type implemented has been Watchdog. This class will be heavily revised in a future development sprint.
An additional Job type might be PDP Automation Toolkit.
Domo Job
Domno Job is an abstract base class to describe all DomoJob types. A Job captures the parameters of an implementation of one task in the application.
The Job will be extended by implementations of an Application like RemoteDomoStats or DatasetWatchdog
= dmda.DomoTokenAuth(
token_auth ="domo-alpha",
domo_instance=os.environ["ALPHA_ACCESS_TOKEN"],
domo_access_token
)
= await application_routes.get_applications(auth=token_auth)
res
= next(
application_id
("applicationId"]
app[for app in res.response
if app["name"] == "Toolkit: Remote Domo Stats"
)
)
= await application_routes.get_application_jobs(
res =application_id, auth=token_auth
application_id
)= res.response[1]["jobId"]
job_id
= await DomoJob_RemoteDomoStats.get_by_id(
test_job =job_id, application_id=application_id, auth=token_auth, return_raw=False
job_id
)
# pprint(test_job.response)
pprint(test_job)
DomoJob_RemoteDomoStats(name='REMOTE_Users',
application_id='50e7230f-d2f2-42e2-a208-d94c8ae9f64c',
logs_dataset_id='c29116fa-c3ad-4bc9-9de5-0f05ce7e7649',
id='b4fd853a-1524-4512-9e4f-1d7a809913db',
user_id=1623162654,
execution_timeout=1440,
is_enabled=False,
customer_id='domo-alpha',
created_dt=datetime.datetime(2024, 3, 8, 21, 35, 46),
updated_dt=datetime.datetime(2024, 9, 19, 21, 30, 25),
description='updated - 2024-03-08 17:50:24.269350',
execution_payload={'metricsDatasetId': 'c29116fa-c3ad-4bc9-9de5-0f05ce7e7649',
'policies': {'People': '7a7caccc-4724-470d-b89f-e5f6d27676a8'},
'remoteInstance': 'domo-alpha.domo.com'},
share_state={'sharedEntities': [{'accessLevel': 'OWNER',
'id': '1623162654',
'type': 'USER'}]},
accounts=[10],
triggers=[],
remote_instance='domo-alpha',
subscriber_job_id=None,
Config=RemoteDomoStats_Config(policies=[RemoteDomoStats_Config_Policy(type='People',
dataset_id='7a7caccc-4724-470d-b89f-e5f6d27676a8')]))
pprint(test_job.to_json())
{'accounts': [10],
'applicationId': '50e7230f-d2f2-42e2-a208-d94c8ae9f64c',
'customerId': 'domo-alpha',
'executionPayload': {'metricsDatasetId': 'c29116fa-c3ad-4bc9-9de5-0f05ce7e7649',
'policies': {'People': '7a7caccc-4724-470d-b89f-e5f6d27676a8'},
'remoteInstance': 'domo-alpha',
'subscriberJobId': None},
'executionTimeout': 1440,
'jobDescription': 'updated - 2024-03-08 17:50:24.269350',
'jobId': 'b4fd853a-1524-4512-9e4f-1d7a809913db',
'jobName': 'REMOTE_Users',
'shareState': {'sharedEntities': [{'accessLevel': 'OWNER',
'id': '1623162654',
'type': 'USER'}]},
'triggers': [],
'userId': 1623162654}
= dmda.DomoTokenAuth(
token_auth =os.environ["DOMO_INSTANCE"],
domo_instance=os.environ["DOMO_ACCESS_TOKEN"],
domo_access_token
)
= RemoteDomoStats_Config._from_json(
config "AccountPermissions": "b156bfe4-d0e5-4410-8354-b3062973a99c"}
{
)
# await DomoJob_RemoteDomoStats.create(
# auth = token_auth,
# application_id="50e7230f-d2f2-42e2-a208-d94c8ae9f64c",
# logs_dataset_id = 'da68b3ea-088f-4493-ae69-ee5094feaa29' ,
# name="domo-community v3",
# accounts=[96],
# remote_instance=os.environ['DOMO_INSTANCE'],
# config=config,
# return_raw = True
# )
DomoJob_Watchdog
= {
obj "entityIds": [
"39ee901e-ab22-4c7c-aab2-010c80da8d52",
"384ef8ba-0782-4062-be99-671fa46badd7",
],"type": "custom_query",
"entityType": "DATA_SOURCE",
"sqlQuery": "SELECT * FROM TABLE",
}
= Watchdog_ConfigFactory[obj["type"].upper()].value._from_json(obj)
s
s.to_json()
{'entityIds': ['39ee901e-ab22-4c7c-aab2-010c80da8d52',
'384ef8ba-0782-4062-be99-671fa46badd7'],
'entityType': 'DATA_SOURCE',
'type': 'custom_query',
'sqlQuery': 'SELECT * FROM TABLE'}
= dmda.DomoTokenAuth(
token_auth ="domo-alpha",
domo_instance=os.environ["ALPHA_ACCESS_TOKEN"],
domo_access_token
)
= await application_routes.get_applications(auth=token_auth)
res
= next(
application_id
("applicationId"]
app[for app in res.response
if app["name"] == "Toolkit: Data Watchdog"
)
)
= await application_routes.get_application_jobs(
res =application_id, auth=token_auth
application_id
)= res.response[0]["jobId"]
job_id
= await DomoJob_Watchdog.get_by_id(
test_job =job_id,
job_id=application_id,
application_id=token_auth,
auth=False,
return_raw
)
pprint(test_job.to_json())
{'accounts': [],
'applicationId': '33aab8f0-3397-45e1-933c-755abd0f5b3a',
'customerId': 'domo-alpha',
'executionPayload': {'customMessage': None,
'domain': None,
'metricsDatasetId': 'a58f8f4c-5174-496d-928d-510846a3e6fc',
'notifyEmailAddresses': [],
'notifyGroupIds': [],
'notifyUserIds': [1623162654],
'watcherParameters': {'entityIds': ['56ecc63a-a967-4e43-8250-1a3c360f9792'],
'entityType': 'DATA_SOURCE',
'type': 'execution_variance',
'variancePercent': 30},
'webhooks': None},
'executionTimeout': 1440,
'jobDescription': 'updated on 2025-02-18',
'jobId': 'e3de115f-576b-4839-a60e-6268c507e32b',
'jobName': 'does it work?',
'shareState': {'sharedEntities': [{'accessLevel': 'OWNER',
'id': '1623162654',
'type': 'USER'}]},
'triggers': [{'eventEntity': '0 32 1/1 ? * *',
'eventType': 'scheduleTriggered'}],
'userId': 1623162654}
Domo Job CRUD Operations
= f"updated on {dt.date.today()}"
test_job.description
await test_job.update()
ResponseGetData(status=200, response={'jobId': 'e3de115f-576b-4839-a60e-6268c507e32b', 'applicationId': '33aab8f0-3397-45e1-933c-755abd0f5b3a', 'customerId': 'domo-alpha', 'jobName': 'does it work?', 'jobDescription': 'updated on 2025-02-18', 'userId': 1623162654, 'executionTimeout': 1440, 'jobStatus': 'idle', 'executionPayload': {'webhooks': None, 'domain': None, 'watcherParameters': {'entityIds': ['56ecc63a-a967-4e43-8250-1a3c360f9792'], 'entityType': 'DATA_SOURCE', 'type': 'execution_variance', 'variancePercent': 30}, 'customMessage': None, 'metricsDatasetId': 'a58f8f4c-5174-496d-928d-510846a3e6fc', 'notifyUserIds': [1623162654], 'notifyEmailAddresses': [], 'notifyGroupIds': []}, 'executionResponse': {}, 'accounts': [], 'executionClass': 'com.domo.executor.datawatchdog.DataWatchdogExecutor', 'created': 1710803700000, 'updated': 1739891339000, 'statusChanged': 1739891150000, 'triggers': [], 'compressPayload': False}, is_success=True, parent_class=None)
sample execute
await test_job.execute()
ResponseGetData(status=200, response={'requestedBy': 1623162654, 'queuedJobs': [{'jobId': 'e3de115f-576b-4839-a60e-6268c507e32b', 'applicationId': '33aab8f0-3397-45e1-933c-755abd0f5b3a', 'executionId': 'e4fd8acd-4502-496c-b96b-5be292317e81', 'customerId': 'domo-alpha', 'jobName': 'does it work?', 'jobDescription': 'updated on 2025-02-18', 'userId': 1623162654, 'executionTimeout': 1440, 'jobStatus': 'idle', 'executionPayload': {'webhooks': None, 'domain': None, 'watcherParameters': {'entityIds': ['56ecc63a-a967-4e43-8250-1a3c360f9792'], 'entityType': 'DATA_SOURCE', 'type': 'execution_variance', 'variancePercent': 30}, 'customMessage': None, 'metricsDatasetId': 'a58f8f4c-5174-496d-928d-510846a3e6fc', 'notifyUserIds': [1623162654], 'notifyEmailAddresses': [], 'notifyGroupIds': []}, 'executionResponse': {}, 'accounts': [], 'executionClass': 'com.domo.executor.datawatchdog.DataWatchdogExecutor', 'created': 1710803700000, 'updated': 1739891339000, 'statusChanged': 1739891150000, 'triggers': [], 'compressPayload': False}]}, is_success=True, parent_class=None)
= dmda.DomoTokenAuth(
token_auth ="domo-alpha",
domo_instance=os.environ["ALPHA_ACCESS_TOKEN"],
domo_access_token
)
= Watchdog_Config_ExecutionVariance._from_json(
config
{"entityIds": [
"56ecc63a-a967-4e43-8250-1a3c360f9792",
],"entityType": "DATA_SOURCE",
"type": "execution_variance",
"variancePercent": 30,
}
)
# await DomoJob_Watchdog.create(
# auth=token_auth,
# application_id="33aab8f0-3397-45e1-933c-755abd0f5b3a",
# config=config,
# notify_user_ids=[1623162654],
# name="does it work?",
# logs_dataset_id="a58f8f4c-5174-496d-928d-510846a3e6fc",
# return_raw=False,
# )