Partager via


DeviceUpdateClient.GetUpdate Méthode

Définition

Obtenir une version de mise à jour spécifique.

public virtual Azure.Response GetUpdate (string provider, string name, string version, Azure.ETag? ifNoneMatch = default, Azure.RequestContext context = default);
abstract member GetUpdate : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
override this.GetUpdate : string * string * string * Nullable<Azure.ETag> * Azure.RequestContext -> Azure.Response
Public Overridable Function GetUpdate (provider As String, name As String, version As String, Optional ifNoneMatch As Nullable(Of ETag) = Nothing, Optional context As RequestContext = Nothing) As Response

Paramètres

provider
String

Fournisseur de mise à jour.

name
String

Nom de la mise à jour.

version
String

Mettre à jour la version.

ifNoneMatch
Nullable<ETag>

Définit la condition If-None-Match. L’opération est effectuée uniquement si l’ETag sur le serveur ne correspond pas à cette valeur.

context
RequestContext

Contexte de la demande, qui peut remplacer les comportements par défaut du pipeline client par appel.

Retours

Réponse retournée par le service. Les détails du schéma du corps de la réponse se trouvent dans la section Remarques ci-dessous.

Exceptions

provider, name ou version a la valeur Null.

provider, name ou version est une chaîne vide, et était censé être non vide.

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

Exemples

Cet exemple montre comment appeler GetUpdate 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 DeviceUpdateClient(endpoint, "<instanceId>", credential);

Response response = client.GetUpdate("<provider>", "<name>", "<version>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("compatibility")[0].GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("manifestVersion").ToString());
Console.WriteLine(result.GetProperty("importedDateTime").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());

Cet exemple montre comment appeler GetUpdate 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 DeviceUpdateClient(endpoint, "<instanceId>", credential);

Response response = client.GetUpdate("<provider>", "<name>", "<version>", null);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("friendlyName").ToString());
Console.WriteLine(result.GetProperty("isDeployable").ToString());
Console.WriteLine(result.GetProperty("updateType").ToString());
Console.WriteLine(result.GetProperty("installedCriteria").ToString());
Console.WriteLine(result.GetProperty("compatibility")[0].GetProperty("<test>").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("handler").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("handlerProperties").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("files")[0].ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("instructions").GetProperty("steps")[0].GetProperty("updateId").GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("provider").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("referencedBy")[0].GetProperty("version").ToString());
Console.WriteLine(result.GetProperty("scanResult").ToString());
Console.WriteLine(result.GetProperty("manifestVersion").ToString());
Console.WriteLine(result.GetProperty("importedDateTime").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("etag").ToString());

Remarques

Vous trouverez ci-dessous le schéma JSON pour la charge utile de réponse.

Corps de réponse :

Schéma pour Update:

{
              updateId: {
                provider: string, # Required. Update provider.
                name: string, # Required. Update name.
                version: string, # Required. Update version.
              }, # Required. Update identity.
              description: string, # Optional. Update description specified by creator.
              friendlyName: string, # Optional. Friendly update name specified by importer.
              isDeployable: boolean, # Optional. Whether the update can be deployed to a device on its own.
              updateType: string, # Optional. Update type. Deprecated in latest import manifest schema.
              installedCriteria: string, # Optional. String interpreted by Device Update client to determine if the update is installed on the device. Deprecated in latest import manifest schema.
              compatibility: [Dictionary<string, string>], # Required. List of update compatibility information.
              instructions: {
                steps: [
                  {
                    type: "Inline" | "Reference", # Optional. Step type.
                    description: string, # Optional. Step description.
                    handler: string, # Optional. Identity of handler that will execute this step. Required if step type is inline.
                    handlerProperties: AnyObject, # Optional. Parameters to be passed to handler during execution.
                    files: [string], # Optional. Collection of file names to be passed to handler during execution. Required if step type is inline.
                    updateId: UpdateId, # Optional. Referenced child update identity.  Required if step type is reference.
                  }
                ], # Required. Collection of installation steps.
              }, # Optional. Update install instructions.
              referencedBy: [UpdateId], # Optional. List of update identities that reference this update.
              scanResult: string, # Optional. Update aggregate scan result (calculated from payload file scan results).
              manifestVersion: string, # Required. Schema version of manifest used to import the update.
              importedDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the update was imported.
              createdDateTime: string (ISO 8601 Format), # Required. Date and time in UTC when the update was created.
              etag: string, # Optional. Update ETag.
            }

S’applique à