Share via


DeviceManagementClient.GetBestUpdatesForDeviceClassSubgroupAsync Method

Definition

Get the best available update for a device class subgroup and a count of how many devices need this update.

public virtual System.Threading.Tasks.Task<Azure.Response> GetBestUpdatesForDeviceClassSubgroupAsync (string groupId, string deviceClassId, Azure.RequestContext context = default);
abstract member GetBestUpdatesForDeviceClassSubgroupAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetBestUpdatesForDeviceClassSubgroupAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetBestUpdatesForDeviceClassSubgroupAsync (groupId As String, deviceClassId As String, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

groupId
String

Group identifier.

deviceClassId
String

Device class identifier.

context
RequestContext

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

Returns

The response returned from the service. Details of the response body schema are in the Remarks section below.

Exceptions

groupId or deviceClassId is null.

groupId or deviceClassId 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 GetBestUpdatesForDeviceClassSubgroupAsync 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);

Response response = await client.GetBestUpdatesForDeviceClassSubgroupAsync("<groupId>", "<deviceClassId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("groupId").ToString());
Console.WriteLine(result.GetProperty("deviceClassId").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("deviceCount").ToString());

Remarks

Below is the JSON schema for the response payload.

Response Body:

Schema for DeviceClassSubgroupUpdatableDevices:

{
              groupId: string, # Required. The group Id
              deviceClassId: string, # Required. The device class subgroup's device class Id
              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.
              deviceCount: number, # Required. Total number of devices for which the update is applicable.
            }

Applies to