创建部署任务

更新时间:2023-03-28 17:43:31

适用产品

CDN Pro

接口描述

创建部署任务将加速项目或证书部署到演练或生产环境,或将已部署的加速项目或证书卸载。 建议先将加速项目部署到演练环境进行测试,以确保加速配置符合预期。

调用频率

单用户调用频率:300/5min

推荐使用 Open API在线调试

Open API在线调试功能提供可视化界面在线调试API、支持生成代码示例、快速检索查看API文档等能力。前往调试

请求参数

请求头

参数名称描述
Check-CertificateString
当您提交部署任务时,后台会校验加速项目所引用的证书是否已过期,以及加速域名是否与证书的授权域名匹配。如果您的部署操作是出于测试目的,您可以在调用接口时传入请求头Check-Certificate: no来跳过校验。非测试目的,不建议跳过校验。
Check-UsageString
当您卸载加速项目时,后台会校验加速项目下的域名是否处于活跃状态。如果域名在过去24小时仍有产生请求,则会拒绝卸载加速项目,避免误操作。如果您确定要卸载加速项目,可以在调用接口时传入请求头Check-Usage: no来跳过校验。

Body 参数

参数名称描述
nameString
部署任务的名称。
*targetString
取值范围: staging,production 指定部署任务的目标环境,即演练或生产环境。
actionsList
部署任务所要执行的操作,可以包括加速项目和证书的部署或卸载操作。
actionString
取值范围: deploy_property,remove_property,deploy_cert,remove_cert 指定操作类型,包括部署加速项目、卸载加速项目、部署证书以及卸载证书。
propertyIdString
指定要部署或卸载的加速项目ID。
certificateIdString
指定要部署或卸载的证书ID。
versionString
指定要部署或卸载的证书或加速项目的版本。
webhookString
部署任务完成时要调用的webhook的ID。

返回参数

响应头

参数名称描述
LocationString
通过Location响应头返回新建的部署任务的URL。可使用该URL调用'获取部署任务详细信息'接口来查看部署任务的详细信息。URL示例:Location: http://open.chinanetcenter.com/cdn/deploymentTasks/ac8e3085-ef92-4c12-ab1b-19b18ac9383c

错误码

错误代码(code)描述(message)HTTP状态码语义
InvalidPropertyIdAn invalid property ID was specified.400指定的加速项目ID不存在。
InvalidActionA deployment action is invalid. It must be deploy_property, remove_property, deploy_cert, or remove_cert.400所指定的部署操作不存在。必须是deploy_property, remove_property,deploy_cert或者remove_cert。
CertificateExpiredCertificate is expired. Use request header 'Check-Certificate: no' to bypass cert expiration check.400证书已过期。如果要跳过证书过期校验,请加上请求头Check-Certificate: no。
InvalidPropertyVersionThe specified version 999 or property 1c2a0ce09612e9988c345dff does not exist.400所指定的加速项目ID或版本不存在。
InvalidCertificateVersionThe specified version 100 of certificate 5c65d18197146f000148511f does not exist.400所指定的证书ID或版本不存在。
CertificateMismatchThe domain(s) mytestdomain.domain.info are not included in the Subject Alternative Name field of the deployed version of certificate c5fbb345a24615f2a7ea0791.400加速项目中的部分域名不在证书的授权域名中。
OutdatedSecretProperty a2334bc12345 versionId 1 is using an outdated secret. Please validate the property again before deploying it.400加速项目所引用的保密信息(Secret)已更新,请重新验证加速项目再部署。
CertificateNotDeployedThe required certificate 879aba3828341232 has not been deployed to the target yet.409加速项目所引用的证书未部署到目标环境。

示例

400
409
400
请求示例
复制代码 复制成功
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://open.chinanetcenter.com/cdn/deploymentTasks" \
-X "POST" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-d '{"name": "DeploymentName_1573690803000", "target": "production", "actions": [{"propertyId": "5bc3a494aceedd9073a7daa0", "version": "1", "action": "deploy_property"}]}'
返回示例
复制代码 复制成功
{
    "code": "InvalidPropertyId",
    "message": "An invalid property ID was specified."
}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!