Skip to content

crud

crud

create_objective async

create_objective(
    auth: DomoAuth,
    name: str | None = None,
    period_id: int | None = None,
    payload: dict | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Create a new objective.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
name str | None

Name for the new objective

None
period_id int | None

Period ID the objective belongs to

None
payload dict | None

Pre-built payload (overrides name/period_id, see generate_create_objective_body for the full set of supported fields)

None
return_raw bool

Return raw response without processing

False
context RouteContext | None

RouteContext for request configuration

None

Returns:

Type Description
ResponseGetData

ResponseGetData object containing the created objective

Raises:

Type Description
Objectives_CreateParams_Error

If required parameters are missing

Objectives_CRUD_Error

If objective creation fails

Source code in src/crew_dcs/routes/objectives/crud.py
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def create_objective(
    auth: DomoAuth,
    name: str | None = None,
    period_id: int | None = None,
    payload: dict | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Create a new objective.

    Args:
        auth: Authentication object for API requests
        name: Name for the new objective
        period_id: Period ID the objective belongs to
        payload: Pre-built payload (overrides name/period_id, see
            generate_create_objective_body for the full set of supported fields)
        return_raw: Return raw response without processing
        context: RouteContext for request configuration

    Returns:
        ResponseGetData object containing the created objective

    Raises:
        Objectives_CreateParams_Error: If required parameters are missing
        Objectives_CRUD_Error: If objective creation fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    if not payload and not (name and period_id):
        raise Objectives_CreateParams_Error(
            "Either payload must be provided or both name and period_id are required"
        )

    payload = payload or generate_create_objective_body(name=name, period_id=period_id)
    url = f"https://{auth.domo_instance}.domo.com/api/social/v1/objectives"

    res = await gd.get_data(
        auth=auth, url=url, method="POST", body=payload, context=context
    )

    if return_raw:
        return res
    if not res.is_success:
        raise Objectives_CRUD_Error(operation="create", objective_id=name, res=res)
    return res

delete_objective async

delete_objective(
    auth: DomoAuth,
    objective_id: int | str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Delete an objective.

Note: the Postman collection lists this endpoint without the {{baseUrl}} prefix (i.e. just /social/v1/objectives/:id), which appears to be a collection bug. This function uses the full {{baseUrl}}-prefixed URL, consistent with every other endpoint in the API.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
objective_id int | str

ID of the objective to delete

required
return_raw bool

Return raw response without processing

False
context RouteContext | None

RouteContext for request configuration

None

Returns:

Type Description
ResponseGetData

ResponseGetData object confirming deletion

Raises:

Type Description
Objectives_CRUD_Error

If objective deletion fails

Source code in src/crew_dcs/routes/objectives/crud.py
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
209
210
211
212
213
214
215
216
217
218
219
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def delete_objective(
    auth: DomoAuth,
    objective_id: int | str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Delete an objective.

    Note: the Postman collection lists this endpoint without the {{baseUrl}}
    prefix (i.e. just `/social/v1/objectives/:id`), which appears to be a
    collection bug. This function uses the full `{{baseUrl}}`-prefixed URL,
    consistent with every other endpoint in the API.

    Args:
        auth: Authentication object for API requests
        objective_id: ID of the objective to delete
        return_raw: Return raw response without processing
        context: RouteContext for request configuration

    Returns:
        ResponseGetData object confirming deletion

    Raises:
        Objectives_CRUD_Error: If objective deletion fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = (
        f"https://{auth.domo_instance}.domo.com/api/social/v1/objectives/{objective_id}"
    )

    res = await gd.get_data(auth=auth, url=url, method="DELETE", context=context)

    if return_raw:
        return res
    if not res.is_success:
        raise Objectives_CRUD_Error(
            operation="delete", objective_id=str(objective_id), res=res
        )
    return res

generate_create_objective_body

generate_create_objective_body(
    name: str,
    period_id: int,
    description: str | None = None,
    starts_at: str | None = None,
    expires_at: str | None = None,
    status: str = "NOT_STARTED",
    owner_id: int | None = None,
    owners: list[dict] | None = None,
    assignees: list[dict] | None = None,
    parent_id: int | None = None,
    key_results: list[dict] | None = None,
    tags: list | None = None,
    write_access: bool = True,
    type: str = "PERSONAL",
) -> dict

Generate payload for objective creation.

Source code in src/crew_dcs/routes/objectives/crud.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def generate_create_objective_body(
    name: str,
    period_id: int,
    description: str | None = None,
    starts_at: str | None = None,
    expires_at: str | None = None,
    status: str = "NOT_STARTED",
    owner_id: int | None = None,
    owners: list[dict] | None = None,
    assignees: list[dict] | None = None,
    parent_id: int | None = None,
    key_results: list[dict] | None = None,
    tags: list | None = None,
    write_access: bool = True,
    type: str = "PERSONAL",
) -> dict:
    """Generate payload for objective creation."""
    return {
        "name": name,
        "description": description,
        "startsAt": starts_at,
        "expiresAt": expires_at,
        "status": status,
        "ownerId": owner_id,
        "owners": owners or [],
        "assignees": assignees or [],
        "periodId": period_id,
        "parentId": parent_id,
        "keyResults": key_results or [],
        "tags": tags or [],
        "writeAccess": write_access,
        "type": type,
    }

update_objective async

update_objective(
    auth: DomoAuth,
    objective_id: int | str,
    payload: dict,
    period_id: int | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Update an existing objective.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
objective_id int | str

ID of the objective to update

required
payload dict

Updated objective payload (see generate_create_objective_body for the full set of supported fields)

required
period_id int | None

Optional period ID query parameter

None
return_raw bool

Return raw response without processing

False
context RouteContext | None

RouteContext for request configuration

None

Returns:

Type Description
ResponseGetData

ResponseGetData object containing the updated objective

Raises:

Type Description
Objectives_CRUD_Error

If objective update fails

Source code in src/crew_dcs/routes/objectives/crud.py
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
163
164
165
166
167
168
169
170
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def update_objective(
    auth: DomoAuth,
    objective_id: int | str,
    payload: dict,
    period_id: int | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Update an existing objective.

    Args:
        auth: Authentication object for API requests
        objective_id: ID of the objective to update
        payload: Updated objective payload (see generate_create_objective_body
            for the full set of supported fields)
        period_id: Optional period ID query parameter
        return_raw: Return raw response without processing
        context: RouteContext for request configuration

    Returns:
        ResponseGetData object containing the updated objective

    Raises:
        Objectives_CRUD_Error: If objective update fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = (
        f"https://{auth.domo_instance}.domo.com/api/social/v1/objectives/{objective_id}"
    )
    params = {}
    if period_id is not None:
        params["periodId"] = period_id

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="PUT",
        body=payload,
        params=params,
        context=context,
    )

    if return_raw:
        return res
    if not res.is_success:
        raise Objectives_CRUD_Error(
            operation="update", objective_id=str(objective_id), res=res
        )
    return res