Skip to content

Job

Job

Application_CRUD_Error

Application_CRUD_Error(
    operation: str,
    entity_id: str | None = None,
    res: ResponseGetData | None = None,
    message: str | None = None,
    **kwargs
)

Bases: RouteError

Raised when application create, update, or delete operations fail.

This exception is used for failures during application job creation, modification, or execution operations.

Source code in src/crew_dcs/routes/application.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def __init__(
    self,
    operation: str,
    entity_id: str | None = None,
    res: rgd.ResponseGetData | None = None,
    message: str | None = None,
    **kwargs,
):
    if not message:
        if entity_id:
            message = f"Application {operation} failed for application {entity_id}"
        else:
            message = f"Application {operation} operation failed"

    super().__init__(
        message=message,
        entity_id=entity_id,
        res=res,
        **kwargs,
    )

Application_GET_Error

Application_GET_Error(
    entity_id: str | None = None,
    res: ResponseGetData | None = None,
    message: str | None = None,
    **kwargs
)

Bases: RouteError

Raised when application retrieval operations fail.

This exception is used for failures during GET operations on applications, including API errors and unexpected response formats.

Source code in src/crew_dcs/routes/application.py
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    entity_id: str | None = None,
    res: rgd.ResponseGetData | None = None,
    message: str | None = None,
    **kwargs,
):
    if not message:
        if entity_id:
            message = f"Failed to retrieve application {entity_id}"
        else:
            message = "Failed to retrieve applications"

    super().__init__(message=message, entity_id=entity_id, res=res, **kwargs)

DomoJob dataclass

DomoJob(
    auth: DomoAuth,
    id: str,
    raw: dict = dict(),
    application_id: str = None,
    name: str = None,
    user_id: str = None,
    logs_dataset_id: str = None,
    execution_timeout: int = 1440,
    is_enabled: bool = False,
    customer_id: str = None,
    created_dt: datetime | None = None,
    updated_dt: datetime | None = None,
    description: str = None,
    execution_payload: dict = dict(),
    share_state: dict = dict(),
    accounts: list[str] = list(),
    triggers: list[DomoTrigger] = list(),
)

Bases: DomoEntity

A class for interacting with Domo Application Jobs.

This class represents a job within a Domo application, providing methods for retrieving, creating, updating, and executing jobs.

Attributes:

Name Type Description
auth DomoAuth

Authentication object for API requests

id str

Unique identifier for the job (job_id)

application_id str

ID of the parent application

name str

Name of the job

raw dict

Raw API response data

user_id str

ID of the user who created the job

logs_dataset_id str

Dataset ID where job logs are stored

execution_timeout int

Timeout in minutes for job execution

is_enabled bool

Whether the job is enabled (has triggers)

customer_id str

Customer ID

created_dt datetime | None

Job creation datetime

updated_dt datetime | None

Job last update datetime

description str

Job description

execution_payload dict

Job execution configuration

share_state dict

Job sharing state

accounts list[str]

list of account IDs associated with the job

triggers list[DomoTrigger]

list of job triggers

display_url property

display_url: str

Generate the URL to display this job in the Domo interface.

Returns:

Name Type Description
str str

URL to view the job in Domo

create async classmethod

