Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance (CCI)
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Cloud Transformation
Well-Architected Framework
Cloud Adoption Framework
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ SecMaster/ API Reference/ API/ Metering and Billing/ Subscribing to Pay-per-Use SecMaster

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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback