Help Center/ Elastic Load Balance/ API Reference/ APIs (V3)/ Reserved IP Address/ Calculating the Number of Reserved IP Addresses
Updated on 2025-08-29 GMT+08:00

Calculating the Number of Reserved IP Addresses

Function

This API is used to calculate the number of reserved IP addresses in the following scenarios:

  • To calculate the number of IP addresses required for creating a load balancer, specify availability_zone_id and optional parameters l7_flavor_id, ip_target_enable, and ip_version. Do not specify loadbalancer_id.

  • To calculate the number of IP addresses required for adding the first Layer 7 listener to a load balancer, specify loadbalancer_id and do not specify other parameters.

  • To calculate the number of IP addresses required for changing the flavors of a dedicated load balancer or enabling IP as a Backend, specify loadbalancer_id and l7_flavor_id, or specify loadbalancer_id and set ip_target_enable to true. You can specify l7_flavor_id and set ip_target_enable to true to calculate the number of IP addresses required for multiple changes.

  • To calculate the number of IP addresses required for upgrading a shared load balancer, specify loadbalancer_id and scene, and do not specify other parameters.

  • To calculate the number of IP addresses required for enabling nat64_enable, specify nat64_enable and loadbalancer_id, and do not specify other parameters.

Note:

  • The number of reserved IP addresses in the query result is greater than that of the actually used IP addresses.

  • The number of reserved IP addresses does not include those already assigned or in use.

Calling Method

For details, see Calling APIs.

URI

GET /v3/{project_id}/elb/preoccupy-ip-num

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition: Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Constraints: N/A

Range: The value can contain a maximum of 32 characters, including digits and lowercase letters.

Default value: N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

l7_flavor_id

No

String

Definition: Specifies the ID of the load balancer flavor at Layer 7. If this parameter is passed, the number of reserved IP addresses required for creating a dedicated load balancer with a Layer 7 flavor or for changing the Layer 7 flavor of a dedicated load balancer will be calculated.

Constraints: This parameter can only be used for creating a dedicated load balancer with a Layer 7 flavor or changing the Layer 7 flavor of a dedicated load balancer

Range: N/A

Default value: N/A

ip_target_enable

No

Boolean

Definition: Whether to whether to enable IP as a Backend.

Constraints: This parameter can only be used for creating a dedicated load balancer with IP as a Backend enabled or for enabling IP as a Backend for an existing dedicated load balancer.

Range:

  • true: The number of reserved IP addresses required for creating a dedicated load balancer with IP as a Backend enabled or for enabling IP as a Backend for an existing dedicated load balancer will be calculated.

  • false: The number of reserved IP addresses required for creating a dedicated load balancer with IP as a Backend disabled will be calculated.

  • If this parameter is not passed, IP as a Backend is disabled.

Default value: false

ip_version

No

Integer

Definition: Specifies the IP address version of the load balancer. The value can be 4 or 6.

Constraints: This parameter can be used for creating a load balancer.

Range:

  • 4: The number of reserved IPv4 addresses required for creating a load balancer will be calculated.

  • 6: The number of reserved IPv6 addresses required for creating a load balancer will be calculated.

Default value: N/A

loadbalancer_id

No

String

Definition: Specifies the load balancer ID. The number of reserved IP addresses required for changing the flavors of a load balancer or for adding the first Layer 7 listener to a load balancer will be calculated.

Constraints: This parameter can be used for changing the flavors of a load balancer, enabling IP as a Backend for an existing load balancer, enabling or disabling nat64_enable, or adding the first Layer 7 listener to a load balancer.

Range: N/A

Default value: N/A

availability_zone_id

No

Array of strings

Definition: Calculates the number of reserved IP addresses required for creating a load balancer in the AZs specified by availability_zone_id.

Constraints:

  • This parameter can only be used for creating a load balancer.

  • This parameter is invalid if loadbalancer_id is specified.

Range: N/A

Default value: N/A

scene

No

String

Definition: Calculates the number of IP addresses required for upgrading a shared load balancer to a dedicated load balancer.

Constraints:

  • This parameter can only be used for upgrading a shared load balancer to a dedicated load balancer.

  • Both this parameter and loadbalancer_id must be specified.

Range: UPGRADE (upgrading a shared load balancer to a dedicated load balancer)

Default value: N/A

nat64_enable

No

Boolean

Definition: Specifies whether to enable nat64_enable. If this parameter is specified, the system will calculate the number of reserved IP addresses required for creating a load balancer whose listeners have nat64_enable enabled or disabled, or for enabling or disabling nat64_enable for the listeners of a specific load balancer.

Constraints:

  • This parameter can only be used for calculating the number of reserved IP addresses required for enabling nat64_enable for the listeners of a load balancer.

Range:

  • true: Enable nat64_enable.

  • false: Disable nat64_enable.

Default value: false

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition: Specifies the token used for IAM authentication.

Constraints: N/A

Range: N/A

Default value: N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

preoccupy_ip

PreoccupyIp object

Definition: Specifies reserved IP address.

Range: N/A

request_id

String

Definition: Specifies the request ID.

Range: The value is automatically generated, and can contain characters including digits, lowercase letters, and hyphens (-).

Table 5 PreoccupyIp

Parameter

Type

Description

total

Integer

Definition: Specifies the number of preoccupied IP addresses.

Range: an integer no less than 0

Example Requests

  • Querying the number of reserved IP addresses required for changing the Layer 7 flavor of a dedicated load balancer

    https://{ELB_Endpoint}/v3/060576782980d5762f9ec014dd2f1148/elb/preoccupy-ip-num?loadbalancer_id=aff4fc31-d635-4f59-a862-edadf32e407d&l7_flavor_id=0051bc4c-a562-4b7c-953b-a250b51d992b
    
    {
      "preoccupy_ip" : {
        "total" : 6
      },
      "request_id" : "8844e9a0-6a2d-44b7-aad9-15a7f75e4059"
    }
  • Querying the number of reserved IP addresses required for creating a dedicated load balancer that is deployed in two AZs and has IP as a Backend enabled

    GET /v3/{project_id}/elb/preoccupy-ip-num?l7_flavor_id=8278944d-f92c-4393-82b2-6fb9cc1d7e53&availability_zone_id=az1&availability_zone_id=az2&ip_target_enable=true
    
    {
      "preoccupy_ip" : {
        "total" : 20
      },
      "request_id" : "63388ec8-fa3c-4c99-b9c8-d2c83b2a9a68"
    }
  • Querying the number of reserved IP addresses required for adding the first HTTP or HTTPS listener to a dedicated load balancer

    GET /v3/{project_id}/elb/preoccupy-ip-num?loadbalancer_id=aff4fc31-d635-4f59-a862-edadf32e407d
    
    {
      "preoccupy_ip" : {
        "total" : 2
      },
      "request_id" : "febfce48-318d-45ba-a9d9-855462123f3b"
    }

Example Responses

Status code: 200

Successful request.

{
  "preoccupy_ip" : {
    "total" : 20
  },
  "request_id" : "63388ec8-fa3c-4c99-b9c8-d2c83b2a9a68"
}

Status Codes

Status Code

Description

200

Successful request.

Error Codes

See Error Codes.