updatableAsset: enrollAssets
命名空间:microsoft.graph.windowsUpdates
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
在 部署服务的更新管理中注册 updatableAsset 资源。
可以在更新管理中注册 azureADDevice 资源,但不能在更新管理中注册 updatableAssetGroup 。
在更新Azure AD注册设备会自动创建 azureADDevice 对象(如果该对象不存在)。
您还可以使用 enrollAssetsById 方法 注册资产。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
WindowsUpdates.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
WindowsUpdates.ReadWrite.All |
HTTP 请求
POST /admin/windows/updates/updatableAssets/enrollAssets
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供参数的 JSON 表示形式。
下表显示了可用于此操作的参数。
| 参数 |
类型 |
说明 |
| updateCategory |
microsoft.graph.windowsUpdates.updateCategory |
要管理的服务的更新类别。 支持 updateCategory 值的子集。 可取值为:feature、unknownFutureValue。 |
| assets |
microsoft.graph.windowsUpdates.updatableAsset 集合 |
要通过服务为给定 updateCategory 注册更新管理的 updatableAsset 资源列表。 |
响应
如果成功,此操作返回 202 Accepted 响应代码。 它不会在响应正文中返回任何内容。
示例
请求
POST https://graph.microsoft.com/beta/admin/windows/updates/updatableAssets/enrollAssets
Content-Type: application/json
{
"updateCategory": "String",
"assets": [
{
"@odata.type": "#microsoft.graph.windowsUpdates.azureADDevice",
"id": "String (identifier)"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var updateCategory = Microsoft.Graph.WindowsUpdates.UpdateCategory.Feature;
var assets = new List<Microsoft.Graph.WindowsUpdates.UpdatableAsset>()
{
new Microsoft.Graph.WindowsUpdates.AzureADDevice
{
Id = "String (identifier)"
}
};
await graphClient.Admin.Windows.Updates.UpdatableAssets
.EnrollAssets(updateCategory,assets)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const enrollAssets = {
updateCategory: 'String',
assets: [
{
'@odata.type': '#microsoft.graph.windowsUpdates.azureADDevice',
id: 'String (identifier)'
}
]
};
await client.api('/admin/windows/updates/updatableAssets/enrollAssets')
.version('beta')
.post(enrollAssets);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/admin/windows/updates/updatableAssets/enrollAssets"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphWindowsUpdatesUpdateCategory *updateCategory = [MSGraphWindowsUpdatesUpdateCategory feature];
payloadDictionary[@"updateCategory"] = updateCategory;
NSMutableArray *assetsList = [[NSMutableArray alloc] init];
MSGraphWindowsUpdatesUpdatableAsset *assets = [[MSGraphWindowsUpdatesUpdatableAsset alloc] init];
[assets setId:@"String (identifier)"];
[assetsList addObject: assets];
payloadDictionary[@"assets"] = assetsList;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
UpdateCategory updateCategory = UpdateCategory.FEATURE;
LinkedList<UpdatableAsset> assetsList = new LinkedList<UpdatableAsset>();
AzureADDevice assets = new AzureADDevice();
assets.id = "String (identifier)";
assetsList.add(assets);
UpdatableAssetCollectionResponse updatableAssetCollectionResponse = new UpdatableAssetCollectionResponse();
updatableAssetCollectionResponse.value = assetsList;
UpdatableAssetCollectionPage updatableAssetCollectionPage = new UpdatableAssetCollectionPage(updatableAssetCollectionResponse, null);
graphClient.admin().windows().updates().updatableAssets()
.enrollAssets(UpdatableAssetEnrollAssetsParameterSet
.newBuilder()
.withUpdateCategory(updateCategory)
.withAssets(assetsList)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
updateCategory := "String"
requestBody.SetUpdateCategory(&updateCategory)
requestBody.SetAssets( []UpdatableAsset {
msgraphsdk.NewUpdatableAsset(),
SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.windowsUpdates.azureADDevice",
"id": "String (identifier)",
}
}
graphClient.Admin().Windows().Updates().UpdatableAssets().EnrollAssets().Post(requestBody)
Import-Module Microsoft.Graph.WindowsUpdates
$params = @{
UpdateCategory = "String"
Assets = @(
@{
"@odata.type" = "#microsoft.graph.windowsUpdates.azureADDevice"
Id = "String (identifier)"
}
)
}
Invoke-MgEnrollWindowsUpdatesUpdatableAsset -BodyParameter $params
响应
HTTP/1.1 202 Accepted