Skip to content

Script Development / Connector Objects with DFF.CONN / Guance

The Guance Connector operation object mainly provides the DataWay object for data writing and the OpenAPI wrapper.

The API Key of this Connector requires the Administrator role

Since this Connector automatically obtains sensitive information such as the workspace Token for subsequent operations such as data reporting.

Therefore, you need to assign the Administrator role to the API Key.

The parameters of DFF.CONN(...) are as follows:

Parameter Type Required / Default Description
connector_id str Required Connector ID
timeout int/float 10 Default HTTP request timeout for the current operation object, in seconds

For the OpenAPI documentation, please refer to:

.dataway

The dataway attribute is the DataWay operation object corresponding to the current Guance, and its usage is the same as that of a directly created DataWay Connector operation object.

Example
1
status_code, result = guance.dataway.write_by_category(category='metric', measurement='host_monitoring', tags={'host': 'web-01'}, fields={'cpu': 10})

For the complete content, please refer to:

.is_api_key_valid / .is_api_key_match

The is_api_key_valid attribute returns whether the current Connector's API Key is valid; is_api_key_match is a compatible alias for the old name:

Example
1
print(guance.is_api_key_valid)
Output Example
1
True

.workspace

The workspace attribute returns the current workspace information:

Example
1
2
import json
print(json.dumps(guance.workspace, indent=2))
Output Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "uuid"        : "wksp_xxxxx",
  "name"        : "xxxxx",
  "rpName"      : "rp1",
  "language"    : "zh",
  "timezone"    : "",
  "bossStation" : "CN",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<other fields omitted>": "..."
}

.workspace_uuid

The workspace_uuid attribute returns the current workspace UUID:

Example
1
print(guance.workspace_uuid)
Output Example
1
wksp_xxxxx

.workspace_token

The workspace_token attribute returns the current workspace Token:

Example
1
print(guance.workspace_token)
Output Example
1
tkn_xxxxx

.workspace_language

The workspace_language attribute returns the current workspace language:

Example
1
print(guance.workspace_language)
Output Example
1
zh

.do_get(...)

Sends a GET request to the Guance OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required OpenAPI path
query dict None URL query parameters
timeout int/float None Timeout for this request; if omitted, the operation object's default value is used
Example
1
2
3
4
import json

result = guance.do_get('/api/v1/workspace/get')
print(json.dumps(result, indent=2))
Output Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "content": {
    "uuid"        : "wksp_xxxxx",
    "name"        : "xxxxx",
    "rpName"      : "rp1",
    "language"    : "zh",
    "timezone"    : "",
    "bossStation" : "CN",
    "billingState": "normal",
    "versionType" : "pay",
    "token"       : "tkn_xxxxx",
    "cliToken"    : "wkcli_xxxxx",
    "<other fields omitted>": "..."
  }
}

This method returns the complete response object of the OpenAPI and does not automatically extract content. It raises an exception when the HTTP status code is greater than or equal to 400.

.do_post(...)

Sends a POST request to the Guance OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required OpenAPI path
query dict None URL query parameters
body dict None JSON request body
timeout int/float None Timeout for this request; if omitted, the operation object's default value is used
Example
1
2
3
4
body = {
    'desc': 'New description'
}
result = guance.do_post('/api/v1/workspace/modify', body=body)

This method returns the complete response object of the OpenAPI. It raises an exception when the HTTP status code is greater than or equal to 400.

Nodes

Guance has multiple nodes available for use. When creating a Guance Connector, you need to specify the corresponding Guance node.

To ensure full offline support, DataFlux Func saves a copy of the latest Guance node list at the time of each release.

Therefore, after Guance adds new nodes, they may not be reflected in DataFlux Func in a timely manner.


In such cases, you can look up the relevant configuration of new Guance nodes at the following address, then select "Private Deployment" and fill it in manually.

The list of currently available nodes is as follows:

Node Name Address
Fetching latest node list...