Purchasing a CA
Function
Purchase a CA.
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.
URI
POST /v1/private-certificate-authorities/order
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
User token. For details, see [Obtaining a User Token] (https://support.huaweicloud.com/en-us/api-iam/iam_30_0001.html). |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
cloud_service_type |
Yes |
String |
Cloud service type. The fixed value is hws.service.type.ccm. Minimum: 1 Maximum: 64 |
|
charging_mode |
Yes |
Integer |
Billing mode: - 0: yearly/monthly |
|
period_type |
Yes |
Integer |
Subscription period type. The options are as follows: 2: month; 3: year. |
|
period_num |
Yes |
Integer |
Number of subscription periods. |
|
is_auto_renew |
Yes |
Integer |
Whether to enable auto-renewal. 1: yes; 0: no |
|
promotion_info |
No |
String |
Discount information. Minimum: 0 Maximum: 2048 |
|
subscription_num |
Yes |
Integer |
Subscription quantity |
|
is_auto_pay |
No |
Integer |
Whether to perform automatic payment. 1: yes; 0: no. The default value is 0. |
|
enterprise_project_id |
No |
String |
Enterprise project ID. Minimum: 1 Maximum: 64 |
|
product_infos |
Yes |
Array of ProductInfo objects |
Product list. For details, see parameter description of the ProductInfo field. Array Length: 0 - 10 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
cloud_service_type |
Yes |
String |
Cloud service type. The fixed value is hws.service.type.ccm. Minimum: 1 Maximum: 64 |
|
resource_type |
Yes |
String |
Resource type. The value of CA is hws.resource.type.pca.duration. Minimum: 1 Maximum: 64 |
|
resource_spec_code |
Yes |
String |
Resource specification code. The value of CA is ca.duration. Minimum: 1 Maximum: 64 |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
order_id |
String |
Order ID. Minimum: 1 Maximum: 64 |
|
ca_ids |
Array of strings |
ID list of the purchased CA certificates. Minimum: 1 Maximum: 64 |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 404
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code Minimum: 3 Maximum: 36 |
|
error_msg |
String |
Error message Minimum: 0 Maximum: 1024 |
Example Requests
When you use this API to create a CA, a token is required in the X-Auth-Token field in the request header, and the token must have the permission to access the API.
POST https://ccm.cn-north-4.myhuaweicloud.com/v1/private-certificate-authorities/order
{
"cloud_service_type" : "hws.service.type.ccm",
"period_type" : 2,
"period_num" : 1,
"charging_mode" : 0,
"is_auto_renew" : 0,
"is_auto_pay" : 0,
"promotion_info" : "",
"enterprise_project_id" : "0",
"product_infos" : [ {
"cloud_service_type" : "hws.service.type.ccm",
"resource_type" : "hws.resource.type.pca.duration",
"resource_spec_code" : "ca.duration"
} ],
"subscription_num" : 1
}
Example Responses
Status code: 200
Request succeeded.
{
"order_id" : "CS1803192259ROA8U",
"ca_ids" : [ "4284547e-68ef-4a94-adea-9df1e5d8ad65", "211c079c-bab8-41af-8948-c5e2531232c6" ]
}
Status code: 400
Invalid request parameter.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 401
Token required for the requested page.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 403
Authentication failed.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 404
No resources available or found.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
Status code: 500
Internal server error.
{
"error_code" : "PCA.XXX",
"error_msg" : "XXX"
}
SDK Sample Code
The SDK sample code is as follows.
Java
When you use this API to create a CA, a token is required in the X-Auth-Token field in the request header, and the token must have the permission to access the API.
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 59 60 61 62 63 64 65 66 |
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.ccm.v1.region.CcmRegion; import com.huaweicloud.sdk.ccm.v1.*; import com.huaweicloud.sdk.ccm.v1.model.*; import java.util.List; import java.util.ArrayList; public class CreateCertificateAuthorityOrderSolution { 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); CcmClient client = CcmClient.newBuilder() .withCredential(auth) .withRegion(CcmRegion.valueOf("<YOUR REGION>")) .build(); CreateCertificateAuthorityOrderRequest request = new CreateCertificateAuthorityOrderRequest(); CreateCertificateAuthorityOrderRequestBody body = new CreateCertificateAuthorityOrderRequestBody(); List<ProductInfo> listbodyProductInfos = new ArrayList<>(); listbodyProductInfos.add( new ProductInfo() .withCloudServiceType("hws.service.type.ccm") .withResourceType("hws.resource.type.pca.duration") .withResourceSpecCode("ca.duration") ); body.withProductInfos(listbodyProductInfos); body.withEnterpriseProjectId("0"); body.withIsAutoPay(0); body.withSubscriptionNum(1); body.withPromotionInfo(""); body.withIsAutoRenew(0); body.withPeriodNum(1); body.withPeriodType(2); body.withChargingMode(0); body.withCloudServiceType("hws.service.type.ccm"); request.withBody(body); try { CreateCertificateAuthorityOrderResponse response = client.createCertificateAuthorityOrder(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
When you use this API to create a CA, a token is required in the X-Auth-Token field in the request header, and the token must have the permission to access the API.
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 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import GlobalCredentials from huaweicloudsdkccm.v1.region.ccm_region import CcmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkccm.v1 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 = CcmClient.new_builder() \ .with_credentials(credentials) \ .with_region(CcmRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateCertificateAuthorityOrderRequest() listProductInfosbody = [ ProductInfo( cloud_service_type="hws.service.type.ccm", resource_type="hws.resource.type.pca.duration", resource_spec_code="ca.duration" ) ] request.body = CreateCertificateAuthorityOrderRequestBody( product_infos=listProductInfosbody, enterprise_project_id="0", is_auto_pay=0, subscription_num=1, promotion_info="", is_auto_renew=0, period_num=1, period_type=2, charging_mode=0, cloud_service_type="hws.service.type.ccm" ) response = client.create_certificate_authority_order(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
When you use this API to create a CA, a token is required in the X-Auth-Token field in the request header, and the token must have the permission to access the API.
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" ccm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/ccm/v1/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 := ccm.NewCcmClient( ccm.CcmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateCertificateAuthorityOrderRequest{} var listProductInfosbody = []model.ProductInfo{ { CloudServiceType: "hws.service.type.ccm", ResourceType: "hws.resource.type.pca.duration", ResourceSpecCode: "ca.duration", }, } enterpriseProjectIdCreateCertificateAuthorityOrderRequestBody:= "0" isAutoPayCreateCertificateAuthorityOrderRequestBody:= int32(0) promotionInfoCreateCertificateAuthorityOrderRequestBody:= "" request.Body = &model.CreateCertificateAuthorityOrderRequestBody{ ProductInfos: listProductInfosbody, EnterpriseProjectId: &enterpriseProjectIdCreateCertificateAuthorityOrderRequestBody, IsAutoPay: &isAutoPayCreateCertificateAuthorityOrderRequestBody, SubscriptionNum: int32(1), PromotionInfo: &promotionInfoCreateCertificateAuthorityOrderRequestBody, IsAutoRenew: int32(0), PeriodNum: int32(1), PeriodType: int32(2), ChargingMode: int32(0), CloudServiceType: "hws.service.type.ccm", } response, err := client.CreateCertificateAuthorityOrder(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 |
Request succeeded. |
|
400 |
Invalid request parameter. |
|
401 |
Token required for the requested page. |
|
403 |
Authentication failed. |
|
404 |
No resources available or found. |
|
500 |
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