
# 查询指定ID的同步任务统计数据 - ListSyncTaskStatistic
#### 功能介绍
查询指定ID同步任务的接收同步请求对象数、同步成功对象数、同步失败对象数、同步跳过对象数、同步成功对象容量统计数据(目前只支持华北-北京四、华东-上海一和西南-贵阳一地区)。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-oms/oms_api_0006.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-oms/oms_api_8001.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                     | 访问级别 | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | oms:synctask:statistics | Read | synctask \* | -   | -  | -      |
     
  
 
#### URI
GET /v2/{project_id}/sync-tasks/{sync_task_id}/statistics
表1路径参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                |
|:---|:---|:---|:---|
| project_id   | 是    | String | 项目ID 最小长度：**1** 最大长度：**1024**   |
| sync_task_id | 是    | String | 同步任务ID。 最小长度：**0** 最大长度：**255** |
   
表2Query参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|:---|:---|:---|:---|
| data_type  | 是    | String | 统计数据类型： 多类型查询用','分隔； REQUEST：接收同步请求对象数 SUCCESS：同步成功对象数 FAILURE：同步失败对象数 SKIP：同步跳过对象数 SIZE：同步成功对象容量(Byte) 最小长度：**1** 最大长度：**255** 枚举值： - **REQUEST**   - **SUCCESS**   - **FAILURE**   - **SKIP**   - **SIZE**    |
| start_time | 是    | Long   | 查询开始时间 最小值：**0** 最大值：**9223372036854775807**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| end_time   | 是    | Long   | 查询结束时间 最小值：**0** 最大值：**9223372036854775807**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
   
#### 请求参数
表3请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                      |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | IAM鉴权Token。 最小长度：**1** 最大长度：**16384** |
   
#### 响应参数
**状态码：200**
表4响应Body参数 
| 参数                  | 参数类型                                                                                     | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|:---|
| sync_task_id        | String                                                                                   | 同步任务id 最小长度：**1** 最大长度：**255**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| statistic_time_type | String                                                                                   | 统计结果时间间隔说明描述 FIVE_MINUTES：5分钟 ONE_HOUR：1小时 最小长度：**1** 最大长度：**255** 枚举值： - **FIVE_MINUTES**   - **ONE_HOUR**    |
| statistic_datas     | Array of [StatisticTypeData] objects | 查询的同步任务统计结果集 数组长度：**0 - 1000**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
   
 表5StatisticTypeData 
| 参数        | 参数类型                                                                             | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|:---|:---|:---|
| data_type | String                                                                           | 统计数据类型： REQUEST：请求对象数 SUCCESS：成功对象数 FAILURE：失败对象数 SKIP：跳过对象数 SIZE：对象容量(Byte) 最小长度：**1** 最大长度：**255** 枚举值： - **REQUEST**   - **SUCCESS**   - **FAILURE**   - **SKIP**   - **SIZE**    |
| data      | Array of [StatisticData] objects | 查询的同步任务统计结果集 数组长度：**0 - 1000**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
   
 表6StatisticData 
| 参数            | 参数类型 | 描述                                                                                                                            |
|:---|:---|:---|
| time_stamp    | Long | 统计时间戳 最小值：**0** 最大值：**9223372036854775807** |
| statistic_num | Long | 统计数量 最小值：**0** 最大值：**9223372036854775807**  |
   
**状态码：404**
表7响应Body参数 
| 参数         | 参数类型   | 描述    |
|:---|:---|:---|
| error_msg  | String | 错误信息。 |
| error_code | String | 错误码。  |
   
