Partager via


DeviceManagementClient.GetOperationStatuses Méthode

Définition

Obtenez la liste de toutes les opérations d’importation d’appareils. Les opérations terminées sont conservées pendant 7 jours avant la suppression automatique.

public virtual Azure.Pageable<BinaryData> GetOperationStatuses (string filter = default, int? top = default, Azure.RequestContext context = default);
abstract member GetOperationStatuses : string * Nullable<int> * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetOperationStatuses : string * Nullable<int> * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetOperationStatuses (Optional filter As String = Nothing, Optional top As Nullable(Of Integer) = Nothing, Optional context As RequestContext = Nothing) As Pageable(Of BinaryData)

Paramètres

filter
String

Limite l’ensemble des opérations retournées. Un seul filtre spécifique est pris en charge : « status eq 'NotStarted' ou status eq 'Running' ».

top
Nullable<Int32>

Spécifie un entier non négatif n qui limite le nombre d’éléments retournés à partir d’une collection. Le service retourne le nombre d’éléments disponibles jusqu’à , mais pas supérieur à la valeur spécifiée n.

context
RequestContext

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

Retours

à Pageable<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

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

Exemples

Cet exemple montre comment appeler GetOperationStatuses 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);

foreach (var data in client.GetOperationStatuses())
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("operationId").ToString());
    Console.WriteLine(result.GetProperty("status").ToString());
    Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
    Console.WriteLine(result.GetProperty("createdDateTime").ToString());
}

Cet exemple montre comment appeler GetOperationStatuses 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);

foreach (var data in client.GetOperationStatuses("<filter>", 1234))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("operationId").ToString());
    Console.WriteLine(result.GetProperty("status").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("message").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("errorDetail").ToString());
    Console.WriteLine(result.GetProperty("error").GetProperty("occurredDateTime").ToString());
    Console.WriteLine(result.GetProperty("traceId").ToString());
    Console.WriteLine(result.GetProperty("lastActionDateTime").ToString());
    Console.WriteLine(result.GetProperty("createdDateTime").ToString());
    Console.WriteLine(result.GetProperty("etag").ToString());
}

Remarques

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

Corps de réponse :

Schéma pour DeviceOperationsListValue:

{
              operationId: string, # Required. Operation Id.
              status: "NotStarted" | "Running" | "Succeeded" | "Failed", # Required. Operation status.
              error: {
                code: string, # Required. Server defined error code.
                message: string, # Required. A human-readable representation of the error.
                target: string, # Optional. The target of the error.
                details: [Error], # Optional. An array of errors that led to the reported error.
                innererror: {
                  code: string, # Required. A more specific error code than what was provided by the containing error.
                  message: string, # Optional. A human-readable representation of the error.
                  errorDetail: string, # Optional. The internal error or exception message.
                  innerError: InnerError, # Optional. An object containing more specific information than the current object about the error.
                }, # Optional. An object containing more specific information than the current object about the error.
                occurredDateTime: string (ISO 8601 Format), # Optional. Date and time in UTC when the error occurred.
              }, # Optional. Operation error encountered, if any.
              traceId: string, # Optional. Operation correlation identity that can used by Microsoft Support for troubleshooting.
              lastActionDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the operation status was last updated.
              createdDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the operation was created.
              etag: string, # Optional. Operation ETag.
            }

S’applique à