GetByName
- TypeScript
- Python
import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";
const DeviceView = cloudApi.iot.devices_device.DeviceView;
const GetByNameDeviceRequest =
cloudApi.iot.devices_device_service.GetByNameDeviceRequest;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.DeviceServiceClient);
const result = await client.getByName(
GetByNameDeviceRequest.fromPartial({
registryId: "registryId",
deviceName: "deviceName",
// deviceView: DeviceView.FULL
})
);
console.log(result);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.iot.devices.v1.device_service_pb2_grpc import DeviceServiceStub
from yandex.cloud.iot.devices.v1.device_pb2 import DeviceView
from yandex.cloud.iot.devices.v1.device_service_pb2 import GetByNameDeviceRequest
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(DeviceServiceStub)
response = service.GetByName(
GetByNameDeviceRequest(
registry_id="registryId",
device_name="deviceName",
# device_view = DeviceView.FULL
)
)
print(response)
GetByNameDeviceRequest
registryId
: string
ID of the registry to get device.
To get a registry ID make a yandex.cloud.iot.devices.v1.RegistryService.List request.
deviceName
: string
Name of the device to return.
To get a device name make a DeviceService.List request.
deviceView
: DeviceView
Specifies which parts of the device resource should be returned in the response.
Device
A device. For more information, see Device.
Status
STATUS_UNSPECIFIED
CREATING
Device is being created.
ACTIVE
Device is ready to use.
DELETING
Device is being deleted.
id
: string
ID of the device.
registryId
: string
ID of the registry that the device belongs to.
createdAt
: google.protobuf.Timestamp
Creation timestamp.
name
: string
Name of the device. The name is unique within the registry.
description
: string
Description of the device. 0-256 characters long.
topicAliases
: string
Alias of a device topic.
Alias is an alternate name of a device topic assigned by the user. Map alias to canonical topic name prefix, e.g. my/custom/alias
match to $device/abcdef/events
.
status
: Status
Status of the device.
monitoringData
: DeviceMonitoringData
Device monitoring data, returns if FULL view specified.