#### 请求示例
查询2c0689c860ad4728a497c91ec0844383项目下的0d146099-8cf4-437d-b6ef-88e043771c8b任务的统计
```
GET https://{endpoint}/v2/2c0689c860ad4728a497c91ec0844383/sync-tasks/0d146099-8cf4-437d-b6ef-88e043771c8b/statistics?data_type=REQUEST
{
  "sync_task_id" : "4fb05cd2-c94e-44e4-a07f-e65a2f01ebcb",
  "statistic_time_type" : "FIVE_MINUTES",
  "statistic_datas" : [ {
    "data_type" : "REQUEST",
    "data" : [ {
      "time_stamp" : 1700150400000,
      "statistic_num" : 1
    }, {
      "time_stamp" : 1700151000000,
      "statistic_num" : 20
    }, {
      "time_stamp" : 1700184000000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700188200000,
      "statistic_num" : 2
    } ]
  } ]
}
```
#### 响应示例
**状态码：200**
OK
```
{
  "sync_task_id" : "4fb05cd2-c94e-44e4-a07f-e65a2f01ebcb",
  "statistic_time_type" : "FIVE_MINUTES",
  "statistic_datas" : [ {
    "data_type" : "REQUEST",
    "data" : [ {
      "time_stamp" : 1700150400000,
      "statistic_num" : 1
    }, {
      "time_stamp" : 1700151000000,
      "statistic_num" : 20
    }, {
      "time_stamp" : 1700151300000,
      "statistic_num" : 13
    }, {
      "time_stamp" : 1700151600000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700151900000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700152200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700152500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700152800000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700153100000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700153400000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700153700000,
      "statistic_num" : 7
    }, {
      "time_stamp" : 1700154000000,
      "statistic_num" : 13
    }, {
      "time_stamp" : 1700154300000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700154600000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700154900000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700155200000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700155500000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700155800000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700156100000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700156400000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700156700000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700157000000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700157300000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700157600000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700157900000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700158200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700158500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700158800000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700159100000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700159400000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700159700000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700160000000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700160300000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700160600000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700160900000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700161200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700161500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700161800000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700162100000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700162400000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700162700000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700163000000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700163300000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700163600000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700163900000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700164200000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700164500000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700164800000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700165100000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700165400000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700165700000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700166000000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700166300000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700166600000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700166900000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700167200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700167500000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700167800000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700168100000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700168400000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700168700000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700169000000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700169300000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700169600000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700169900000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700170200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700170500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700170800000,
      "statistic_num" : 13
    }, {
      "time_stamp" : 1700171100000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700171400000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700171700000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700172000000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700172300000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700172600000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700172900000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700173200000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700173500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700173800000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700174100000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700174400000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700174700000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700175000000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700175300000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700175600000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700175900000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700176200000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700176500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700176800000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700177100000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700177400000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700177700000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700178000000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700178300000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700178600000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700178900000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700179200000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700179500000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700179800000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700180100000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700180400000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700180700000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700181000000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700181300000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700181600000,
      "statistic_num" : 12
    }, {
      "time_stamp" : 1700181900000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700182200000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700182500000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700182800000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700183100000,
      "statistic_num" : 11
    }, {
      "time_stamp" : 1700183400000,
      "statistic_num" : 10
    }, {
      "time_stamp" : 1700183700000,
      "statistic_num" : 9
    }, {
      "time_stamp" : 1700184000000,
      "statistic_num" : 8
    }, {
      "time_stamp" : 1700188200000,
      "statistic_num" : 1
    } ]
  } ]
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  查询2c0689c860ad4728a497c91ec0844383项目下的0d146099-8cf4-437d-b6ef-88e043771c8b任务的统计
  ```
  package com.huaweicloud.sdk.test;
  import com.huaweicloud.sdk.core.auth.ICredential;
  import com.huaweicloud.sdk.core.auth.BasicCredentials;
  import com.huaweicloud.sdk.core.exception.ConnectionException;
  import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
  import com.huaweicloud.sdk.core.exception.ServiceResponseException;
  import com.huaweicloud.sdk.oms.v2.region.OmsRegion;
  import com.huaweicloud.sdk.oms.v2.*;
  import com.huaweicloud.sdk.oms.v2.model.*;
  public class ListSyncTaskStatisticSolution {
      public static void main(String[] args) {
          // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
          // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
          String ak = System.getenv("CLOUD_SDK_AK");
          String sk = System.getenv("CLOUD_SDK_SK");
          String projectId = "{project_id}";
          ICredential auth = new BasicCredentials()
                  .withProjectId(projectId)
                  .withAk(ak)
                  .withSk(sk);
          OmsClient client = OmsClient.newBuilder()
                  .withCredential(auth)
                  .withRegion(OmsRegion.valueOf("<YOUR REGION>"))
                  .build();
          ListSyncTaskStatisticRequest request = new ListSyncTaskStatisticRequest();
          request.withSyncTaskId("{sync_task_id}");
          try {
              ListSyncTaskStatisticResponse response = client.listSyncTaskStatistic(request);
              System.out.println(response.toString());
          } catch (ConnectionException e) {
              e.printStackTrace();
          } catch (RequestTimeoutException e) {
              e.printStackTrace();
          } catch (ServiceResponseException e) {
              e.printStackTrace();
              System.out.println(e.getHttpStatusCode());
              System.out.println(e.getRequestId());
              System.out.println(e.getErrorCode());
              System.out.println(e.getErrorMsg());
          }
      }
  }
  ```
- [Python]
  查询2c0689c860ad4728a497c91ec0844383项目下的0d146099-8cf4-437d-b6ef-88e043771c8b任务的统计
  ```
  # coding: utf-8
  import os
  from huaweicloudsdkcore.auth.credentials import BasicCredentials
  from huaweicloudsdkoms.v2.region.oms_region import OmsRegion
  from huaweicloudsdkcore.exceptions import exceptions
  from huaweicloudsdkoms.v2 import *
  if __name__ == "__main__":
      # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
      # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
      ak = os.environ["CLOUD_SDK_AK"]
      sk = os.environ["CLOUD_SDK_SK"]
      projectId = "{project_id}"
      credentials = BasicCredentials(ak, sk, projectId)
      client = OmsClient.new_builder() \
          .with_credentials(credentials) \
          .with_region(OmsRegion.value_of("<YOUR REGION>")) \
          .build()
      try:
          request = ListSyncTaskStatisticRequest()
          request.sync_task_id = "{sync_task_id}"
          response = client.list_sync_task_statistic(request)
          print(response)
      except exceptions.ClientRequestException as e:
          print(e.status_code)
          print(e.request_id)
          print(e.error_code)
          print(e.error_msg)
  ```
- [Go]
  查询2c0689c860ad4728a497c91ec0844383项目下的0d146099-8cf4-437d-b6ef-88e043771c8b任务的统计
  ```
  package main
  import (
  "fmt"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
      oms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2"
  "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/model"
      region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/oms/v2/region"
  )
  func main() {
      // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
      // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
      ak := os.Getenv("CLOUD_SDK_AK")
      sk := os.Getenv("CLOUD_SDK_SK")
      projectId := "{project_id}"
      auth, err := basic.NewCredentialsBuilder().
          WithAk(ak).
          WithSk(sk).
          WithProjectId(projectId).
          SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      hcClient, err := oms.OmsClientBuilder().
           WithRegion(region.ValueOf("<YOUR REGION>")).
           WithCredential(auth).
           SafeBuild()
      if err != nil {
          fmt.Println(err)
          return
      }
      client := oms.NewOmsClient(hcClient)
      request := &model.ListSyncTaskStatisticRequest{}
  request.SyncTaskId = "{sync_task_id}"
  response, err := client.ListSyncTaskStatistic(request)
  if err == nil {
          fmt.Printf("%+v\n", response)
      } else {
          fmt.Println(err)
      }
  }
  ```
- [更多]
  更多编程语言的SDK代码示例，请参见[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/OMS/sdk?api=ListSyncTaskStatistic)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述        |
|:---|:---|
| 200 | OK        |
| 404 | Not Found |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-oms/ErrorCode.html)。
