On-Demand Subscription of SecMaster
Function
Enable the on-demand SecMaster.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/subscriptions/orders
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Tenant project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
X-Language |
Yes |
String |
Current language environment zh-cn or en-us. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
region_id |
Yes |
String |
Region ID, for example, cn-north-4. |
domain_id |
Yes |
String |
domainId |
tag_list |
No |
Array of TagInfo objects |
Charging tag. |
product_list |
No |
Array of ProductPostPaid objects |
Product list. |
operate_type |
No |
String |
Specifies the operation type. The value can be create or addition. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Identifier. The value is a string of 2 to 36 characters consisting of only letters, digits, underscores (_), and hyphens (-). |
value |
Yes |
String |
Content. The value is a string of 2 to 36 characters consisting of only letters, digits, underscores (_), and hyphens (-). |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
Yes |
String |
Specifies the identifier, which must be unique in each price query and is used for identifying the mappings between requests and responses. |
product_id |
Yes |
String |
Offering ID, which is obtained from the CBC price inquiry. |
cloud_service_type |
Yes |
String |
Cloud service type. The fixed value is hws.service.type.sa. |
resource_type |
Yes |
String |
Specifies the resource type of the purchased product. For example, the resource type for typical scenarios in SecMaster is hws.resource.type.secmaster.typical. |
resource_spec_code |
Yes |
String |
Specifies the resource specifications of the purchased product. For example, the resource specification for the basic edition in SecMaster is secmaster.basic. |
usage_measure_id |
Yes |
Integer |
Specifies the usage measurement unit. This parameter is mandatory for a pay-per-use task. For example, the resources are billed by hour, the usage value is 1, and the usage measurement unit is hour. The options are: 4: Hours 10: GB. The bandwidth usage is measured by traffic (GB). 11: MB. The bandwidth usage is measured by traffic (MB). |
usage_value |
Yes |
Number |
Specifies the usage value. This parameter is mandatory for a pay-per-use task. For example, the resources are billed by hour, the usage value is 1, and the usage measurement unit is hour. |
resource_size |
Yes |
Integer |
Specifies the number of quotas. |
usage_factor |
Yes |
String |
Specifies the usage factor. This parameter is mandatory for a pay-per-use task. The value is the same as the usage factor of SDRs. The mappings between cloud services and usage factors are as follows: Typical configuration: Duration Situation management: duration Security orchestration: count Intelligent analysis: flow |
resource_id |
No |
String |
Resource ID, which is transferred only when the quota is added. |
Response Parameters
None
Example Requests
https://{endpoint}/v1/{projectId}/subscriptions/orders { "domain_id" : "abcdef8a41164a2280ec65f1f4c4mlnyz", "region_id" : "cn-north-4", "product_list" : [ { "product_id" : "OFFI908269345109094402", "cloud_service_type" : "hws.service.type.sa", "id" : "E52E1A22-9408-459A-9F67-7B5C11B1E71A", "resource_spec_code" : "secmaster.professional", "resource_type" : "hws.resource.type.secmaster.typical", "usage_factor" : "duration", "usage_value" : 1, "usage_measure_id" : 4, "resource_size" : 1 } ] }
Example Responses
Status code: 400
Parameter error.
{ "error_msg" : "You already have [standard edition] package. To use more, upgrade the SecMaster edition you are using or increase the quota.", "error_code" : "SecMaster.00010201" }
SDK Sample Code
The SDK sample code is as follows.
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 67 |
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.secmaster.v2.region.SecMasterRegion; import com.huaweicloud.sdk.secmaster.v2.*; import com.huaweicloud.sdk.secmaster.v2.model.*; import java.util.List; import java.util.ArrayList; public class CreatePostPaidOrderSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); SecMasterClient client = SecMasterClient.newBuilder() .withCredential(auth) .withRegion(SecMasterRegion.valueOf("<YOUR REGION>")) .build(); CreatePostPaidOrderRequest request = new CreatePostPaidOrderRequest(); PostPaidParam body = new PostPaidParam(); List<ProductPostPaid> listbodyProductList = new ArrayList<>(); listbodyProductList.add( new ProductPostPaid() .withId("E52E1A22-9408-459A-9F67-7B5C11B1E71A") .withProductId("OFFI908269345109094402") .withCloudServiceType("hws.service.type.sa") .withResourceType("hws.resource.type.secmaster.typical") .withResourceSpecCode("secmaster.professional") .withUsageMeasureId(ProductPostPaid.UsageMeasureIdEnum.NUMBER_4) .withUsageValue(java.math.BigDecimal.valueOf(1)) .withResourceSize(1) .withUsageFactor("duration") ); body.withProductList(listbodyProductList); body.withDomainId("abcdef8a41164a2280ec65f1f4c4mlnyz"); body.withRegionId("cn-north-4"); request.withBody(body); try { CreatePostPaidOrderResponse response = client.createPostPaidOrder(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()); } } } |
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 BasicCredentials from huaweicloudsdksecmaster.v2.region.secmaster_region import SecMasterRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksecmaster.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"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = SecMasterClient.new_builder() \ .with_credentials(credentials) \ .with_region(SecMasterRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreatePostPaidOrderRequest() listProductListbody = [ ProductPostPaid( id="E52E1A22-9408-459A-9F67-7B5C11B1E71A", product_id="OFFI908269345109094402", cloud_service_type="hws.service.type.sa", resource_type="hws.resource.type.secmaster.typical", resource_spec_code="secmaster.professional", usage_measure_id=4, usage_value=1, resource_size=1, usage_factor="duration" ) ] request.body = PostPaidParam( product_list=listProductListbody, domain_id="abcdef8a41164a2280ec65f1f4c4mlnyz", region_id="cn-north-4" ) response = client.create_post_paid_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) |
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 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" secmaster "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/secmaster/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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := secmaster.NewSecMasterClient( secmaster.SecMasterClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreatePostPaidOrderRequest{} var listProductListbody = []model.ProductPostPaid{ { Id: "E52E1A22-9408-459A-9F67-7B5C11B1E71A", ProductId: "OFFI908269345109094402", CloudServiceType: "hws.service.type.sa", ResourceType: "hws.resource.type.secmaster.typical", ResourceSpecCode: "secmaster.professional", UsageMeasureId: model.GetProductPostPaidUsageMeasureIdEnum().E_4, UsageValue: float32(1), ResourceSize: int32(1), UsageFactor: "duration", }, } request.Body = &model.PostPaidParam{ ProductList: &listProductListbody, DomainId: "abcdef8a41164a2280ec65f1f4c4mlnyz", RegionId: "cn-north-4", } response, err := client.CreatePostPaidOrder(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
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 successful. |
400 |
Parameter error. |
403 |
Insufficient permissions. |
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