assign-objects-to-label
dci assign-objects-to-label <id> [body]
Assigns or un-assigns objects to the label specified by the ID.
id— Label ID as shown bydci list-labels. This command changes which objects carry the label, so interactive terminals ask for confirmation.
Pass the request body as name: value arguments or pipe JSON on stdin — see Command structure.
Object types
objectType is one of alert, allocation, budget, metric, report,
or annotation. Check the current assignments with
dci get-label-assignments <label-id>.
Examples
# Put a label on a report (object IDs come from the matching list command, here `dci list-reports`).
dci assign-objects-to-label <label-id> add: [{objectType: report, objectId: <report-id> }]
# Label a budget and remove the label from a report in one call, with the body read from a file.
dci assign-objects-to-label <label-id> < assign.json
# assign.json
{"add": [{"objectId": "<budget-id>", "objectType": "budget"}],
"remove": [{"objectId": "<report-id>", "objectType": "report"}]}
# Preview locally without sending a request.
dci assign-objects-to-label <label-id> --dry-run add: [{objectType: report, objectId: <report-id> }]
# Apply without a prompt, for scripts and CI (exit code 30 if confirmation is missing).
dci assign-objects-to-label <label-id> --yes add: [{objectType: report, objectId: <report-id> }]
Request
Content-Type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
add | array of object | Array of objects to assign to the label. | |
add[].objectId | string | yes | The ID of the object to assign/unassign. |
add[].objectType | string | yes | The type of the object. One of: "alert", "allocation", "budget", "metric", "report", "annotation". |
remove | array of object | Array of objects to unassign from the label. | |
remove[].objectId | string | yes | The ID of the object to assign/unassign. |
remove[].objectType | string | yes | The type of the object. One of: "alert", "allocation", "budget", "metric", "report", "annotation". |
Raw JSON schema
{
"type": "object",
"description": "Request to assign or remove objects from a label.",
"properties": {
"add": {
"type": "array",
"items": {
"required": [
"objectId",
"objectType"
],
"type": "object",
"description": "Object identifier and type used for label assignments.",
"properties": {
"objectId": {
"type": "string",
"description": "The ID of the object to assign/unassign."
},
"objectType": {
"type": "string",
"enum": [
"alert",
"allocation",
"budget",
"metric",
"report",
"annotation"
],
"description": "The type of the object."
}
}
},
"description": "Array of objects to assign to the label."
},
"remove": {
"type": "array",
"items": {
"required": [
"objectId",
"objectType"
],
"type": "object",
"description": "Object identifier and type used for label assignments.",
"properties": {
"objectId": {
"type": "string",
"description": "The ID of the object to assign/unassign."
},
"objectType": {
"type": "string",
"enum": [
"alert",
"allocation",
"budget",
"metric",
"report",
"annotation"
],
"description": "The type of the object."
}
}
},
"description": "Array of objects to unassign from the label."
}
}
}
Output
On success, this command produces no response data.
Errors
On failure, dci prints a single error message — with a hint when one is available — and exits with a typed code your scripts can branch on. See Errors and exit codes for the full contract.
HTTP status to exit code mapping
| HTTP status | Exit code | Error code | Meaning |
|---|---|---|---|
| 400 | 30 | VALIDATION_ERROR | The arguments or request body were rejected. Review the command's flags and payload. |
| 401 | 10 | AUTHENTICATION_FAILED | Not signed in, or the API token is invalid. Run dci login or check DCI_API_KEY. |
| 403 | 11 | PERMISSION_DENIED | The DoiT user or the active customer context does not have access. |
| 404 | 20 | RESOURCE_NOT_FOUND | The requested resource does not exist. Check the identifier argument. |
Related
- get-label-assignments — Get label assignments
- list-labels — List labels
- get-label — Retrieve a label
- create-label — Create a label
- API reference: POST /analytics/v1/labels/{id}/assignments
Aliases: assignobjectstolabel