Deploying Certificates
Function
This API is used to deploy an SSL certificate to another Huawei Cloud service, such as Elastic Load Balance (ELB), Web Application Firewall (WAF), and Content Delivery Network (CDN).
Constraints
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
scm:cert:deployResources
Write
cert *
g:ResourceTag/<tag-key>
-
-
-
g:EnterpriseProjectId
URI
POST /v3/scm/certificates/{certificate_id}/deploy
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
certificate_id |
Yes |
String |
Certificate ID. Minimum: 16 Maximum: 16 |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API. The value of X-Subject-Token in the response header is the user token. Minimum: 32 Maximum: 2097152 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_name |
No |
String |
Name of the project where the resource to be deployed is located. If the resource is deployed in the main project, the value is the region ID. Minimum: 1 Maximum: 255 |
|
service_name |
Yes |
String |
Service to which the certificate is pushed. Currently, certificates can only be pushed to CDN, WAF, and ELB. Minimum: 1 Maximum: 64 |
|
resources |
Yes |
Array of DeployedResource objects |
List of resources to be deployed. Array Length: 1 - 20 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
Resource ID. This parameter is mandatory when WAF or ELB is deployed. Minimum: 0 Maximum: 63 |
|
type |
No |
String |
Resource type. Currently, this parameter is required only when WAF resources are deployed. The value can be cloud for cloud mode or premium for dedicated mode. Minimum: 0 Maximum: 63 |
|
domain_name |
No |
String |
Domain name to be deployed. Currently, this parameter is required only when CDN is deployed, that is, the domain name to be accelerated. The domain name must match the certificate. Minimum: 0 Maximum: 63 |
|
enterprise_project_id |
No |
String |
ID of the enterprise project to which the resource to be deployed belongs. This parameter is mandatory only when WAF resources are deployed. Minimum: 0 Maximum: 63 |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
failure_list |
Array of FaiureResource objects |
List of resources that fail to be deployed. Array Length: 1 - 20 |
|
Parameter |
Type |
Description |
|---|---|---|
|
resource |
String |
Information about the resource that fails to be deployed. When WAF or ELB is deployed, this field is the resource ID. When CDN is deployed, this field is the acceleration domain name. Minimum: 0 Maximum: 63 |
|
failure_info |
String |
Failure cause, which is generally the error code returned by the target service. Minimum: 0 Maximum: 255 |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code returned for an error request. Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error information returned for an error request. Minimum: 0 Maximum: 1024 |
Example Requests
{
"service_name" : "ELB",
"project_name" : "cn-north-7",
"resources" : [ {
"id" : "982b8a6a6ebc43809d82a46ca99aaeb7"
} ]
}
Example Responses
Status code: 200
Normal response.
{
"failure_list" : [ {
"resource" : "982b8a6a6ebc43809d82a46ca99aaeb7",
"failure_info" : "ELB.8904:certificate 982b8a6a6ebc43809d82a46ca99aaeb7 does not exist"
} ]
}
Status code: 401
Authentication failed.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
Status code: 403
Access denied.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
Status code: 500
Failed to complete the request because of an internal server error.
{
"error_code" : "SCM.XXX",
"error_msg" : "XXX"
}
SDK Sample Code
The SDK sample code is as follows.
Java
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.GlobalCredentials; 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.scm.v3.region.ScmRegion; import com.huaweicloud.sdk.scm.v3.*; import com.huaweicloud.sdk.scm.v3.model.*; import java.util.List; import java.util.ArrayList; public class DeployCertificateSolution { 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 GlobalCredentials() .withAk(ak) .withSk(sk); ScmClient client = ScmClient.newBuilder() .withCredential(auth) .withRegion(ScmRegion.valueOf("<YOUR REGION>")) .build(); DeployCertificateRequest request = new DeployCertificateRequest(); request.withCertificateId("{certificate_id}"); DeployCertificateRequestBody body = new DeployCertificateRequestBody(); List<DeployedResource> listbodyResources = new ArrayList<>(); listbodyResources.add( new DeployedResource() .withId("982b8a6a6ebc43809d82a46ca99aaeb7") ); body.withResources(listbodyResources); body.withServiceName("ELB"); body.withProjectName("cn-north-7"); request.withBody(body); try { DeployCertificateResponse response = client.deployCertificate(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
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import GlobalCredentials from huaweicloudsdkscm.v3.region.scm_region import ScmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkscm.v3 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 = GlobalCredentials(ak, sk) client = ScmClient.new_builder() \ .with_credentials(credentials) \ .with_region(ScmRegion.value_of("<YOUR REGION>")) \ .build() try: request = DeployCertificateRequest() request.certificate_id = "{certificate_id}" listResourcesbody = [ DeployedResource( id="982b8a6a6ebc43809d82a46ca99aaeb7" ) ] request.body = DeployCertificateRequestBody( resources=listResourcesbody, service_name="ELB", project_name="cn-north-7" ) response = client.deploy_certificate(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
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" scm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/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 := global.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := scm.NewScmClient( scm.ScmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.DeployCertificateRequest{} request.CertificateId = "{certificate_id}" idResources:= "982b8a6a6ebc43809d82a46ca99aaeb7" var listResourcesbody = []model.DeployedResource{ { Id: &idResources, }, } projectNameDeployCertificateRequestBody:= "cn-north-7" request.Body = &model.DeployCertificateRequestBody{ Resources: listResourcesbody, ServiceName: "ELB", ProjectName: &projectNameDeployCertificateRequestBody, } response, err := client.DeployCertificate(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Normal response. |
|
401 |
Authentication failed. |
|
403 |
Access denied. |
|
404 |
Access page not found. |
|
500 |
Failed to complete the request because of an internal server error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot