Partager via


DeviceManagementClient.GetDeploymentsForDeviceClassSubgroupsAsync Méthode

Définition

Obtient la liste des déploiements pour un sous-groupe de classe d’appareil.

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

Paramètres

groupId
String

Identificateur de groupe.

deviceClassId
String

Identificateur de classe d’appareil.

orderBy
String

Commande l’ensemble de déploiements retourné. Vous pouvez commander par date de début.

context
RequestContext

Contexte de requête, qui peut remplacer les comportements par défaut du pipeline client par appel.

Retours

à AsyncPageable<T> partir du service contenant une liste d’objets BinaryData . Les détails du schéma de corps pour chaque élément de la collection se trouvent dans la section Remarques ci-dessous.

Exceptions

groupId ou deviceClassId est null.

groupId ou deviceClassId est une chaîne vide, et on s’attendait à ce qu’elle ne soit pas vide.

Le service a retourné un code de status non réussi.

Exemples

Cet exemple montre comment appeler GetDeploymentsForDeviceClassSubgroupsAsync avec les paramètres requis et analyser le résultat.

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

await foreach (var data in client.GetDeploymentsForDeviceClassSubgroupsAsync("<groupId>", "<deviceClassId>"))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("deploymentId").ToString());
    Console.WriteLine(result.GetProperty("startDateTime").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
    Console.WriteLine(result.GetProperty("groupId").ToString());
}

Cet exemple montre comment appeler GetDeploymentsForDeviceClassSubgroupsAsync avec tous les paramètres et comment analyser le résultat.

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

await foreach (var data in client.GetDeploymentsForDeviceClassSubgroupsAsync("<groupId>", "<deviceClassId>", "<orderBy>"))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("deploymentId").ToString());
    Console.WriteLine(result.GetProperty("startDateTime").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("description").ToString());
    Console.WriteLine(result.GetProperty("update").GetProperty("friendlyName").ToString());
    Console.WriteLine(result.GetProperty("groupId").ToString());
    Console.WriteLine(result.GetProperty("deviceClassSubgroups")[0].ToString());
    Console.WriteLine(result.GetProperty("isCanceled").ToString());
    Console.WriteLine(result.GetProperty("isRetried").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("provider").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("name").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("updateId").GetProperty("version").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("description").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("update").GetProperty("friendlyName").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("failure").GetProperty("devicesFailedPercentage").ToString());
    Console.WriteLine(result.GetProperty("rollbackPolicy").GetProperty("failure").GetProperty("devicesFailedCount").ToString());
    Console.WriteLine(result.GetProperty("isCloudInitiatedRollback").ToString());
}

Remarques

Voici le schéma JSON d’un élément de la réponse paginable.

Corps de réponse :

Schéma pour DeploymentsListValue:

{
              deploymentId: string, # Required. The caller-provided deployment identifier. This cannot be longer than 73 characters, must be all lower-case, and cannot contain '&', '^', '[', ']', '{', '}', '|', '<', '>', forward slash, backslash, or double quote. The Updates view in the Azure Portal IoT Hub resource generates a GUID for deploymentId when you create a deployment.
              startDateTime: string (ISO 8601 Format), # Required. The deployment start datetime.
              update: {
                updateId: {
                  provider: string, # Required. Update provider.
                  name: string, # Required. Update name.
                  version: string, # Required. Update version.
                }, # Required. Update identifier.
                description: string, # Optional. Update description.
                friendlyName: string, # Optional. Friendly update name.
              }, # Required. Update information for the update in the deployment.
              groupId: string, # Required. The group identity for the devices the deployment is intended to update.
              deviceClassSubgroups: [string], # Optional. The device class subgroups the deployment is compatible with and subgroup deployments have been created for. This is not provided by the caller during CreateOrUpdateDeployment but is automatically determined by Device Update
              isCanceled: boolean, # Optional. Boolean flag indicating whether the deployment was canceled.
              isRetried: boolean, # Optional. Boolean flag indicating whether the deployment has been retried.
              rollbackPolicy: {
                update: UpdateInfo, # Required. Update to rollback to.
                failure: {
                  devicesFailedPercentage: number, # Required. Percentage of devices that failed.
                  devicesFailedCount: number, # Required. Number of devices that failed.
                }, # Required. Failure conditions to initiate rollback policy.
              }, # Optional. The rollback policy for the deployment.
              isCloudInitiatedRollback: boolean, # Optional. Boolean flag indicating whether the deployment is a rollback deployment.
            }

S’applique à