Share via


DeviceManagementClient.GetDeviceStatesForDeviceClassSubgroupDeployments Method

Definition

Gets a list of devices in a deployment along with their state. Useful for getting a list of failed devices.

public virtual Azure.Pageable<BinaryData> GetDeviceStatesForDeviceClassSubgroupDeployments (string groupId, string deviceClassId, string deploymentId, string filter = default, Azure.RequestContext context = default);
abstract member GetDeviceStatesForDeviceClassSubgroupDeployments : string * string * string * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetDeviceStatesForDeviceClassSubgroupDeployments : string * string * string * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetDeviceStatesForDeviceClassSubgroupDeployments (groupId As String, deviceClassId As String, deploymentId As String, Optional filter As String = Nothing, Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)

Parameters

groupId
String

Group identifier.

deviceClassId
String

Device class identifier.

deploymentId
String

Deployment identifier.

filter
String

Restricts the set of deployment device states returned. You can filter on deviceId and moduleId and/or deviceState.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Pageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

groupId, deviceClassId or deploymentId is null.

groupId, deviceClassId or deploymentId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call GetDeviceStatesForDeviceClassSubgroupDeployments with required parameters and parse the result.

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);

foreach (var data in client.GetDeviceStatesForDeviceClassSubgroupDeployments("<groupId>", "<deviceClassId>", "<deploymentId>"))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("deviceId").ToString());
    Console.WriteLine(result.GetProperty("retryCount").ToString());
    Console.WriteLine(result.GetProperty("movedOnToNewDeployment").ToString());
    Console.WriteLine(result.GetProperty("deviceState").ToString());
}

This sample shows how to call GetDeviceStatesForDeviceClassSubgroupDeployments with all parameters, and how to parse the result.

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new DeviceManagementClient(endpoint, "<instanceId>", credential);

foreach (var data in client.GetDeviceStatesForDeviceClassSubgroupDeployments("<groupId>", "<deviceClassId>", "<deploymentId>", "<filter>"))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("deviceId").ToString());
    Console.WriteLine(result.GetProperty("moduleId").ToString());
    Console.WriteLine(result.GetProperty("retryCount").ToString());
    Console.WriteLine(result.GetProperty("movedOnToNewDeployment").ToString());
    Console.WriteLine(result.GetProperty("deviceState").ToString());
}

Remarks

Below is the JSON schema for one item in the pageable response.

Response Body:

Schema for DeploymentDeviceStatesListValue:

{
              deviceId: string, # Required. Device identity.
              moduleId: string, # Optional. Device module identity.
              retryCount: number, # Required. The number of times this deployment has been retried on this device.
              movedOnToNewDeployment: boolean, # Required. Boolean flag indicating whether this device is in a newer deployment and can no longer retry this deployment.
              deviceState: "Succeeded" | "InProgress" | "Canceled" | "Failed", # Required. Deployment device state.
            }

Applies to