create(
    auth: DomoAuth,
    application_id: str,
    job_name: str,
    execution_payload: dict,
    job_description: str | None = None,
    execution_timeout: int = 1440,
    accounts: list[str] | None = None,
    triggers: list[dict] | None = None,
    return_raw: bool = False,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Create a new job in the application.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
application_id str

ID of the parent application

required
job_name str

Name for the new job

required
execution_payload dict

Job execution configuration

required
job_description str | None

Optional job description

None
execution_timeout int

Timeout in minutes (default 1440)

1440
accounts list[str] | None

list of account IDs

None
triggers list[dict] | None

list of job triggers

None
return_raw bool

Return raw ResponseGetData instead of DomoJob

False
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session for request pooling

None
debug_num_stacks_to_drop int

Number of stack frames to drop in debug output

2

Returns:

Type Description

DomoJob or ResponseGetData: Created job object or raw response

Raises:

Type Description
CRUD_ApplicationJob_Error

If creation fails

Source code in src/crew_dcs/classes/DomoApplication/Job.py
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
@classmethod
async def create(
    cls,
    auth: DomoAuth,
    application_id: str,
    job_name: str,
    execution_payload: dict,
    job_description: str | None = None,
    execution_timeout: int = 1440,
    accounts: list[str] | None = None,
    triggers: list[dict] | None = None,
    return_raw: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Create a new job in the application.

    Args:
        auth: Authentication object
        application_id: ID of the parent application
        job_name: Name for the new job
        execution_payload: Job execution configuration
        job_description: Optional job description
        execution_timeout: Timeout in minutes (default 1440)
        accounts: list of account IDs
        triggers: list of job triggers
        return_raw: Return raw ResponseGetData instead of DomoJob
        debug_api: Enable API debugging
        session: Optional httpx session for request pooling
        debug_num_stacks_to_drop: Number of stack frames to drop in debug output

    Returns:
        DomoJob or ResponseGetData: Created job object or raw response

    Raises:
        CRUD_ApplicationJob_Error: If creation fails
    """
    body = {
        "jobName": job_name,
        "jobDescription": job_description,
        "executionTimeout": execution_timeout,
        "executionPayload": execution_payload,
        "accounts": accounts or [],
        "triggers": triggers or [],
    }

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await application_routes.create_application_job(
        auth=auth,
        body=body,
        application_id=application_id,
        context=context,
    )

    if return_raw:
        return res

    # Get the created job
    job_id = res.response.get("jobId")
    return await cls.get_by_id(
        auth=auth,
        application_id=application_id,
        job_id=job_id,
        context=context,
    )

execute async

execute(
    return_raw: bool = False,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Execute this job.

Parameters:

Name Type Description Default
return_raw bool

Return raw ResponseGetData

False
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session for request pooling

None
debug_num_stacks_to_drop int

Number of stack frames to drop in debug output

2

Returns:

Name Type Description
ResponseGetData

Response from job execution

Raises:

Type Description
CRUD_ApplicationJob_Error

If execution fails

Source code in src/crew_dcs/classes/DomoApplication/Job.py
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
async def execute(
    self,
    return_raw: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Execute this job.

    Args:
        return_raw: Return raw ResponseGetData
        debug_api: Enable API debugging
        session: Optional httpx session for request pooling
        debug_num_stacks_to_drop: Number of stack frames to drop in debug output

    Returns:
        ResponseGetData: Response from job execution

    Raises:
        CRUD_ApplicationJob_Error: If execution fails
    """
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await application_routes.execute_application_job(
        auth=self.auth,
        application_id=self.application_id,
        job_id=self.id,
        context=context,
    )

    if return_raw:
        return res

    return res

from_dict classmethod

from_dict(auth: DomoAuth, obj: dict[str, Any])

Create a DomoJob instance from a dictionary representation.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
obj dict[str, Any]

Dictionary containing job data from API

required

Returns:

Name Type Description
DomoJob

New instance with populated attributes

Source code in src/crew_dcs/classes/DomoApplication/Job.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
@classmethod
def from_dict(cls, auth: DomoAuth, obj: dict[str, Any]):
    """Create a DomoJob instance from a dictionary representation.

    Args:
        auth: Authentication object
        obj: Dictionary containing job data from API

    Returns:
        DomoJob: New instance with populated attributes
    """
    # Use DomoJob_Base conversion logic
    base_obj = DomoJob_Base._convert_API_res_to_DomoJob_base_obj(obj=obj)

    return cls(
        auth=auth,
        raw=obj,
        **base_obj,
    )

get_by_id async classmethod

get_by_id(
    auth: DomoAuth,
    application_id: str,
    job_id: str,
    return_raw: bool = False,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Retrieve a job by its ID.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
application_id str

ID of the parent application

required
job_id str

Unique identifier of the job

required
return_raw bool

Return raw ResponseGetData instead of DomoJob

False
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session for request pooling

None
debug_num_stacks_to_drop int

Number of stack frames to drop in debug output

2

Returns:

Type Description

DomoJob or ResponseGetData: The job object or raw response

Raises:

Type Description
ApplicationError_NoneRetrieved

If job retrieval fails

Source code in src/crew_dcs/classes/DomoApplication/Job.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@classmethod
async def get_by_id(
    cls,
    auth: DomoAuth,
    application_id: str,
    job_id: str,
    return_raw: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Retrieve a job by its ID.

    Args:
        auth: Authentication object
        application_id: ID of the parent application
        job_id: Unique identifier of the job
        return_raw: Return raw ResponseGetData instead of DomoJob
        debug_api: Enable API debugging
        session: Optional httpx session for request pooling
        debug_num_stacks_to_drop: Number of stack frames to drop in debug output

    Returns:
        DomoJob or ResponseGetData: The job object or raw response

    Raises:
        ApplicationError_NoneRetrieved: If job retrieval fails
    """
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await application_routes.get_application_job_by_id(
        auth=auth,
        application_id=application_id,
        job_id=job_id,
        context=context,
    )

    if return_raw:
        return res

    return cls.from_dict(auth=auth, obj=res.response)

get_entity_by_id async classmethod

get_entity_by_id(
    auth: DomoAuth,
    entity_id: str,
    debug_num_stacks_to_drop: int = 2,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    **kwargs
)

Fetch a job by its entity ID.

Note: For DomoJob, this requires both application_id and job_id. The entity_id is treated as the job_id, and application_id must be provided in kwargs.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
entity_id str

Job ID (job_id)

required
debug_num_stacks_to_drop int

Number of stack frames to drop in debug

2
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session

None
**kwargs

Must include application_id

{}

Returns:

Type Description

DomoJob instance

Raises:

Type Description
ValueError

If application_id not provided in kwargs

Source code in src/crew_dcs/classes/DomoApplication/Job.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
@classmethod
async def get_entity_by_id(
    cls,
    auth: DomoAuth,
    entity_id: str,
    debug_num_stacks_to_drop: int = 2,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    **kwargs,
):
    """Fetch a job by its entity ID.

    Note: For DomoJob, this requires both application_id and job_id.
    The entity_id is treated as the job_id, and application_id must be
    provided in kwargs.

    Args:
        auth: Authentication object
        entity_id: Job ID (job_id)
        debug_num_stacks_to_drop: Number of stack frames to drop in debug
        debug_api: Enable API debugging
        session: Optional httpx session
        **kwargs: Must include application_id

    Returns:
        DomoJob instance

    Raises:
        ValueError: If application_id not provided in kwargs
    """
    application_id = kwargs.get("application_id")
    if not application_id:
        raise ValueError(
            "application_id is required in kwargs for DomoJob.get_entity_by_id()"
        )

    return await cls.get_by_id(
        auth=auth,
        application_id=application_id,
        job_id=entity_id,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        debug_api=debug_api,
        session=session,
        **kwargs,
    )

to_dict

to_dict() -> dict

Convert the job to a dictionary for API requests.

Returns:

Name Type Description
dict dict

Dictionary representation of the job

Source code in src/crew_dcs/classes/DomoApplication/Job.py
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
def to_dict(self) -> dict:
    """Convert the job to a dictionary for API requests.

    Returns:
        dict: Dictionary representation of the job
    """
    trigger_ls = (
        [self.triggers[0].schedule.to_dict()] if len(self.triggers) > 0 else []
    )

    execution_payload = self.execution_payload or {}
    if self.logs_dataset_id:
        execution_payload.update({"metricsDatasetId": self.logs_dataset_id})

    return {
        "jobId": self.id,
        "jobName": self.name,
        "userId": self.user_id,
        "applicationId": self.application_id,
        "customerId": self.customer_id,
        "executionTimeout": self.execution_timeout,
        "executionPayload": execution_payload,
        "shareState": self.share_state,
        "triggers": trigger_ls,
        "jobDescription": self.description,
        "accounts": self.accounts,
    }

update async

update(
    body: dict | None = None,
    return_raw: bool = False,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Update this job's configuration.

Parameters:

Name Type Description Default
body dict | None

Dictionary containing job update data (uses to_dict if None)

None
return_raw bool

Return raw ResponseGetData instead of DomoJob

False
debug_api bool

Enable API debugging

False
session AsyncClient | None

Optional httpx session for request pooling

None
debug_num_stacks_to_drop int

Number of stack frames to drop in debug output

2

Returns:

Type Description

DomoJob or ResponseGetData: Updated job object or raw response

Raises:

Type Description
CRUD_ApplicationJob_Error

If update fails

Source code in src/crew_dcs/classes/DomoApplication/Job.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
async def update(
    self,
    body: dict | None = None,
    return_raw: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Update this job's configuration.

    Args:
        body: Dictionary containing job update data (uses to_dict if None)
        return_raw: Return raw ResponseGetData instead of DomoJob
        debug_api: Enable API debugging
        session: Optional httpx session for request pooling
        debug_num_stacks_to_drop: Number of stack frames to drop in debug output

    Returns:
        DomoJob or ResponseGetData: Updated job object or raw response

    Raises:
        CRUD_ApplicationJob_Error: If update fails
    """
    if body is None:
        body = self.to_dict()

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await application_routes.update_application_job(
        auth=self.auth,
        body=body,
        job_id=self.id,
        application_id=self.application_id,
        context=context,
    )

    if return_raw:
        return res

    # Refresh the job data
    return await self.get_by_id(
        auth=self.auth,
        application_id=self.application_id,
        job_id=self.id,
        context=context,
    )