54 KiB

original_name

CreateFirewall.html

Creating a Firewall

Function

This API is used to create a firewall.

URI

POST /v2/{project_id}/firewall

Table 1 Path Parameters
Parameter Mandatory Type Description
project_id Yes String Project ID, which can be obtained by calling an API or from the console. For details, see Obtaining a Project ID <cfw_02_0015>.

Request Parameters

Table 2 Request header parameters
Parameter Mandatory Type Description
X-Auth-Token Yes String User token. You can obtain the token by referring to Obtaining a User Token <cfw_02_0029>.
X-Client-Token No String

Identifier that ensures idempotency of client requests.

It is a 32-bit UUID and is generated by the client. The value must be unique.

Table 3 Request body parameters
Parameter Mandatory Type Description
name Yes String Firewall name.
enterprise_project_id No String Enterprise project ID, which is the ID of a project planned based on organizations. You can obtain the enterprise project ID by referring to Obtaining an Enterprise Project ID <cfw_02_0027>. If the enterprise project function is not enabled, the value is 0.
tags No Array of tags <createfirewall__request_tags> objects List of service resource tags. After tags are added to firewall resources, you can query resources and combine CDRs by key and value.
flavor Yes flavor <createfirewall__request_flavor> object Firewall specifications.
charge_info Yes charge_info <createfirewall__request_charge_info> object Billing type, which can be yearly/monthly or pay-per-use (default setting).
Table 4 tags
Parameter Mandatory Type Description
key No String Resource tag key.
value No String Resource tag value.
Table 5 flavor
Parameter Mandatory Type Description
version Yes String Firewall edition. Only the professional edition is supported.
extend_eip_count No Integer Number of EIPs to be added. This parameter takes effect only in the yearly/monthly billing mode. Set this parameter when you need to increase protected EIPs.
extend_bandwidth No Integer Added bandwidth. The increment step is 5. This parameter takes effect only in yearly/monthly billing mode. Set this parameter when you need to increase protected bandwidth.
extend_vpc_count No Integer Number of VPCs to be added. This parameter takes effect only in the yearly/monthly billing mode. Set this parameter when you need to increase protected VPCs.
Table 6 charge_info
Parameter Mandatory Type Description
charge_mode Yes String Billing mode. The value can only be postPaid, indicating pay-per-use billing.
period_type No String

Subscription period.

Enumeration values:

  • month

  • year

    Note: This parameter is valid and mandatory when charge_mode is set to prePaid.

period_num No Integer

Subscription time. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Enumeration values:

  • If period_type is set to month, the parameter value ranges from integer 1 to 9.
  • If period_type is set to year, the parameter value ranges from integer 1 to 3.
is_auto_renew Yes Boolean

Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal.

Enumeration values:

  • true (Automatic renewal enabled.)
  • false (Default. Automatic renewal disabled.)
is_auto_pay Yes Boolean

Whether an order will be automatically paid after yearly/monthly CFW instances are created. This parameter does not affect the payment mode of automatic renewal.

Enumeration values:

  • true: The order will be automatically paid. (Discounts and coupons are automatically selected. The fee will be automatically deducted from your Cloud account.) If the automatic payment fails, an unpaid order will be generated, and you need to manually complete the payment. (During manual payment, you can still modify the discounts and coupons that were automatically selected.)
  • false: The order will be manually paid. This is the default value. (You need to manually pay for the bill. Discounts and coupons can be used.)

Response Parameters

Status code: 200

Table 7 Response body parameters
Parameter Type Description
job_id String Instance creation task ID. This parameter is returned only when pay-per-use instances are created.
order_id String Order ID. This parameter is returned only when yearly/monthly instances are created.
data CreateFirewallReq <createfirewall__response_createfirewallreq> object Request body for creating a firewall.
Table 8 CreateFirewallReq
Parameter Type Description
name String Firewall name.
enterprise_project_id String Enterprise project ID, which is the ID of a project planned based on organizations. You can obtain the enterprise project ID by referring to Obtaining an Enterprise Project ID <cfw_02_0027>. If the enterprise project function is not enabled, the value is 0.
tags Array of tags <createfirewall__response_tags> objects List of service resource tags. After tags are added to firewall resources, you can query resources and combine CDRs by key and value.
flavor flavor <createfirewall__response_flavor> object Firewall specifications.
charge_info charge_info <createfirewall__response_charge_info> object Billing type, which can be yearly/monthly or pay-per-use (default setting).
Table 9 tags
Parameter Type Description
key String Resource tag key.
value String Resource tag value.
Table 10 flavor
Parameter Type Description
version String Firewall edition. Only the professional edition is supported.
extend_eip_count Integer Number of EIPs to be added. This parameter takes effect only in the yearly/monthly billing mode. Set this parameter when you need to increase protected EIPs.
extend_bandwidth Integer Added bandwidth. The increment step is 5. This parameter takes effect only in yearly/monthly billing mode. Set this parameter when you need to increase protected bandwidth.
extend_vpc_count Integer Number of VPCs to be added. This parameter takes effect only in the yearly/monthly billing mode. Set this parameter when you need to increase protected VPCs.
Table 11 charge_info
Parameter Type Description
charge_mode String Billing mode. The value can only be postPaid, indicating pay-per-use billing.
period_type String

