
# 查桶对应的CDN信息 - ShowCdnInfo
#### 功能介绍
查桶对应的CDN信息
#### 调用方法
请参见[如何调用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::checkCdnInfo | Read | -           | -   | -  | -      |
     
  
 
#### URI
POST /v2/{project_id}/objectstorage/buckets/cdn-info
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                          |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID 最小长度：**1** 最大长度：**1024** |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                   |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | IAM Token认证，需要确认Token中包含的Project ID与请求URI中修改资源的Project ID匹配。 最小长度：**1** 最大长度：**16384** |
   
表3请求Body参数 
| 参数                | 是否必选 | 参数类型                                                        | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| ak                | 是    | String                                                      | 源端桶的AK（最大长度100个字符），task_type为非url_list时，本参数为必选。 最小长度：**0** 最大长度：**100**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| sk                | 是    | String                                                      | 源端桶的SK（最大长度100个字符），task_type为非url_list时，本参数为必选。 最小长度：**0** 最大长度：**100**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| connection_string | 否    | String                                                      | 连接字符串，用于微软云Blob鉴权 最小长度：**0** 最大长度：**2048**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| cloud_type        | 是    | String                                                      | 云类型 AWS：亚马逊 Aliyun：阿里云 Qiniu：七牛云 QingCloud：青云 Tencent：腾讯云 Baidu：百度云 KingsoftCloud：金山云 Azure：微软云 UCloud：优刻得 HuaweiCloud：华为云 URLSource：URL HEC：HEC 最小长度：**0** 最大长度：**100** |
| region            | 是    | String                                                      | 区域 最小长度：**0** 最大长度：**100**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| app_id            | 否    | String                                                      | 腾讯云APPID，当源端为腾讯云时，需要填写此参数，您可以在腾讯云控制台账号信息页面获取。 最小长度：**0** 最大长度：**255**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| bucket            | 是    | String                                                      | 桶名 最小长度：**0** 最大长度：**100**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| prefix            | 否    | [PrefixKeyInfo] object | 前缀                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| source_cdn        | 是    | [SourceCdnReq] object   | 指定是否启用CDN迁移支持，若包含此字段则为支持，否则为不支持，启用CDN迁移支持后，迁移时将从CDN域名获取源端对象。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
   
 表4PrefixKeyInfo 
| 参数   | 是否必选 | 参数类型             | 描述                                                                                                                                       |
|:---|:---|:---|:---|
| keys | 是    | Array of strings | 键 最小长度：**0** 最大长度：**2048** 数组长度：**0 - 100** |
   
 表5SourceCdnReq 
| 参数                  | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| authentication_key  | 否    | String | CDN鉴权密钥，如果CDN需要进行鉴权，则此选项为必选。 无需授权：无需配置此项。 Qiniu：无需配置此项。 Aliyun：根据authentication_type指定的鉴权方式配置此项。 KingsoftCloud：无需配置此项。 最小长度：**0** 最大长度：**255**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| authentication_type | 是    | String | 鉴权类型: NONE：公开访问，无安全限制, QINIU_PRIVATE_AUTHENTICATION：七牛自定义URL签名, ALIYUN_OSS_A：阿里云 URL携带签名，简单通用, ALIYUN_OSS_B：阿里云 Header携带签名，用于API调用, ALIYUN_OSS_C：阿里云 STS临时安全令牌，最安全, KSYUN_PRIVATE_AUTHENTICATION：金山云 金山云自定义URL签名, AZURE_SAS_TOKEN：微软Azure 灵活安全的共享访问签名, TENCENT_COS_A:腾讯云 多次有效签名（不推荐）, TENCENT_COS_B:腾讯云 单次有效签名，安全性最高, TENCENT_COS_C:腾讯云 Header携带签名，用于API调用, TENCENT_COS_D:腾讯云 Header携带签名，用于API调用. 缺省值：**NONE** 枚举值： - **NONE**   - **QINIU_PRIVATE_AUTHENTICATION**   - **ALIYUN_OSS_A**   - **ALIYUN_OSS_B**   - **ALIYUN_OSS_C**   - **KSYUN_PRIVATE_AUTHENTICATION**   - **AZURE_SAS_TOKEN**   - **TENCENT_COS_A**   - **TENCENT_COS_B**   - **TENCENT_COS_C**   - **TENCENT_COS_D**    |
| domain              | 是    | String | 从指定域名获取对象。 最小长度：**0** 最大长度：**1024**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| protocol            | 是    | String | 协议类型，支持http和https协议。 枚举值： - **http**   - **https**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| crypto_type         | 否    | String | 加解密类型，默认为DEFAULT，可选类型为DEFAULT、KMS 缺省值：**DEFAULT** 最小长度：**1** 最大长度：**32** 枚举值： - **DEFAULT**   - **KMS**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| kms_key_id          | 否    | String | KMS密钥ID，36个字符 最小长度：**0** 最大长度：**36**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
   
#### 响应参数
**状态码：200**
表6响应Body参数 
| 参数                    | 参数类型                                                             | 描述                                                           |
|:---|:---|:---|
| is_same_cloud_type    | Boolean                                                          | 是否相同云类型                                                      |
| is_download_available | Boolean                                                          | 是否下载可用                                                       |
| checked_keys          | Array of [CheckedKey] objects | 返回的已检查的对象数组 数组长度：**0 - 1000** |
   
 表7CheckedKey 
| 参数                 | 参数类型    | 描述                                                                                       |
|:---|:---|:---|
| key                | String  | 键 最小长度：**0** 最大长度：**2048** |
| is_etag_matching   | Boolean | 是否电子标签匹配                                                                                 |
| is_object_existing | Boolean | 是否存在对象                                                                                   |
   
**状态码：400**
表8响应Body参数 
| 参数         | 参数类型   | 描述    |
|:---|:---|:---|
| error_msg  | String | 错误信息。 |
| error_code | String | 错误码。  |
   
#### 请求示例
用ALIYUN_OSS_B加密方式xcsad密钥查询xxx桶的CDN信息
```
POST https://{endpoint}/v2/{project_id}/objectstorage/buckets/cdn-info
{
  "ak" : "xxx",
  "sk" : "xxx",
  "cloud_type" : "Aliyun",
  "region" : "cn-hangzhou",
  "bucket" : "xxx",
  "source_cdn" : {
    "protocol" : "https",
    "domain" : "xxx",
    "authentication_type" : "ALIYUN_OSS_B",
    "authentication_key" : "xcsad"
  }
}
```
#### 响应示例
**状态码：200**
查询CDN信息响应体
```
{
  "is_same_cloud_type" : false,
  "is_download_available" : false,
  "checked_keys" : [ {
    "key" : "xxx",
    "is_etag_matching" : false,
    "is_object_existing" : false
  }, {
    "key" : "yyy",
    "is_etag_matching" : false,
    "is_object_existing" : false
  }, {
    "key" : "ccc",
    "is_etag_matching" : false,
    "is_object_existing" : false
  }, {
    "key" : "bbb",
    "is_etag_matching" : false,
    "is_object_existing" : false
  }, {
    "key" : "nnnn",
    "is_etag_matching" : false,
    "is_object_existing" : false
  } ]
}
```
#### SDK代码示例
SDK代码示例如下。
- [Java]
  用ALIYUN_OSS_B加密方式xcsad密钥查询xxx桶的CDN信息
  ```
  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 ShowCdnInfoSolution {
      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();
          ShowCdnInfoRequest request = new ShowCdnInfoRequest();
          ShowCdnInfoReq body = new ShowCdnInfoReq();
          SourceCdnReq sourceCdnbody = new SourceCdnReq();
          sourceCdnbody.withAuthenticationKey("xcsad")
              .withAuthenticationType(SourceCdnReq.AuthenticationTypeEnum.fromValue("ALIYUN_OSS_B"))
              .withDomain("xxx")
              .withProtocol(SourceCdnReq.ProtocolEnum.fromValue("https"));
          body.withSourceCdn(sourceCdnbody);
          body.withBucket("xxx");
          body.withRegion("cn-hangzhou");
          body.withCloudType("Aliyun");
          body.withSk("xxx");
          body.withAk("xxx");
          request.withBody(body);
          try {
              ShowCdnInfoResponse response = client.showCdnInfo(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]
  用ALIYUN_OSS_B加密方式xcsad密钥查询xxx桶的CDN信息
  ```
  # 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 = ShowCdnInfoRequest()
          sourceCdnbody = SourceCdnReq(
              authentication_key="xcsad",
              authentication_type="ALIYUN_OSS_B",
              domain="xxx",
              protocol="https"
          )
          request.body = ShowCdnInfoReq(
              source_cdn=sourceCdnbody,
              bucket="xxx",
              region="cn-hangzhou",
              cloud_type="Aliyun",
              sk="xxx",
              ak="xxx"
          )
          response = client.show_cdn_info(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]
  用ALIYUN_OSS_B加密方式xcsad密钥查询xxx桶的CDN信息
  ```
  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.ShowCdnInfoRequest{}
  authenticationKeySourceCdn:= "xcsad"
  sourceCdnbody := &model.SourceCdnReq{
  AuthenticationKey: &authenticationKeySourceCdn,
  AuthenticationType: model.GetSourceCdnReqAuthenticationTypeEnum().ALIYUN_OSS_B,
  Domain: "xxx",
  Protocol: model.GetSourceCdnReqProtocolEnum().HTTPS,
  }
  request.Body = &model.ShowCdnInfoReq{
  SourceCdn: sourceCdnbody,
  Bucket: "xxx",
  Region: "cn-hangzhou",
  CloudType: "Aliyun",
  Sk: "xxx",
  Ak: "xxx",
  }
  response, err := client.ShowCdnInfo(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=ShowCdnInfo)的代码示例页签，可生成自动对应的SDK代码示例。
#### 状态码
| 状态码 | 描述         |
|:---|:---|
| 200 | 查询CDN信息响应体 |
| 400 | 通用异常响应体    |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-oms/ErrorCode.html)。
