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.

token_auth = dmda.DomoTokenAuth(
    domo_instance="domo-alpha",
    domo_access_token=os.environ["ALPHA_ACCESS_TOKEN"],
)

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

token_auth = dmda.DomoTokenAuth(
    domo_instance="domo-alpha",
    domo_access_token=os.environ["ALPHA_ACCESS_TOKEN"],
)

res = await application_routes.get_applications(auth=token_auth)

application_id = next(
    (
        app["applicationId"]
        for app in res.response
        if app["name"] == "Toolkit: Remote Domo Stats"
    )
)

res = await application_routes.get_application_jobs(
    application_id=application_id, auth=token_auth
)
job_id = res.response[1]["jobId"]

test_job = await DomoJob_RemoteDomoStats.get_by_id(
    job_id=job_id, application_id=application_id, auth=token_auth, return_raw=False
)

# 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}
token_auth = dmda.DomoTokenAuth(
    domo_instance=os.environ["DOMO_INSTANCE"],
    domo_access_token=os.environ["DOMO_ACCESS_TOKEN"],
)

config = RemoteDomoStats_Config._from_json(
    {"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",
}

s = Watchdog_ConfigFactory[obj["type"].upper()].value._from_json(obj)

s.to_json()
{'entityIds': ['39ee901e-ab22-4c7c-aab2-010c80da8d52',
  '384ef8ba-0782-4062-be99-671fa46badd7'],
 'entityType': 'DATA_SOURCE',
 'type': 'custom_query',
 'sqlQuery': 'SELECT * FROM TABLE'}
token_auth = dmda.DomoTokenAuth(
    domo_instance="domo-alpha",
    domo_access_token=os.environ["ALPHA_ACCESS_TOKEN"],
)

res = await application_routes.get_applications(auth=token_auth)

application_id = next(
    (
        app["applicationId"]
        for app in res.response
        if app["name"] == "Toolkit: Data Watchdog"
    )
)

res = await application_routes.get_application_jobs(
    application_id=application_id, auth=token_auth
)
job_id = res.response[0]["jobId"]


test_job = await DomoJob_Watchdog.get_by_id(
    job_id=job_id,
    application_id=application_id,
    auth=token_auth,
    return_raw=False,
)

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

test_job.description = f"updated on {dt.date.today()}"

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)
token_auth = dmda.DomoTokenAuth(
    domo_instance="domo-alpha",
    domo_access_token=os.environ["ALPHA_ACCESS_TOKEN"],
)

config = Watchdog_Config_ExecutionVariance._from_json(
    {
        "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,
# )