GetTargetStates
Gets states of target resources in the attached target group.
- TypeScript
- Python
import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";
const GetTargetStatesRequest =
cloudApi.apploadbalancer.load_balancer_service.GetTargetStatesRequest;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(
serviceClients.NetworkLoadBalancerServiceClient
);
const result = await client.getTargetStates(
GetTargetStatesRequest.fromPartial({
loadBalancerId: "loadBalancerId",
backendGroupId: "backendGroupId",
targetGroupId: "targetGroupId",
})
);
console.log(result);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.apploadbalancer.v1.load_balancer_service_pb2 import GetTargetStatesRequest
from yandex.cloud.loadbalancer.v1.network_load_balancer_service_pb2_grpc import (
NetworkLoadBalancerServiceStub,
)
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(NetworkLoadBalancerServiceStub)
response = service.GetTargetStates(
GetTargetStatesRequest(
load_balancer_id="loadBalancerId",
backend_group_id="backendGroupId",
target_group_id="targetGroupId",
)
)
print(response)
GetTargetStatesRequest
networkLoadBalancerId
: string
ID of the NetworkLoadBalancer resource with an attached target group.
targetGroupId
: string
ID of the target group to get states of resources from.
GetTargetStatesResponse
targetStates
: TargetState
List of states of targets within the target group that is specified in the GetTargetStatesRequest message.
TargetState
State of the target that was returned after the last health check.
Status
Status of the target.
STATUS_UNSPECIFIED
Status of the target.
INITIAL
The network load balancer is setting up health checks for this target.
HEALTHY
Health check passed and the target is ready to receive traffic.
UNHEALTHY
Health check failed and the target is not receiving traffic.
DRAINING
Target is being deleted and the network load balancer is no longer sending traffic to this target.
INACTIVE
The network load balancer is stopped and not performing health checks on this target.
subnetId
: string
ID of the subnet that the target is connected to.
address
: string
IP address of the target.
status
: Status
Status of the target.