更新属性集
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 attributeSet 对象 的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
CustomSecAttributeDefinition.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
CustomSecAttributeDefinition.ReadWrite.All
还必须为登录用户分配属性定义管理员 目录角色 。 默认情况下,全局管理员和其他管理员角色没有读取、定义或分配自定义安全属性的权限。
HTTP 请求
PATCH /directory/attributeSets/{attributeSetId}
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,仅 提供应更新的属性的值。未包含在请求正文中的现有属性将保留其以前的值或根据对其他属性值的更改重新计算。
下表指定可更新的属性。
属性
类型
说明
说明
String
属性集的说明。 可最多为 128 个字符,并且包含 Unicode 字符。 可选。
maxAttributesPerSet
Int32
可以在此属性集内定义的自定义安全属性的最大数量。 默认值为 null。 如果未指定,则管理员最多可以添加每个租户 500 个活动属性。 可选。
响应
如果成功,此方法返回 204 No Content 响应代码。
示例
示例:更新属性集
下面的示例更新名为 的属性集的说明和最大属性数 Engineering 。
请求
PATCH https://graph.microsoft.com/beta/directory/attributeSets/Engineering
Content-Type: application/json
Content-length: 119
{
"description":"Attributes for engineering team",
"maxAttributesPerSet":20
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var attributeSet = new AttributeSet
{
Description = "Attributes for engineering team",
MaxAttributesPerSet = 20
};
await graphClient.Directory.AttributeSets["{attributeSet-id}"]
.Request()
.UpdateAsync(attributeSet);
const options = {
authProvider,
};
const client = Client.init(options);
const attributeSet = {
description: 'Attributes for engineering team',
maxAttributesPerSet: 20
};
await client.api('/directory/attributeSets/Engineering')
.version('beta')
.update(attributeSet);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/directory/attributeSets/Engineering"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphAttributeSet *attributeSet = [[MSGraphAttributeSet alloc] init];
[attributeSet setDescription:@"Attributes for engineering team"];
[attributeSet setMaxAttributesPerSet: 20];
NSError *error;
NSData *attributeSetData = [attributeSet getSerializedDataWithError:&error];
[urlRequest setHTTPBody:attributeSetData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
AttributeSet attributeSet = new AttributeSet();
attributeSet.description = "Attributes for engineering team";
attributeSet.maxAttributesPerSet = 20;
graphClient.directory().attributeSets("Engineering")
.buildRequest()
.patch(attributeSet);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewAttributeSet()
description := "Attributes for engineering team"
requestBody.SetDescription(&description)
maxAttributesPerSet := int32(20)
requestBody.SetMaxAttributesPerSet(&maxAttributesPerSet)
attributeSetId := "attributeSet-id"
graphClient.Directory().AttributeSetsById(&attributeSetId).Patch(requestBody)
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
Description = "Attributes for engineering team"
MaxAttributesPerSet = 20
}
Update-MgDirectoryAttributeSet -AttributeSetId $attributeSetId -BodyParameter $params
响应
HTTP/1.1 204 No Content