更新 allowedValue
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 allowedValue 对象 的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
CustomSecAttributeDefinition.ReadWrite.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| 应用程序 |
CustomSecAttributeDefinition.ReadWrite.All |
还必须为登录用户分配属性定义管理员 目录角色。 默认情况下,全局管理员和其他管理员角色没有读取、定义或分配自定义安全属性的权限。
HTTP 请求
PATCH /directory/customSecurityAttributeDefinitions/{customSecurityAttributeDefinitionId}/allowedValues/{allowedValueId}
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,仅 提供应更新的属性的值。未包含在请求正文中的现有属性将保留其以前的值或根据对其他属性值的更改重新计算。
下表指定可更新的属性。
| 属性 |
类型 |
说明 |
| isActive |
布尔 |
指示预定义值是处于活动状态还是已停用。 如果设置为 false ,则此预定义值不能分配给任何其他受支持的目录对象。 可选。 |
响应
如果成功,此方法返回 204 No Content 响应代码。
示例
示例:停用预定义值
以下示例停用自定义安全属性定义的预定义值。
- 属性集:
Engineering
- 属性:
Project
- 预定义值:
Alpine
请求
PATCH https://graph.microsoft.com/beta/directory/customSecurityAttributeDefinitions/Engineering_Project/allowedValues/Alpine
Content-Type: application/json
Content-length: 80
{
"isActive": "false"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var allowedValue = new AllowedValue
{
IsActive = false
};
await graphClient.Directory.CustomSecurityAttributeDefinitions["{customSecurityAttributeDefinition-id}"].AllowedValues["{allowedValue-id}"]
.Request()
.UpdateAsync(allowedValue);
const options = {
authProvider,
};
const client = Client.init(options);
const allowedValue = {
isActive: 'false'
};
await client.api('/directory/customSecurityAttributeDefinitions/Engineering_Project/allowedValues/Alpine')
.version('beta')
.update(allowedValue);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/directory/customSecurityAttributeDefinitions/Engineering_Project/allowedValues/Alpine"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphAllowedValue *allowedValue = [[MSGraphAllowedValue alloc] init];
[allowedValue setIsActive:@"false"];
NSError *error;
NSData *allowedValueData = [allowedValue getSerializedDataWithError:&error];
[urlRequest setHTTPBody:allowedValueData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
AllowedValue allowedValue = new AllowedValue();
allowedValue.isActive = false;
graphClient.directory().customSecurityAttributeDefinitions("Engineering_Project").allowedValues("Alpine")
.buildRequest()
.patch(allowedValue);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewAllowedValue()
isActive := "false"
requestBody.SetIsActive(&isActive)
customSecurityAttributeDefinitionId := "customSecurityAttributeDefinition-id"
allowedValueId := "allowedValue-id"
graphClient.Directory().CustomSecurityAttributeDefinitionsById(&customSecurityAttributeDefinitionId).AllowedValuesById(&allowedValueId).Patch(requestBody)
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
IsActive = "false"
}
Update-MgDirectoryCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId $customSecurityAttributeDefinitionId -AllowedValueId $allowedValueId -BodyParameter $params
响应
HTTP/1.1 204 No Content