Help Center/ SecMaster/ API Reference/ API/ Metering and Billing/ Subscribing to Pay-per-Use SecMaster
Updated on 2025-06-24 GMT+08:00

Subscribing to Pay-per-Use SecMaster

Function

This API is used to enable SecMaster billed on a pay-per-use basis.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/subscriptions/orders

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Request Parameters

Table 2 Request header 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 environment language. The value can be zh-cn or en-us.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

region_id

Yes

String

Region ID.

domain_id

Yes

String

domainId

tag_list

No

Array of TagInfo objects

Billing tag.

product_list

No

Array of ProductPostPaid objects

Product list.

operate_type

No

String

Operation type. The options are create for creating product and addition for increasing the quota.

Table 4 TagInfo

Parameter

Mandatory

Type

Description

key

Yes

String

ID.

Only letters, digits, underscores (_), and hyphens (-) are allowed. Length: [2, 36].

value

Yes

String

Content.

Only letters, digits, underscores (_), and hyphens (-) are allowed. Length: [2, 36].

Table 5 ProductPostPaid

Parameter

Mandatory

Type

Description

id

Yes

String

ID, which is used to identify the mapping between the inquiry result and the request. The ID must be unique in an inquiry.

product_id

Yes

String

Product ID, which can be obtained from CBC.

cloud_service_type

Yes

String

Cloud service type. The fixed value is fixed at hws.service.type.sa for this service.

resource_type

Yes

String

Resource type of the cloud service product you purchase. For example, the resource type value is hws.resource.type.secmaster.typical for the typical scenario configuration of SecMaster.

resource_spec_code

Yes

String

Resource specifications of the cloud service product you purchase. For example, the resource specifications for SecMaster basic edition is secmaster.basic.

usage_measure_id

Yes

Integer

Usage measurement unit. This parameter is mandatory for a pay-per-use inquiry. For example, the resources are billed by the hour, the usage value is 1, and the usage measurement unit is hour. The options are:

4: Hours

10: Gbit/s. Bandwidth usage is measured in Gbit/s based on traffic.

11: Mbit/s. Bandwidth usage is measured in Mbit/s based on traffic.

usage_value

Yes

Number

Usage value. This parameter is mandatory for a pay-per-use inquiry. For example, the resources are billed by the hour, the usage value is 1, and the usage measurement unit is hour.

resource_size

Yes

Integer

Number of quotas.

usage_factor

Yes

String

Usage factor. This parameter is mandatory for pay-per-use billing. The value is the same as the usage factor in 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 required only when you want to increase the quota.

Response Parameters

Status code: 200

Request succeeded.

None

Example Requests

https://{endpoint}/v1/{projectId}/subscriptions/orders

{
  "domain_id" : "abcdef8a41164a2280ec65f1f4c4mlnyz",
  "region_id" : "region_id",
  "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 are using SecMaster standard edition. You can upgrade the SecMaster edition in-use or increase the quota as needed.",
  "error_code" : "SecMaster.00010201"
}

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
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("region_id");
        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());
        }
    }
}

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
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="region_id"
        )
        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)

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
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: "region_id",
	}
	response, err := client.CreatePostPaidOrder(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

Parameter error.

403

Insufficient permissions.

Error Codes

See Error Codes.