このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。
Updating a Load Balancer
Function
This API is used to update a load balancer.
Calling Method
For details, see Calling APIs.
URI
PUT /v3/{project_id}/elb/loadbalancers/{loadbalancer_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
loadbalancer_id |
Yes |
String |
Specifies the load balancer ID. |
project_id |
Yes |
String |
Specifies the project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Specifies the token used for IAM authentication. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
loadbalancer |
Yes |
UpdateLoadBalancerOption object |
Specifies the load balancer. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Specifies the load balancer name. |
admin_state_up |
No |
Boolean |
Specifies whether the load balancer is enabled. Value options:
|
description |
No |
String |
Provides supplementary information about the load balancer. |
ipv6_vip_virsubnet_id |
No |
String |
Specifies the ID of the IPv6 subnet where the load balancer resides. You can query parameter neutron_network_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets). Note:
|
vip_subnet_cidr_id |
No |
String |
Specifies the ID of the IPv4 subnet where the load balancer resides. You can query parameter neutron_subnet_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets). Note:
|
vip_address |
No |
String |
Specifies the private IPv4 address bound to the load balancer. Note:
|
l4_flavor_id |
No |
String |
Specifies the ID of a flavor at Layer 4. Note:
|
l7_flavor_id |
No |
String |
Specifies the ID of a flavor at Layer 7. Note:
|
ipv6_bandwidth |
No |
BandwidthRef object |
Specifies the ID of the bandwidth used by an IPv6 address. Note: This parameter is available only when you create or update a load balancer with a public IPv6 address. If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth. |
ip_target_enable |
No |
Boolean |
Specifies whether to add backend servers that are not in the load balancer's VPC. If you enable this function, you can add servers in a peer VPC connected through a VPC peering connection, servers in other public clouds, or servers in an on-premises data center at the other end of a Direct Connect or VPN connection, by using their IP addresses. Value options:
Note:
|
elb_virsubnet_ids |
No |
Array of strings |
Specifies the IDs of subnets on the downstream plane. You can query parameter neutron_network_id in the response by calling the API (GET https://{VPC_Endpoint}/v1/{project_id}/subnets). Note:
|
deletion_protection_enable |
No |
Boolean |
Specifies whether to enable deletion protection. Value options:
Disable deletion protection for all your resources before deleting your account. |
prepaid_options |
No |
PrepaidUpdateOption object |
Updates the yearly/monthly billing information during the change of load balancer flavors. This parameter is unsupported. Please do not use it. |
autoscaling |
No |
Specifies information about elastic scaling. If elastic scaling is enabled, the load balancer specifications can be automatically adjusted based on incoming traffic. Note:
|
|
charge_mode |
No |
String |
Specifies the charge mode when updating a load balancer. Value options:
|
waf_failure_action |
No |
String |
Specifies traffic distributing policies when the WAF is faulty. Value options:
Note: This parameter takes effect only when WAF is enabled for the load balancer. |
protection_status |
No |
String |
Specifies the protection status. Value options:
|
protection_reason |
No |
String |
Specifies why the modification protection is enabled. Note: This parameter is valid only when protection_status is set to consoleProtection. The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>). |
ipv6_vip_address |
No |
String |
Specifies the IPv6 address bound to the load balancer. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
Yes |
String |
Specifies the shared bandwidth ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
auto_pay |
No |
Boolean |
Specifies whether the payment will be automatically deducted from the customer's account after an order is placed.
If you want to use coupons, submit your request. The system automatically will switch to the billing center, where you can use the coupons. |
change_mode |
No |
String |
Specifies the flavor change type. Value options:
|
period_num |
No |
Integer |
Specifies the number of subscription periods. The value varies with the operation policy, and the default value is 1. This parameter takes effect only when change_mode is set to delay.
|
period_type |
No |
String |
Specifies the subscription period type. Yearly/Monthly subscription is supported. This parameter takes effect only when change_mode is set to delay.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
enable |
Yes |
Boolean |
Specifies whether to enable elastic scaling the load balancer. Value options:
|
min_l7_flavor_id |
No |
String |
Specifies the ID of the minimum elastic flavor at Layer 7. Note:
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
loadbalancer |
LoadBalancer object |
Specifies the load balancer. |
request_id |
String |
Specifies the request ID. Note: The value is automatically generated. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the load balancer ID. |
description |
String |
Provides supplementary information about the load balancer. |
provisioning_status |
String |
Specifies the provisioning status of the load balancer. Value options:
|
admin_state_up |
Boolean |
Specifies whether the load balancer is enabled. Value options:
|
provider |
String |
Specifies the provider of the load balancer. The value can only be vlb. |
pools |
Array of PoolRef objects |
Lists the IDs of backend server groups associated with the load balancer. |
listeners |
Array of ListenerRef objects |
Lists the IDs of listeners added to the load balancer. |
operating_status |
String |
Specifies the operating status of the load balancer. Value options:
|
name |
String |
Specifies the load balancer name. |
project_id |
String |
Specifies the project ID of the load balancer. |
vip_subnet_cidr_id |
String |
Specifies the ID of the frontend IPv4 subnet where the load balancer resides. |
vip_address |
String |
Specifies the private IPv4 address bound to the load balancer. |
vip_port_id |
String |
Specifies the ID of the port bound to the private IPv4 address of the load balancer. |
tags |
Array of Tag objects |
Lists the tags added to the load balancer. |
created_at |
String |
Specifies the time when the load balancer was created, in the format of yyyy-MM-dd''T''HH:mm:ss''Z''. |
updated_at |
String |
Specifies the time when the load balancer was updated, in the format of yyyy-MM-dd''T''HH:mm:ss''Z''. |
guaranteed |
Boolean |
Specifies whether the load balancer is a dedicated load balancer. Value options:
|
vpc_id |
String |
Specifies the ID of the VPC where the load balancer resides. |
eips |
Array of EipInfo objects |
Specifies the EIP bound to the load balancer. Only one EIP can be bound to a load balancer. This parameter has the same meaning as publicips. |
ipv6_vip_address |
String |
Specifies the IPv6 address bound to the load balancer. |
ipv6_vip_virsubnet_id |
String |
Specifies the ID of the IPv6 subnet where the load balancer resides. |
ipv6_vip_port_id |
String |
Specifies the ID of the port bound to the IPv6 address of the load balancer. |
availability_zone_list |
Array of strings |
Specifies the list of AZs where the load balancer is created. |
enterprise_project_id |
String |
Specifies the enterprise project ID. If this parameter is not passed during resource creation, "0" will be returned, and the resource belongs to the default enterprise project. Note: "0" is not a valid enterprise project ID and cannot be used in the APIs for creating, updating the load balancer, or querying the details of the load balancer. |
billing_info |
String |
Provides resource billing information.
This parameter is unsupported. Please do not use it. |
l4_flavor_id |
String |
Specifies the ID of a flavor at Layer 4. l4_flavor_id defines the maximum elastic flavor at Layer 4. Note:
|
l4_scale_flavor_id |
String |
Specifies the ID of the reserved flavor at Layer 4. This parameter is unsupported. Please do not use it. |
l7_flavor_id |
String |
Specifies the ID of a flavor at Layer 7. l7_flavor_id defines the maximum elastic flavor at Layer 7. Note:
|
l7_scale_flavor_id |
String |
Specifies the ID of the reserved flavor at Layer 7. This parameter is unsupported. Please do not use it. |
publicips |
Array of PublicIpInfo objects |
Specifies the EIP bound to the load balancer. Only one EIP can be bound to a load balancer. This parameter has the same meaning as eips. |
global_eips |
Array of GlobalEipInfo objects |
Specifies the global EIP bound to the load balancer. Only the first global EIP specified under global_eips will be bound. |
elb_virsubnet_ids |
Array of strings |
Lists the IDs of subnets on the downstream plane. |
elb_virsubnet_type |
String |
Specifies the type of the subnet on the downstream plane. Value options:
|
ip_target_enable |
Boolean |
Specifies whether to add backend servers that are not in the load balancer's VPC. If you enable this function, you can add servers in a peer VPC connected through a VPC peering connection, servers in other public clouds, or servers in an on-premises data center at the other end of a Direct Connect or VPN connection, by using their IP addresses. Value options:
Note:
|
frozen_scene |
String |
Specifies the scenario where the load balancer is frozen. Multiple values are separated using commas (,). Value options:
|
ipv6_bandwidth |
BandwidthRef object |
Specifies the ID of the bandwidth used by an IPv6 address. Note: This parameter is available only when you create or update a load balancer with a public IPv6 address. If you use a new IPv6 address and specify a shared bandwidth, the IPv6 address will be added to the shared bandwidth. |
deletion_protection_enable |
Boolean |
Specifies whether to enable deletion protection. Value options:
Note:
|
autoscaling |
AutoscalingRef object |
Specifies information about elastic scaling. If elastic scaling is enabled, the load balancer specifications can be automatically adjusted based on incoming traffic. Note:
|
public_border_group |
String |
Specifies the AZ group to which the load balancer belongs. |
charge_mode |
String |
Specifies the charge mode when creating a load balancer. Value options:
|
waf_failure_action |
String |
Specifies traffic distributing policies when the WAF is faulty. Value options:
Note: This parameter takes effect only when WAF is enabled for the load balancer. |
protection_status |
String |
Specifies the protection status. Value options:
|
protection_reason |
String |
Specifies why the modification protection is enabled. Note: This parameter is valid only when protection_status is set to consoleProtection. The value can contain a maximum of 255 Unicode characters, excluding angle brackets (<>). |
log_group_id |
String |
Specifies the ID of the log group that is associated with the load balancer. |
log_topic_id |
String |
Specifies the ID of the log topic that is associated with the load balancer. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Specifies the tag key. |
value |
String |
Specifies the tag value. |
Parameter |
Type |
Description |
---|---|---|
eip_id |
String |
Specifies the EIP ID. |
eip_address |
String |
Specifies the EIP. |
ip_version |
Integer |
Specifies the IP version. 4 indicates IPv4, and 6 indicates IPv6. |
Parameter |
Type |
Description |
---|---|---|
publicip_id |
String |
Specifies the EIP ID. |
publicip_address |
String |
Specifies the IP address. |
ip_version |
Integer |
Specifies the IP version. The value can be 4 (IPv4) or 6 (IPv6). |
Parameter |
Type |
Description |
---|---|---|
global_eip_id |
String |
Specifies the ID of the global EIP. |
global_eip_address |
String |
Specifies the global EIP. |
ip_version |
Integer |
Specifies the IP version. The value can be 4 and 6. 4 indicates an IPv4 address, and 6 indicates an IPv6 address. |
Parameter |
Type |
Description |
---|---|---|
enable |
Boolean |
Specifies whether to enable elastic scaling for the load balancer. Value options:
|
min_l7_flavor_id |
String |
Specifies the ID of the minimum elastic flavor at Layer 7. Note:
|
Example Requests
Modifying the description and name of a load balancer
PUT https://{ELB_Endpoint}/v3/{project_id}/elb/loadbalancers/{loadbalancer_id} { "loadbalancer" : { "description" : "loadbalancer", "name" : "loadbalancer-update" } }
Example Responses
Status code: 200
Successful request.
{ "request_id" : "010dad1e-32a3-4405-ab83-62a1fc5f8722", "loadbalancer" : { "id" : "2e073bf8-edfe-4e51-a699-d915b0b8af89", "project_id" : "b2782e6708b8475c993e6064bc456bf8", "name" : "loadbalancer-update", "description" : "loadbalancer", "vip_port_id" : null, "vip_address" : null, "admin_state_up" : true, "provisioning_status" : "ACTIVE", "operating_status" : "ONLINE", "listeners" : [ { "id" : "41937176-bf64-4b58-8e0d-9ff2d0d32c54" }, { "id" : "abc6ac93-ad0e-4765-bd5a-eec632efde56" }, { "id" : "b9d8ba97-6d60-467d-838d-f3550b54c22a" }, { "id" : "fd797ebd-263d-4b18-96e9-e9188d36c69e" } ], "pools" : [ { "id" : "0aabcaa8-c35c-4ddc-a60c-9032d0ac0b80" }, { "id" : "165d9092-396e-4a8d-b398-067496a447d2" } ], "tags" : [ ], "provider" : "vlb", "created_at" : "2019-04-20T03:10:37Z", "updated_at" : "2019-05-24T02:11:58Z", "vpc_id" : "2037c5bb-e04b-4de2-9300-9051af18e417", "enterprise_project_id" : "0", "availability_zone_list" : [ "AZ1", "AZ2", "dc3" ], "ipv6_vip_address" : null, "ipv6_vip_virsubnet_id" : null, "ipv6_vip_port_id" : null, "eips" : [ ], "guaranteed" : true, "billing_info" : null, "l4_flavor_id" : null, "l4_scale_flavor_id" : null, "l7_flavor_id" : null, "l7_scale_flavor_id" : null, "vip_subnet_cidr_id" : null, "deletion_protection_enable" : false, "public_border_group" : "center" } }
SDK Sample Code
The SDK sample code is as follows.
Modifying the description and name of a 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 48 49 50 51 52 53 54 |
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 UpdateLoadBalancerSolution { 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(); UpdateLoadBalancerRequest request = new UpdateLoadBalancerRequest(); request.withLoadbalancerId("{loadbalancer_id}"); UpdateLoadBalancerRequestBody body = new UpdateLoadBalancerRequestBody(); UpdateLoadBalancerOption loadbalancerbody = new UpdateLoadBalancerOption(); loadbalancerbody.withName("loadbalancer-update") .withDescription("loadbalancer"); body.withLoadbalancer(loadbalancerbody); request.withBody(body); try { UpdateLoadBalancerResponse response = client.updateLoadBalancer(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()); } } } |
Modifying the description and name of a 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 |
# 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 = UpdateLoadBalancerRequest() request.loadbalancer_id = "{loadbalancer_id}" loadbalancerbody = UpdateLoadBalancerOption( name="loadbalancer-update", description="loadbalancer" ) request.body = UpdateLoadBalancerRequestBody( loadbalancer=loadbalancerbody ) response = client.update_load_balancer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Modifying the description and name of a 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 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.UpdateLoadBalancerRequest{} request.LoadbalancerId = "{loadbalancer_id}" nameLoadbalancer:= "loadbalancer-update" descriptionLoadbalancer:= "loadbalancer" loadbalancerbody := &model.UpdateLoadBalancerOption{ Name: &nameLoadbalancer, Description: &descriptionLoadbalancer, } request.Body = &model.UpdateLoadBalancerRequestBody{ Loadbalancer: loadbalancerbody, } response, err := client.UpdateLoadBalancer(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.
Modifying the description and name of a 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 48 49 50 51 52 53 54 |
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 UpdateLoadBalancerSolution { 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(); UpdateLoadBalancerRequest request = new UpdateLoadBalancerRequest(); request.withLoadbalancerId("{loadbalancer_id}"); UpdateLoadBalancerRequestBody body = new UpdateLoadBalancerRequestBody(); UpdateLoadBalancerOption loadbalancerbody = new UpdateLoadBalancerOption(); loadbalancerbody.withName("loadbalancer-update") .withDescription("loadbalancer"); body.withLoadbalancer(loadbalancerbody); request.withBody(body); try { UpdateLoadBalancerResponse response = client.updateLoadBalancer(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()); } } } |
Modifying the description and name of a 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 |
# 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 = UpdateLoadBalancerRequest() request.loadbalancer_id = "{loadbalancer_id}" loadbalancerbody = UpdateLoadBalancerOption( name="loadbalancer-update", description="loadbalancer" ) request.body = UpdateLoadBalancerRequestBody( loadbalancer=loadbalancerbody ) response = client.update_load_balancer(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Modifying the description and name of a 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 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.UpdateLoadBalancerRequest{} request.LoadbalancerId = "{loadbalancer_id}" nameLoadbalancer:= "loadbalancer-update" descriptionLoadbalancer:= "loadbalancer" loadbalancerbody := &model.UpdateLoadBalancerOption{ Name: &nameLoadbalancer, Description: &descriptionLoadbalancer, } request.Body = &model.UpdateLoadBalancerRequestBody{ Loadbalancer: loadbalancerbody, } response, err := client.UpdateLoadBalancer(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