列出设备使用情况Rights
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
检索给定设备的 usageRight 对象列表。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Device.Read.All、Directory.Read.All、Directory.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Device.Read.All、Device.ReadWrite.All、Directory.Read.All、Directory.ReadWrite.All
HTTP 请求
GET /devices/{objectId}/usageRights
可选的查询参数
此 API 支持 $filter OData 查询参数 。 支持以下 $filter 模式:
$filter = state eq 'value'
$filter = serviceIdentifier eq 'value'
$filter = state eq 'value' and serviceIdentifier eq 'value'
$filter = ( value1、value2")
$filter =serviceIdentifier in ('value1', 'value2')
$filter = ( value1、value2") 和 serviceIdentifier 中的 state ("value1","value2")
名称
说明
Authorization
Bearer {token}。必需。
odata.maxpagesize
设置每个结果页的最大大小。 可选。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应正文中返回 响应代码和 200 OK usageRight 对象集合。
此外,如果响应中有更多的页面,@odata.nextLink。
示例
示例 1:获取设备的所有使用权限
请求
GET https://graph.microsoft.com/beta/devices/{objectId}/usageRights
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var usageRights = await graphClient.Devices["{device-id}"].UsageRights
.Request()
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let usageRights = await client.api('/devices/{objectId}/usageRights')
.version('beta')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/devices/{objectId}/usageRights"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphUsageRight *usageRight = [[MSGraphUsageRight alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UsageRightCollectionPage usageRights = graphClient.devices("{objectId}").usageRights()
.buildRequest()
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
deviceId := "device-id"
result, err := graphClient.DevicesById(&deviceId).UsageRights().Get()
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDeviceUsageRights -DeviceId $deviceId
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#devices('fead5c35-ebc5-47c4-a909-c43b4faf2160')/usageRights",
"@odata.nextLink": "https://graph.microsoft.com/beta/devices/fead5c35-ebc5-47c4-a909-c43b4faf2160/usageRights?$skiptoken=W4diD29cGKX1bX",
"value": [
{
"id": "99f828b9-09f2-445d-a758-b6727316dbe1",
"catalogId": "CFQ7TTC0KCRG:0001",
"serviceIdentifier": "mscrm.f6d23ec7-255c-4bd8-8c99-dc041d5cb8b3.517f7ddd-df45-4f1c-83ec-a081a047f546",
"state": "active"
}
]
}
示例 2:获取具有特定服务标识符和状态的设备的使用权限
请求
GET https://graph.microsoft.com/beta/devices/{objectId}/usageRights?$filter=state in ('active', 'suspended') and serviceIdentifier in ('ABCD')
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var usageRights = await graphClient.Devices["{device-id}"].UsageRights
.Request()
.Filter("state in ('active', 'suspended') and serviceIdentifier in ('ABCD')")
.GetAsync();
const options = {
authProvider,
};
const client = Client.init(options);
let usageRights = await client.api('/devices/{objectId}/usageRights')
.version('beta')
.filter('state in (\'active\', \'suspended\') and serviceIdentifier in (\'ABCD\')')
.get();
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/devices/{objectId}/usageRights?$filter=state%20in%20('active',%20'suspended')%20and%20serviceIdentifier%20in%20('ABCD')"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
NSError *jsonError = nil;
MSCollection *collection = [[MSCollection alloc] initWithData:data error:&jsonError];
MSGraphUsageRight *usageRight = [[MSGraphUsageRight alloc] initWithDictionary:[[collection value] objectAtIndex: 0] error:&nserror];
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UsageRightCollectionPage usageRights = graphClient.devices("{objectId}").usageRights()
.buildRequest()
.filter("state in ('active', 'suspended') and serviceIdentifier in ('ABCD')")
.get();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestParameters := &msgraphsdk.UsageRightsRequestBuilderGetQueryParameters{
Filter: "state%20in%20('active',%20'suspended')%20and%20serviceIdentifier%20in%20('ABCD')",
}
options := &msgraphsdk.UsageRightsRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
deviceId := "device-id"
result, err := graphClient.DevicesById(&deviceId).UsageRights().GetWithRequestConfigurationAndResponseHandler(options, nil)
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDeviceUsageRights -DeviceId $deviceId -Filter "state in ('active', 'suspended') and serviceIdentifier in ('ABCD')"
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#devices('fead5c35-ebc5-47c4-a909-c43b4faf2160')/usageRights",
"value": [
{
"id": "9905e6b1-9040-4926-b028-fdb748c359d6",
"catalogId": "CFQ7TTC0KCRG:0001",
"serviceIdentifier": "ABCD",
"state": "active"
}
]
}