Subscription period.

Enumeration values:

  • month

  • year

    Note: This parameter is valid and mandatory when charge_mode is set to prePaid.

period_num Integer

Subscription time. This parameter is valid and mandatory only when charge_mode is set to prePaid.

Enumeration values:

  • If period_type is set to month, the parameter value ranges from integer 1 to 9.
  • If period_type is set to year, the parameter value ranges from integer 1 to 3.
is_auto_renew Boolean

Whether automatic renewal is enabled for yearly/monthly instances. The renewal period is the same as the original period and the order will be automatically paid during the subscription renewal.

Enumeration values:

  • true (Automatic renewal enabled.)
  • false (Default. Automatic renewal disabled.)
is_auto_pay Boolean

Whether an order will be automatically paid after yearly/monthly CFW instances are created. This parameter does not affect the payment mode of automatic renewal.

Enumeration values:

  • true: The order will be automatically paid. (Discounts and coupons are automatically selected. The fee will be automatically deducted from your Cloud account.) If the automatic payment fails, an unpaid order will be generated, and you need to manually complete the payment. (During manual payment, you can still modify the discounts and coupons that were automatically selected.)
  • false: The order will be manually paid. This is the default value. (You need to manually pay for the bill. Discounts and coupons can be used.)

Status code: 400

Table 12 Response body parameters
Parameter Type Description
error_code String Error code.
error_msg String Error description.

Example Requests

The customer whose project ID is 124147da-5b08-471a-93d2-bc82acc290c6 subscribes to the standard firewall. The firewall name is CFW-Test, the enterprise project ID is 0, the resource tag is a key-value pair, the key is TagKey, the value is TagValue, the added number of protected EIPs is 2000, the added protection bandwidth is 5000 Mbit/s, and the added number of protected VCPs is 100. The yearly/monthly billing mode is used. Auto-renewal and auto-payment are enabled. The usage duration is one month.

https://{Endpoint}/v2/124147da-5b08-471a-93d2-bc82acc290c6/firewall

{
  "name" : "CFW-TEST",
  "enterprise_project_id" : "0",
  "tags" : [ {
    "key" : "TagKey",
    "value" : "TagVal"
  } ],
  "flavor" : {
    "version" : "standard",
    "extend_eip_count" : 2000,
    "extend_bandwidth" : 5000,
    "extend_vpc_count" : 100
  },
  "charge_info" : {
    "charge_mode" : "prePaid",
    "period_type" : "month",
    "period_num" : 1,
    "is_auto_renew" : true,
    "is_auto_pay" : true
  }
}

Example Responses

Status code: 200

Information returned when the firewall is purchased successfully.

{
  "data" : {
    "charge_info" : {
      "charge_mode" : "prePaid",
      "is_auto_pay" : true,
      "is_auto_renew" : true,
      "period_num" : 1,
      "period_type" : "month"
    },
    "enterprise_project_id" : "0",
    "flavor" : {
      "extend_bandwidth" : 5000,
      "extend_eip_count" : 2000,
      "extend_vpc_count" : 100,
      "version" : "Standard"
    },
    "name" : "CFW-TEST",
    "tags" : [ {
      "key" : "TagKey",
      "value" : "TagVal"
    } ]
  },
  "job_id" : "CS2403271050ZEM0L"
}

Status code: 400

Returned error information.

{
  "error_code" : "CFW.00100001",
  "error_msg" : "System busy. Try again later."
}

Status Codes

Status Code Description
200 Information returned when the firewall is purchased successfully.
400 Returned error information.

Error Codes

See Error Codes <errorcode>.