Help Center/ Workspace/ API Reference/ Workspace APIs/ Desktop Statistics/ Querying the Desktop Usage Duration
Updated on 2024-01-10 GMT+08:00

Querying the Desktop Usage Duration

Function

Query the desktop usage duration.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v2/{project_id}/desktops/statistics/used

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

No

String

MIME type of the request body.

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

desktop_ids

No

Array of strings

Desktop ID set.

start_time

No

String

Start time. The format is yyyy-MM-dd (UTC time). If this parameter is not specified, data of the latest 15 days is queried by default. Data of a maximum of 31 days can be queried.

end_time

No

String

End time. The format is yyyy-MM-dd (UTC time). If this parameter is not specified, data of the latest 15 days is queried by default. Data of a maximum of 31 days can be queried.

desktop_username

No

String

If the username of the desktop is specified, only the usage time of the user is queried.

offset

No

Integer

Start position of the data record to be returned. This parameter is used for pagination query. The value ranges from 0 to 2000. The default value is 0.

limit

No

Integer

Number of information items to be returned in the query result. This parameter is used for pagination query. The value ranges from 0 to 100. The default value is 100.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

desktop_used_info_list

Array of DesktopUsedHoursInfo objects

Desktop usage information (divided by desktop ID).

total_count

Integer

Total number.

Table 5 DesktopUsedHoursInfo

Parameter

Type

Description

desktop_id

String

Desktop ID.

desktop_username

String

User.

used_info_list

Array of DesktopUsedInfo objects

List of desktop usage time.

Table 6 DesktopUsedInfo

Parameter

Type

Description

date

String

Date. The format is yyyy-MM-dd (UTC time).

use_time

String

Total online duration, in hours. The value is accurate to two decimal places, for example, 1.32.

Status code: default

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code, which is returned upon failure.

error_msg

String

Error description.

Example Requests

None

Example Responses

Status code: 200

Response to the request for querying the desktop usage duration.

{
  "desktop_used_info_list" : [ {
    "desktop_id" : "c6e6dbd7-c950-471d-a6a7-01d0fb62f450",
    "used_info_list" : [ {
      "date" : "2022-12-09",
      "use_time" : 12.62
    }, {
      "date" : "2022-12-10",
      "use_time" : 2.62
    }, {
      "date" : "2022-12-11",
      "use_time" : 1.02
    }, {
      "date" : "2022-12-12",
      "use_time" : 0
    }, {
      "date" : "2022-12-13",
      "use_time" : 0
    }, {
      "date" : "2022-12-14",
      "use_time" : 3.87
    }, {
      "date" : "2022-12-15",
      "use_time" : 3.56
    } ]
  }, {
    "desktop_id" : "d5367f84-1d64-498e-9b92-093002ac6ce9",
    "used_info_list" : [ {
      "date" : "2022-12-09",
      "use_time" : 10.56
    }, {
      "date" : "2022-12-10",
      "use_time" : 1.38
    }, {
      "date" : "2022-12-11",
      "use_time" : 0
    }, {
      "date" : "2022-12-12",
      "use_time" : 0
    }, {
      "date" : "2022-12-13",
      "use_time" : 0
    }, {
      "date" : "2022-12-14",
      "use_time" : 3.87
    }, {
      "date" : "2022-12-15",
      "use_time" : 3.56
    } ]
  } ],
  "total_count" : 2
}

Status Codes

Status Code

Description

200

Response to the request for querying the desktop usage duration.

default

Error response.

Error Codes

See Error Codes.