Skip to main content

List

Retrieves the list of devices in the specified registry.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const DeviceView = cloudApi.iot.devices_device.DeviceView;
const ListDevicesRequest =
cloudApi.iot.devices_device_service.ListDevicesRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.DeviceServiceClient);

const result = await client.list(
ListDevicesRequest.fromPartial({
// registryId: "registryId",
// folderId: "folderId",
// pageSize: 0,
// pageToken: "pageToken",
// deviceView: DeviceView.FULL
})
);
console.log(result);
})();

ListDevicesRequest

One of id

  • registryId : string

    ID of the registry to list devices in.

To get a registry ID make a yandex.cloud.iot.devices.v1.RegistryService.List request.

  • folderId : string

    ID of the folder to list devices in.

To get a folder ID make a yandex.cloud.resourcemanager.v1.FolderService.List request.

pageSize : int64

The maximum number of results per page to return. If the number of available results is larger than page_size, the service returns a ListDevicesResponse.next_page_token that can be used to get the next page of results in subsequent list requests. Default value: 100.

pageToken : string

Page token. To get the next page of results, set page_token to the ListDevicesResponse.next_page_token returned by a previous list request.

deviceView : DeviceView

Specifies which parts of the device resource should be returned in the response.

ListDevicesResponse

devices : Device

List of devices.

nextPageToken : string

Token for getting the next page of the list. If the number of results is greater than the specified ListDevicesRequest.page_size, use next_page_token as the value for the ListDevicesRequest.page_token parameter in the next list request.

Each subsequent page will have its own next_page_token to continue paging through the results.

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.

DeviceMonitoringData

lastAuthIp : string
lastAuthTime : google.protobuf.Timestamp
lastPubActivityTime : google.protobuf.Timestamp
lastSubActivityTime : google.protobuf.Timestamp
lastOnlineTime : google.protobuf.Timestamp