Get¶
GET /api/v1/workspace/{workspace_uuid}/get
Overview¶
Read a valid Workspace on the current site by UUID.
Before You Begin and Usage Steps¶
First, obtain the UUID from the Workspace list, then query the specific Workspace. The field table and example show a selection of commonly used fields; the full response may contain Workspace credentials, so treat the response as sensitive information.
The example uses External API signature version v20240417. Set the target site's External API URL, Access Key, and Secret Key to DF_EXTERNAL_API_URL, DF_EXTERNAL_ACCESS_KEY, and DF_EXTERNAL_SECRET_KEY, respectively. Replace the example ID with the actual value.
Path Parameters¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| workspace_uuid | string | Y | Target Workspace UUID. Example: wksp_exampleHow to obtain or enter: Obtain it from content.data[].uuid in the response of the Workspace list, and use the original value. |
Request Headers¶
| Parameter | Type | Required | Description |
|---|---|---|---|
| X-Df-SVersion | string | Signature version. The following example uses v20240417. Example: v20240417How to obtain or enter: Enter it as shown in the example, corresponding to the signature algorithm. |
|
| X-Df-Access-Key | string | Y | AK information for the request Example: <access-key>How to obtain or enter: Assigned by the External API administrator. |
| X-Df-Signature | string | Y | Signature information Example: <hex-signature>How to obtain or enter: Use the Secret Key to perform HMAC-SHA256 on the text composed of GET, nonce, the request path and raw query string, the timestamp, and an empty string, then take the hexadecimal result. |
| X-Df-Timestamp | string | Y | Timestamp at request time Example: 1785456000How to obtain or enter: Enter the current Unix second at the time of the call, for example, run date +%s. |
| X-Df-Nonce | string | Y | Nonce generated at request time Example: b53b47e12e514616ad8cb1f17cb66dceHow to obtain or enter: Generate a new random value for each request, for example, uuid.uuid4().hex. |
Additional Parameter Notes¶
Use the External API signing credentials assigned to the current target site.
Request Example¶
import hmac
import os
import time
import uuid
from urllib.parse import urlencode
import requests
server = os.environ["DF_EXTERNAL_API_URL"].rstrip("/")
path = "/api/v1/workspace/wksp_example/get"
query = {}
if query:
path += "?" + urlencode(query)
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
payload = " ".join(("GET", nonce, path, timestamp, ""))
signature = hmac.digest(os.environ["DF_EXTERNAL_SECRET_KEY"].encode(), payload.encode(), "sha256").hex()
headers = {
"X-Df-Access-Key": os.environ["DF_EXTERNAL_ACCESS_KEY"],
"X-Df-Timestamp": timestamp,
"X-Df-Nonce": nonce,
"X-Df-SVersion": "v20240417",
"X-Df-Signature": signature,
}
try:
result = requests.get(server + path, headers=headers, timeout=15)
except requests.RequestException:
print('读取失败,可退避后重新签名重试,保留traceId及查询条件。')
raise SystemExit(1)
if not 200 <= result.status_code < 300:
print("HTTP", result.status_code, result.text) # Retain errorCode, content, and traceId; do not output AK/SK.
raise SystemExit(1)
data = result.json()["content"]
Response¶
HTTP 200, application/json.
| Field | Type | Description |
|---|---|---|
| content.uuid | string | Workspace UUID. It is subsequently placed in the workspace_uuid path parameter or workspaceUUID request field of the API. |
| content.name | string | Workspace display name. |
| content.desc | string | Workspace description. |
| content.status | integer | Workspace status. |
| content.timezone | string | Workspace time zone, for example, Asia/Shanghai. |
| content.language | string | Workspace language setting. |
| content.bindInfo | object or null | Workspace-level override configuration for brand text, email, and domain. |
| content.brandKey | string | Site brand identifier associated with the Workspace. |
{
"code": 200,
"content": {
"uuid": "wksp_example",
"name": "生产监控",
"desc": "生产服务观测",
"status": 0,
"timezone": "Asia/Shanghai",
"language": "zh",
"brandKey": "truewatch",
"bindInfo": {
"name": "示例观测平台",
"domain": "console.example.com"
}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Response¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Resolution |
|---|---|---|---|---|
| 406 | ft.NotFoundWorkspace | The valid Workspace corresponding to the specified UUID does not exist, or the Workspace status is not valid | The specified Workspace was not found. | Obtain a valid UUID again from the Workspace list on the current site. |