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 adding the first HTTP or HTTPS listener to a load balancer,
specify loadbalancer_id, leave l7_flavor_id blank, and do not specify ip_target_enable set its value to false.
-
To calculate the number of IP addresses required for changing the flavors of a dedicated load balancer or enabling IP as a Backend for a load balancer, specify loadbalancer_id and l7_flavor_id, and set ip_target_enable to true.
-
To calculate the number of IP addresses required for creating a load balancer, specify availability_zone_id and optional parameters parameters l7_flavor_id, ip_target_enable, and ip_version. Do not pass loadbalancer_id.
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 is the number of IP addresses used by a load balancer.
Calling Method
For details, see Calling APIs.
URI
GET /v3/{project_id}/elb/preoccupy-ip-num
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
l7_flavor_id |
No |
String |
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. Application scenarios: creating a dedicated load balancer with a Layer-7 flavor or changing the Layer 7 flavors of a dedicated load balancer |
ip_target_enable |
No |
Boolean |
Specifies whether to enable IP as a Backend.
Application scenarios: creating a dedicated load balancer or changing the flavors of a dedicated load balancer |
ip_version |
No |
Integer |
Specifies the IP address version of the load balancer. The value can be 4 or 6.
Application scenario: creating a dedicated load balancer. |
loadbalancer_id |
No |
String |
Specifies the load balancer ID. The number of reserved IP addresses required for changing the flavors of a dedicated load balancer or for adding the first HTTP or HTTPS listener to a dedicated load balancer will be calculated. Application scenario: changing the flavors of a dedicated load balancer or adding the first HTTP or HTTPS listener to a dedicated load balancer |
availability_zone_id |
No |
Array of strings |
Calculates the number of reserved IP addresses required for creating a dedicated load balancer in the AZs specified by availability_zone_id. Application scenario: creating a dedicated load balancer Constraint: This parameter will not take effect when loadbalancer_id is passed. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the token used for IAM authentication. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
preoccupy_ip |
PreoccupyIp object |
Shows reserved IP address information. |
request_id |
String |
Specifies the request ID. Note: The value is automatically generated. |
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" }
SDK Sample Code
The SDK sample code is as follows.
-
Querying the number of reserved IP addresses required for changing the Layer 7 flavor of a dedicated load balancer
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
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.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class CountPreoccupyIpNumSolution { 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); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); CountPreoccupyIpNumRequest request = new CountPreoccupyIpNumRequest(); try { CountPreoccupyIpNumResponse response = client.countPreoccupyIpNum(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()); } } }
-
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
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
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.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class CountPreoccupyIpNumSolution { 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); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); CountPreoccupyIpNumRequest request = new CountPreoccupyIpNumRequest(); try { CountPreoccupyIpNumResponse response = client.countPreoccupyIpNum(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()); } } }
-
Querying the number of reserved IP addresses required for adding the first HTTP or HTTPS listener to a dedicated load balancer
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
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.elb.v3.region.ElbRegion; import com.huaweicloud.sdk.elb.v3.*; import com.huaweicloud.sdk.elb.v3.model.*; public class CountPreoccupyIpNumSolution { 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); ElbClient client = ElbClient.newBuilder() .withCredential(auth) .withRegion(ElbRegion.valueOf("<YOUR REGION>")) .build(); CountPreoccupyIpNumRequest request = new CountPreoccupyIpNumRequest(); try { CountPreoccupyIpNumResponse response = client.countPreoccupyIpNum(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()); } } }
-
Querying the number of reserved IP addresses required for changing the Layer 7 flavor of a dedicated load balancer
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 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 = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = CountPreoccupyIpNumRequest() response = client.count_preoccupy_ip_num(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
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
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 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 = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = CountPreoccupyIpNumRequest() response = client.count_preoccupy_ip_num(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Querying the number of reserved IP addresses required for adding the first HTTP or HTTPS listener to a dedicated load balancer
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
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkelb.v3.region.elb_region import ElbRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkelb.v3 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 = ElbClient.new_builder() \ .with_credentials(credentials) \ .with_region(ElbRegion.value_of("<YOUR REGION>")) \ .build() try: request = CountPreoccupyIpNumRequest() response = client.count_preoccupy_ip_num(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Querying the number of reserved IP addresses required for changing the Layer 7 flavor of a dedicated load balancer
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/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 := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CountPreoccupyIpNumRequest{} response, err := client.CountPreoccupyIpNum(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
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
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/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 := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CountPreoccupyIpNumRequest{} response, err := client.CountPreoccupyIpNum(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Querying the number of reserved IP addresses required for adding the first HTTP or HTTPS listener to a dedicated load balancer
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" elb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/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 := elb.NewElbClient( elb.ElbClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CountPreoccupyIpNumRequest{} response, err := client.CountPreoccupyIpNum(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 |
Successful request. |
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