Get All Labels¶
POST /api/v1/object/hosts/label/list
Overview¶
Read the label details bound to infrastructure objects by data source and object name.
Prerequisites and Usage Steps¶
This group of labels are the labels bound to infrastructure objects. It does not modify collection Tags, host names, or raw log fields, and it is not equivalent to directly managing global label permissions. The API Key determines the current workspace. Call it with the JSON Body on this page; this legacy route's parameter handling also uses URL parameters to override same-named JSON values or to fill in other fields. The URL does not have the same validation as this page's Body, so undeclared compatibility fields should not be treated as a stable extension contract. Do not mix in URL business parameters.
Any one of the entry permissions routine.defaultAccess, infrastructure.setManage, or anonymous.snapshotShared is required; actual object queries are also constrained by data access rules. Set source to the actual object class; for hosts this is usually HOST. When names is omitted or [], all objects returned for that class are queried, which is not the same as listing all global labels in the workspace. Use names to filter a small number of objects for verification first. It is recommended to specify two Unix millisecond timestamps for timeRange; when not provided, an empty range is passed upstream, and all historical data is not guaranteed to be returned.
The response returns a mapping of dynamic object names, which may be {} when no objects are found. Label queries and object storage may be cached (legacy usage notes typically state about 5 minutes); after modifications, wait and read back to verify; strong consistency must not be required. Raw label strings are matched against the current workspace's global label records; unregistered labels are returned as temporary objects with an empty UUID and are not created automatically by this read.
Label scope normalization supports all, scene, monitor, dialing, security, infrastructure, and catalog; all cannot be mixed with other scopes. If a legacy label's scope is invalid, the query also returns 406 invalid scope; check the label configuration rather than only modifying this request's Body.
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | The OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or fill in: Obtain an OpenAPI Key with the required permissions from the API Key management of the target workspace. |
Body Request Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| source | string | Y | Required string; it is not the data namespace namespace=object; the source code has no enum constraint limited to HOST. Null allowed: False Example: HOSTHow to obtain or fill in: Obtain from the object class on the infrastructure page or the collection class of the actual object; hosts usually use HOST. |
| names | array | Optional array; omitted or [] means no filtering by name. Elements should all be deduplicated strings; the public array has no per-element type validation, and invalid elements may fail at the business stage. Null allowed: False Example: ["host-example"]How to obtain or fill in: Copy the object name from the actual object list, matching the source class. |
|
| timeRange | array | Optional array; two valid integer milliseconds are recommended; the declaration has no length or element type restrictions; when omitted, [] is passed to the query service. Null allowed: False Example: [1785427200000, 1785429000000]How to obtain or fill in: Select the start and end Unix milliseconds of the objects to view. |
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/object/hosts/label/list' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"source":"HOST","names":["host-example"],"timeRange":[1785427200000,1785429000000]}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content. | object | Dynamic object name key, corresponding to tags.name returned by the query; it is not a fixed host field. |
| content. | array | List of label information objects sorted by label name; it is not an array of strings. |
| content. | object | Information for one label; unregistered labels are also returned as temporary objects. |
| content. | string | Global label UUID; empty string for unregistered labels, and cannot be used with the tag UUID management API. |
| content. | string | Workspace that owns the registered label; empty for temporary objects. |
| content. | string | Label name; subsequent label modifications should submit this name value, not the whole object or uuid. |
| content. | string | Global label description; empty for temporary objects. |
| content. | string | Label color; default for temporary objects. |
| content. | array | Effective scope of the global label; temporary objects default to [all], and this is not the data access authorization of the current Key. |
| content. | integer or string | Internal row number of the registered label; empty string for temporary objects, and not used as a resource call parameter. |
| content.declaration | object or null | Workspace common declaration attached to non-empty business objects; may be null or an empty object when not configured; empty objects are not added. |
{
"code": 200,
"content": {
"host-example": {
"labels": [
{
"uuid": "tag_example",
"workspaceUUID": "wksp_example",
"name": "production",
"description": "Production environment",
"colour": "default",
"scope": [
"all"
],
"id": 10
},
{
"uuid": "",
"workspaceUUID": "",
"name": "unmanaged-label",
"description": "",
"colour": "default",
"scope": [
"all"
],
"id": ""
}
]
},
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Response¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
Queries may return other syntax or data domain errors based on actual data permissions and the query service; handle HTTP statuses and error codes according to the actual response and the common documentation. This describes the current get_obj_labels, not an internal v2 method that returns a different shape.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | Request field missing, or field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Invalid request JSON syntax | Request JSON format error | Fix the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | Body is not a JSON object | Some json file format errors | Submit the JSON object on this page. |
| 406 | ft.DqlParseError | Source/name cannot form a valid query expression | dql parser parsing failed: {} | Use the actual source and object names, avoid manually constructing values containing quotes or syntax control characters, and check the query first. |
| 503 | ft.QueryServiceUnavailable | Object query upstream 503 is normalized | The query service is temporarily unavailable, please try again later | Back off and retry according to the content.retryable hint; do not poll at high frequency. |
| 500 | ft.InternalServerError | Upstream structure, array sub-element/label name type anomaly, cache/database error, or non-passthrough service 5xx | Internal error | Narrow the object query scope, check legacy label records and the upstream response structure; back off and retry, and provide traceId if it persists. |
| 406 | ft.ParameterValidationFailed | Legacy global label scope is an empty array / contains unknown values / mixes all, or other invalid combinations | invalid scope | Ask the administrator to fix the scope of the corresponding global label; this type of error is not necessarily caused by invalid query parameters in this request. |