更新时间:2024-09-10 GMT+08:00
分享

查桶对应的CDN信息

功能介绍

查桶对应的CDN信息

调用方法

请参见如何调用API

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

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

当源端为腾讯云时,会返回此参数。

最小长度:0

最大长度:255

bucket

String

桶名

最小长度:0

最大长度:100

prefix

PrefixKeyInfo object

前缀

source_cdn

SourceCdnReq object

指定是否启用CDN迁移支持,若包含此字段则为支持,否则为不支持,启用CDN迁移支持后,迁移时将从CDN域名获取源端对象。

表4 PrefixKeyInfo

参数

是否必选

参数类型

描述

keys

Array of strings

最小长度:0

最大长度:2048

数组长度:0 - 100

表5 SourceCdnReq

参数

是否必选

参数类型

描述

authentication_key

String

CDN鉴权秘钥,如果CDN需要进行鉴权,则此选项为必选。

无需授权:无需配置此项。 Qiniu:无需配置此项。 Aliyun:根据authentication_type指定的鉴权方式配置此项。 KingsoftCloud:无需配置此项。

最小长度:0

最大长度:255

authentication_type

String

鉴权类型: 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

缺省值: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

响应参数

状态码: 200

表6 响应Body参数

参数

参数类型

描述

is_same_cloud_type

Boolean

是否相同云类型

is_download_available

Boolean

是否下载可用

checked_keys

Array of CheckedKey objects

返回的已检查的对象数组

数组长度:0 - 1000

表7 CheckedKey

参数

参数类型

描述

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代码示例如下。

用ALIYUN_OSS_B加密方式xcsad秘钥查询xxx桶的CDN信息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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");

        ICredential auth = new BasicCredentials()
                .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());
        }
    }
}

用ALIYUN_OSS_B加密方式xcsad秘钥查询xxx桶的CDN信息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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"]

    credentials = BasicCredentials(ak, sk)

    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)

用ALIYUN_OSS_B加密方式xcsad秘钥查询xxx桶的CDN信息

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := oms.NewOmsClient(
        oms.OmsClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    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的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

查询CDN信息响应体

400

通用异常响应体

错误码

请参见错误码

相关文档