Update
Updates the specified network load balancer.
- TypeScript
- Python
import {
cloudApi,
decodeMessage,
serviceClients,
Session,
waitForOperation,
} from "@yandex-cloud/nodejs-sdk";
const IpVersion = cloudApi.loadbalancer.network_load_balancer.IpVersion;
const Listener_Protocol =
cloudApi.loadbalancer.network_load_balancer.Listener_Protocol;
const NetworkLoadBalancer =
cloudApi.loadbalancer.network_load_balancer.NetworkLoadBalancer;
const UpdateNetworkLoadBalancerRequest =
cloudApi.loadbalancer.network_load_balancer_service
.UpdateNetworkLoadBalancerRequest;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(
serviceClients.NetworkLoadBalancerServiceClient
);
const operation = await client.update(
UpdateNetworkLoadBalancerRequest.fromPartial({
networkLoadBalancerId: "networkLoadBalancerId",
// updateMask: {
// paths: ["paths"]
// },
// name: "name",
// description: "description",
// labels: {"key": "labels"},
// listenerSpecs: [{
// name: "name",
// port: 0,
// protocol: Listener_Protocol.TCP,
// externalAddressSpec: {
// address: "address",
// ipVersion: IpVersion.IPV4
// },
// internalAddressSpec: {
// address: "address",
// subnetId: "subnetId",
// ipVersion: IpVersion.IPV4
// },
// targetPort: 0
// }],
// attachedTargetGroups: [{
// targetGroupId: "targetGroupId",
// healthChecks: [{
// name: "name",
// interval: {
// seconds: 0,
// nanos: 0
// },
// timeout: {
// seconds: 0,
// nanos: 0
// },
// unhealthyThreshold: 0,
// healthyThreshold: 0,
// tcpOptions: {
// port: 0
// },
// httpOptions: {
// port: 0,
// path: "path"
// }
// }]
// }],
// deletionProtection: true
})
);
const finishedOp = await waitForOperation(operation, session);
if (finishedOp.response) {
const result = decodeMessage<typeof NetworkLoadBalancer>(
finishedOp.response
);
console.log(result);
}
})();
import os
import grpc
import yandexcloud
from yandex.cloud.loadbalancer.v1.network_load_balancer_pb2 import AttachedTargetGroup
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2 import ExternalAddressSpec
from yandex.cloud.loadbalancer.v1.health_check_pb2 import HealthCheck
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2 import InternalAddressSpec
from yandex.cloud.loadbalancer.v1.network_load_balancer_pb2 import IpVersion
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2 import ListenerSpec
from yandex.cloud.loadbalancer.v1.network_load_balancer_pb2 import NetworkLoadBalancer
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2_grpc import (
NetworkLoadBalancerServiceStub,
)
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2 import (
UpdateNetworkLoadBalancerMetadata,
)
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2 import (
UpdateNetworkLoadBalancerRequest,
)
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(NetworkLoadBalancerServiceStub)
operation = service.Update(
UpdateNetworkLoadBalancerRequest(
network_load_balancer_id="networkLoadBalancerId",
# update_mask = FieldMask.FromJsonString("field1,field2"),
# name = "name",
# description = "description",
# labels = {"key": "labels"},
# listener_specs = [ListenerSpec(
# name = "name",
# port = 0,
# protocol = Listener.Protocol.TCP,
# external_address_spec = ExternalAddressSpec(
# address = "address",
# ip_version = IpVersion.IPV4
# ),
# internal_address_spec = InternalAddressSpec(
# address = "address",
# subnet_id = "subnetId",
# ip_version = IpVersion.IPV4
# ),
# target_port = 0
# )],
# attached_target_groups = [AttachedTargetGroup(
# target_group_id = "targetGroupId",
# health_checks = [HealthCheck(
# name = "name",
# interval = Duration(
# seconds = 0,
# nanos = 0
# ),
# timeout = Duration(
# seconds = 0,
# nanos = 0
# ),
# unhealthy_threshold = 0,
# healthy_threshold = 0,
# tcp_options = HealthCheck.TcpOptions(
# port = 0
# ),
# http_options = HealthCheck.HttpOptions(
# port = 0,
# path = "path"
# )
# )]
# )],
# deletion_protection = true
)
)
operation_result = sdk.wait_operation_and_get_result(
operation,
response_type=NetworkLoadBalancer,
meta_type=UpdateNetworkLoadBalancerMetadata,
)
print(operation_result)
UpdateNetworkLoadBalancerRequest
networkLoadBalancerId
: string
ID of the network load balancer to update. To get the network load balancer ID, use a NetworkLoadBalancerService.List request.
updateMask
: google.protobuf.FieldMask
Field mask that specifies which fields of the NetworkLoadBalancer resource are going to be updated.
name
: string
Name of the network load balancer. The name must be unique within the folder.
description
: string
Description of the network load balancer.
labels
: string
Resource labels as key:value
pairs.
The existing set of labels
is completely replaced with the provided set.
listenerSpecs
: ListenerSpec
A list of listeners and their specs for the network load balancer.
attachedTargetGroups
: AttachedTargetGroup
A list of attached target groups for the network load balancer.
deletionProtection
: bool
Specifies if network load balancer protected from deletion.
ListenerSpec
Listener specification that will be used by a network load balancer.
name
: string
Name of the listener. The name must be unique for each listener on a single load balancer. 3-63 characters long.
port
: int64
Port for incoming traffic.
protocol
: Listener.Protocol
Protocol for incoming traffic.
One of address
IP address for incoming traffic. Either the ID of the previously created address or the address specification.
externalAddressSpec
: ExternalAddressSpecExternal IP address specification.
internalAddressSpec
: InternalAddressSpecInternal IP address specification.
targetPort
: int64
Port of a target. Acceptable values are 1 to 65535, inclusive.
AttachedTargetGroup
An AttachedTargetGroup resource. For more information, see Targets and groups.
targetGroupId
: string
ID of the target group.
healthChecks
: HealthCheck
A health check to perform on the target group. For now we accept only one health check per AttachedTargetGroup.
ExternalAddressSpec
External address specification that is used by ListenerSpec.
address
: string
Public IP address for a listener. If you provide a static public IP address for the NetworkLoadBalancerService.Update method, it will replace the existing listener address.
ipVersion
: IpVersion
IP version.
InternalAddressSpec
Internal address specification that is used by ListenerSpec.
address
: string
Internal IP address for a listener.
subnetId
: string
ID of the subnet.
ipVersion
: IpVersion
IP version.
HealthCheck
A HealthCheck resource. For more information, see Health check.
TcpOptions
Configuration option for a TCP health check.
port
: int64
Port to use for TCP health checks.
HttpOptions
Configuration option for an HTTP health check.
port
: int64
Port to use for HTTP health checks.
path
: string
URL path to set for health checking requests for every target in the target group.
For example /ping
. The default path is /
.
name
: string
Name of the health check. The name must be unique for each target group that attached to a single load balancer. 3-63 characters long.
interval
: google.protobuf.Duration
The interval between health checks. The default is 2 seconds.
timeout
: google.protobuf.Duration
Timeout for a target to return a response for the health check. The default is 1 second.
unhealthyThreshold
: int64
Number of failed health checks before changing the status to UNHEALTHY
. The default is 2.
healthyThreshold
: int64
Number of successful health checks required in order to set the HEALTHY
status for the target. The default is 2.
One of options
Protocol to use for the health check. Either TCP or HTTP.
tcpOptions
: TcpOptionsOptions for TCP health check.
httpOptions
: HttpOptionsOptions for HTTP health check.
TcpOptions
Configuration option for a TCP health check.
port
: int64
Port to use for TCP health checks.
HttpOptions
Configuration option for an HTTP health check.
port
: int64
Port to use for HTTP health checks.
path
: string
URL path to set for health checking requests for every target in the target group.
For example /ping
. The default path is /
.
Operation
An Operation resource. For more information, see Operation.
id
: string
ID of the operation.
description
: string
Description of the operation. 0-256 characters long.
createdAt
: google.protobuf.Timestamp
Creation timestamp.
createdBy
: string
ID of the user or service account who initiated the operation.
modifiedAt
: google.protobuf.Timestamp
The time when the Operation resource was last modified.
done
: bool
If the value is false
, it means the operation is still in progress.
If true
, the operation is completed, and either error
or response
is available.
metadata
: google.protobuf.Any
Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.
One of result
The operation result.
If done == false
and there was no failure detected, neither error
nor response
is set.
If done == false
and there was a failure detected, error
is set.
If done == true
, exactly one of error
or response
is set.
error
: google.rpc.StatusThe error result of the operation in case of failure or cancellation.
response
: google.protobuf.AnyThe normal response of the operation in case of success.
If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.