次の方法で共有


DeviceUpdateClient.GetUpdatesAsync(String, String, RequestContext) メソッド

定義

IoT Hubの Device Update にインポートされたすべての更新プログラムの一覧を取得します。

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

パラメーター

search
String

自由テキスト検索式に一致する更新を要求します。

filter
String

isDeployable プロパティで更新プログラムをフィルター処理する場合は省略可能です。

context
RequestContext

要求コンテキスト。これは、呼び出しごとにクライアント パイプラインの既定の動作をオーバーライドできます。

戻り値

AsyncPageable<T>オブジェクトの一覧を含むサービスの BinaryData 。 コレクション内の各項目の本文スキーマの詳細については、以下の「解説」セクションを参照してください。

例外

サービスから成功以外の状態コードが返されました。

このサンプルでは、GetUpdatesAsync を呼び出して結果を解析する方法を示します。

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

await foreach (var data in client.GetUpdatesAsync())
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).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());
}

このサンプルでは、すべてのパラメーターを使用して GetUpdatesAsync を呼び出す方法と、結果を解析する方法を示します。

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

await foreach (var data in client.GetUpdatesAsync("<search>", "<filter>"))
{
    JsonElement result = JsonDocument.Parse(data.ToStream()).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());
}

注釈

ページング可能な応答の 1 つの項目の JSON スキーマを次に示します。

応答本文:

UpdateListValueスキーマ:

{
              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.
            }

適用対象