Custom Domain

Last updated: 2020-03-20 09:56:49

PDF

Note

This document provides an overview of API for custom domain names and sample SDK code.

API Operation name pedagogical operation
PUT Bucket domain Set up a custom domain name Set Bucket's custom domain name information
GET Bucket domain Query custom domain name Query Bucket's custom domain name information
DELETE Bucket domain Delete a custom domain name Delete Bucket's custom domain name

Set up a custom domain name

Function description

PUT Bucket domain is used to configure a custom domain name for Bucket.

Method prototype

put_bucket_domain(Bucket, DomainConfiguration={}, **kwargs)

Request Sample

response = client.put_bucket_domain(
    Bucket='bucket',
    DomainConfiguration={
        'DomainRule': [
            {
                'Name': 'example.com',
                'Type': 'REST'|'WEBSITE'|'ACCELERATE',
                'Status': 'ENABLED'|'DISABLED',
                'ForcedReplacement': 'CNAME'|'TXT'
            },
        ]
    }
)

Parameter description

Parameter name Parameter description Type Required/Optional
Bucket Set the custom domain name Bucket in BucketName-APPID format. For more information, please see Naming convention String Yes
DomainRule Collection of custom domain names List Yes
Name Custom domain name String Yes
Type The type of real server bound. Available values include REST and WEBSITE. String Yes
Status Domain name Activate status. Available values include ENABLED and DISABLED String Yes
ForcedReplacement Forced overwrite of existing configurations. Available values include CNAME and TXT String No

Return result description

The return value of this method is None.

Returns the error code description

Some common special errors that may occur in this request are as follows:

Status Code Description
HTTP 409 Conflict The domain name record already exists and no mandatory overwrite is set in the request. Or the domain name record does not exist and a forced overwrite is set in the request
HTTP 451 Unavailable For Legal Reasons The domain name is a domain name within China, and there is no ICP filing.

Query custom domain name

Function description

GET Bucket domain is used to query Bucket's custom domain name information.

Method prototype

get_bucket_domain(Bucket, **kwargs)

Request Sample

response = client.get_bucket_domain(
    Bucket='examplebucket-1250000000'
)

Parameter description

Parameter name Parameter description Type Required/Optional
Bucket Query the Bucket of the custom domain name in BucketName-APPID format. For more information, please see Naming convention String Yes

Return result description

Bucket customizes the domain name configuration, and the type is dict.

{
    'x-cos-domain-txt-verification': 'string',
    'DomainRule': [
        {
            'Name': 'example.com',
            'Type': 'REST'|'WEBSITE'|'ACCELERATE',
            'Status': 'ENABLED'|'DISABLED',
            'ForcedReplacement': 'CNAME'|'TXT'
        },
    ]
}
Parameter name Parameter description Type
X-cos-domain-txt-verification Domain name verification information. This field is a MD5 check value. The original string format is: cos[Region][BucketName-APPID][BucketCreateTime] Where Region is the region where Bucket is located, and BucketCreateTime is the creation time of Bucket GMT String
DomainRule Collection of custom domain names List
Name Custom domain name String
Type The type of real server bound. Available values include REST and WEBSITE. String
Status Domain name Activate status. Available values include ENABLED and DISABLED String
ForcedReplacement Forced overwrite of existing configurations. Available values include CNAME and TXT String

Delete a custom domain name

Function description

DELETE Bucket domain is used to delete the existing custom domain name configuration under the specified Bucket.

Method prototype

delete_bucket_domain(Bucket, **kwargs)

Request Sample

response = client.delete_bucket_domain(
    Bucket='examplebucket-1250000000'
)

Parameter description

Parameter name Parameter description Type Required/Optional
Bucket Bucket of the deleted custom domain name in BucketName-APPID format. For more information, please see Naming convention String Yes

Return result description

The return value of this method is None.