DeviceManagementClient.GetGroupsAsync(String, RequestContext) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a list of all device groups. The $default group will always be returned first.
public virtual Azure.AsyncPageable<BinaryData> GetGroupsAsync (string orderBy = default, Azure.RequestContext context = default);
abstract member GetGroupsAsync : string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetGroupsAsync : string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetGroupsAsync (Optional orderBy As String = Nothing, Optional context As RequestContext = Nothing) As AsyncPageable(Of BinaryData)
Parameters
- orderBy
- String
Orders the set of groups returned. You can order by groupId, deviceCount, createdDate, subgroupsWithNewUpdatesAvailableCount, subgroupsWithUpdatesInProgressCount, or subgroupsOnLatestUpdateCount.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The AsyncPageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.
Exceptions
Service returned a non-success status code.
Examples
This sample shows how to call GetGroupsAsync and parse the result.
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.GetGroupsAsync())
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("groupId").ToString());
Console.WriteLine(result.GetProperty("groupType").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
}
This sample shows how to call GetGroupsAsync with all parameters, and how to parse the result.
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.GetGroupsAsync("<orderBy>"))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("groupId").ToString());
Console.WriteLine(result.GetProperty("groupType").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("deviceCount").ToString());
Console.WriteLine(result.GetProperty("subgroupsWithNewUpdatesAvailableCount").ToString());
Console.WriteLine(result.GetProperty("subgroupsWithUpdatesInProgressCount").ToString());
Console.WriteLine(result.GetProperty("subgroupsWithOnLatestUpdateCount").ToString());
Console.WriteLine(result.GetProperty("deployments")[0].ToString());
}
Remarks
Below is the JSON schema for one item in the pageable response.
Response Body:
Schema for GroupsListValue
:
{
groupId: string, # Required. Group identity. This is created from the value of the ADUGroup tag in the Iot Hub's device/module twin or $default for devices with no tag.
groupType: "IoTHubTag" | "DefaultNoTag", # Required. Group type.
createdDateTime: string, # Required. Date and time when the update was created.
deviceCount: number, # Optional. The number of devices in the group.
subgroupsWithNewUpdatesAvailableCount: number, # Optional. The count of subgroups with new updates available.
subgroupsWithUpdatesInProgressCount: number, # Optional. The count of subgroups with updates in progress.
subgroupsWithOnLatestUpdateCount: number, # Optional. The count of subgroups with devices on the latest update.
deployments: [string], # Optional. The active deployment Ids for the group
}
Applies to
Azure SDK for .NET