更新 deviceAndAppManagementRoleDefinition
本文内容
命名空间:microsoft.graph
注意: 适用于 Intune 的 Microsoft Graph API 需要适用于租户的活动 Intune 许可证 。
更新 deviceAndAppManagementRoleDefinition 对象的属性。
此 API 可用于以下国家级云部署 。
全局服务
美国政府 L4
美国政府 L5 (DOD)
由世纪互联运营的中国
✅
✅
✅
✅
权限
要调用此 API,需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
DeviceManagementRBAC.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
DeviceManagementRBAC.ReadWrite.All
HTTP 请求
PATCH /deviceManagement/roleDefinitions/{roleDefinitionId}
PATCH /deviceManagement/roleDefinitions/{roleDefinitionId}/roleAssignments/{roleAssignmentId}/roleDefinition
标头
值
Authorization
持有者 {token}。 必填。 详细了解 身份验证和授权 。
接受
application/json
请求正文
在请求正文中,提供 deviceAndAppManagementRoleDefinition 对象的 JSON 表示形式。
下表显示创建 deviceAndAppManagementRoleDefinition 时所需的属性。
响应
如果成功,此方法在响应正文中返回 200 OK
响应代码和更新的 deviceAndAppManagementRoleDefinition 对象。
示例
请求
下面是一个请求示例。
PATCH https://graph.microsoft.com/v1.0/deviceManagement/roleDefinitions/{roleDefinitionId}
Content-type: application/json
Content-length: 602
{
"@odata.type": "#microsoft.graph.deviceAndAppManagementRoleDefinition",
"displayName": "Display Name value",
"description": "Description value",
"rolePermissions": [
{
"@odata.type": "microsoft.graph.rolePermission",
"resourceActions": [
{
"@odata.type": "microsoft.graph.resourceAction",
"allowedResourceActions": [
"Allowed Resource Actions value"
],
"notAllowedResourceActions": [
"Not Allowed Resource Actions value"
]
}
]
}
],
"isBuiltIn": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceAndAppManagementRoleDefinition
{
OdataType = "#microsoft.graph.deviceAndAppManagementRoleDefinition",
DisplayName = "Display Name value",
Description = "Description value",
RolePermissions = new List<RolePermission>
{
new RolePermission
{
OdataType = "microsoft.graph.rolePermission",
ResourceActions = new List<ResourceAction>
{
new ResourceAction
{
OdataType = "microsoft.graph.resourceAction",
AllowedResourceActions = new List<string>
{
"Allowed Resource Actions value",
},
NotAllowedResourceActions = new List<string>
{
"Not Allowed Resource Actions value",
},
},
},
},
},
IsBuiltIn = true,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.RoleDefinitions["{roleDefinition-id}"].PatchAsync(requestBody);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
mgc device-management role-definitions patch --role-definition-id {roleDefinition-id} --body '{\
"@odata.type": "#microsoft.graph.deviceAndAppManagementRoleDefinition",\
"displayName": "Display Name value",\
"description": "Description value",\
"rolePermissions": [\
{\
"@odata.type": "microsoft.graph.rolePermission",\
"resourceActions": [\
{\
"@odata.type": "microsoft.graph.resourceAction",\
"allowedResourceActions": [\
"Allowed Resource Actions value"\
],\
"notAllowedResourceActions": [\
"Not Allowed Resource Actions value"\
]\
}\
]\
}\
],\
"isBuiltIn": true\
}\
'
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewRoleDefinition()
displayName := "Display Name value"
requestBody.SetDisplayName(&displayName)
description := "Description value"
requestBody.SetDescription(&description)
rolePermission := graphmodels.NewRolePermission()
resourceAction := graphmodels.NewResourceAction()
allowedResourceActions := []string {
"Allowed Resource Actions value",
}
resourceAction.SetAllowedResourceActions(allowedResourceActions)
notAllowedResourceActions := []string {
"Not Allowed Resource Actions value",
}
resourceAction.SetNotAllowedResourceActions(notAllowedResourceActions)
resourceActions := []graphmodels.ResourceActionable {
resourceAction,
}
rolePermission.SetResourceActions(resourceActions)
rolePermissions := []graphmodels.RolePermissionable {
rolePermission,
}
requestBody.SetRolePermissions(rolePermissions)
isBuiltIn := true
requestBody.SetIsBuiltIn(&isBuiltIn)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleDefinitions, err := graphClient.DeviceManagement().RoleDefinitions().ByRoleDefinitionId("roleDefinition-id").Patch(context.Background(), requestBody, nil)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceAndAppManagementRoleDefinition roleDefinition = new DeviceAndAppManagementRoleDefinition();
roleDefinition.setOdataType("#microsoft.graph.deviceAndAppManagementRoleDefinition");
roleDefinition.setDisplayName("Display Name value");
roleDefinition.setDescription("Description value");
LinkedList<RolePermission> rolePermissions = new LinkedList<RolePermission>();
RolePermission rolePermission = new RolePermission();
rolePermission.setOdataType("microsoft.graph.rolePermission");
LinkedList<ResourceAction> resourceActions = new LinkedList<ResourceAction>();
ResourceAction resourceAction = new ResourceAction();
resourceAction.setOdataType("microsoft.graph.resourceAction");
LinkedList<String> allowedResourceActions = new LinkedList<String>();
allowedResourceActions.add("Allowed Resource Actions value");
resourceAction.setAllowedResourceActions(allowedResourceActions);
LinkedList<String> notAllowedResourceActions = new LinkedList<String>();
notAllowedResourceActions.add("Not Allowed Resource Actions value");
resourceAction.setNotAllowedResourceActions(notAllowedResourceActions);
resourceActions.add(resourceAction);
rolePermission.setResourceActions(resourceActions);
rolePermissions.add(rolePermission);
roleDefinition.setRolePermissions(rolePermissions);
roleDefinition.setIsBuiltIn(true);
RoleDefinition result = graphClient.deviceManagement().roleDefinitions().byRoleDefinitionId("{roleDefinition-id}").patch(roleDefinition);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const roleDefinition = {
'@odata.type': '#microsoft.graph.deviceAndAppManagementRoleDefinition',
displayName: 'Display Name value',
description: 'Description value',
rolePermissions: [
{
'@odata.type': 'microsoft.graph.rolePermission',
resourceActions: [
{
'@odata.type': 'microsoft.graph.resourceAction',
allowedResourceActions: [
'Allowed Resource Actions value'
],
notAllowedResourceActions: [
'Not Allowed Resource Actions value'
]
}
]
}
],
isBuiltIn: true
};
await client.api('/deviceManagement/roleDefinitions/{roleDefinitionId}')
.update(roleDefinition);
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DeviceAndAppManagementRoleDefinition;
use Microsoft\Graph\Generated\Models\RolePermission;
use Microsoft\Graph\Generated\Models\ResourceAction;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceAndAppManagementRoleDefinition();
$requestBody->setOdataType('#microsoft.graph.deviceAndAppManagementRoleDefinition');
$requestBody->setDisplayName('Display Name value');
$requestBody->setDescription('Description value');
$rolePermissionsRolePermission1 = new RolePermission();
$rolePermissionsRolePermission1->setOdataType('microsoft.graph.rolePermission');
$resourceActionsResourceAction1 = new ResourceAction();
$resourceActionsResourceAction1->setOdataType('microsoft.graph.resourceAction');
$resourceActionsResourceAction1->setAllowedResourceActions(['Allowed Resource Actions value', ]);
$resourceActionsResourceAction1->setNotAllowedResourceActions(['Not Allowed Resource Actions value', ]);
$resourceActionsArray []= $resourceActionsResourceAction1;
$rolePermissionsRolePermission1->setResourceActions($resourceActionsArray);
$rolePermissionsArray []= $rolePermissionsRolePermission1;
$requestBody->setRolePermissions($rolePermissionsArray);
$requestBody->setIsBuiltIn(true);
$result = $graphServiceClient->deviceManagement()->roleDefinitions()->byRoleDefinitionId('roleDefinition-id')->patch($requestBody)->wait();
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.DeviceManagement.Administration
$params = @{
"@odata.type" = "#microsoft.graph.deviceAndAppManagementRoleDefinition"
displayName = "Display Name value"
description = "Description value"
rolePermissions = @(
@{
"@odata.type" = "microsoft.graph.rolePermission"
resourceActions = @(
@{
"@odata.type" = "microsoft.graph.resourceAction"
allowedResourceActions = @(
"Allowed Resource Actions value"
)
notAllowedResourceActions = @(
"Not Allowed Resource Actions value"
)
}
)
}
)
isBuiltIn = $true
}
Update-MgDeviceManagementRoleDefinition -RoleDefinitionId $roleDefinitionId -BodyParameter $params
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.device_and_app_management_role_definition import DeviceAndAppManagementRoleDefinition
from msgraph.generated.models.role_permission import RolePermission
from msgraph.generated.models.resource_action import ResourceAction
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceAndAppManagementRoleDefinition(
odata_type = "#microsoft.graph.deviceAndAppManagementRoleDefinition",
display_name = "Display Name value",
description = "Description value",
role_permissions = [
RolePermission(
odata_type = "microsoft.graph.rolePermission",
resource_actions = [
ResourceAction(
odata_type = "microsoft.graph.resourceAction",
allowed_resource_actions = [
"Allowed Resource Actions value",
],
not_allowed_resource_actions = [
"Not Allowed Resource Actions value",
],
),
],
),
],
is_built_in = True,
)
result = await graph_client.device_management.role_definitions.by_role_definition_id('roleDefinition-id').patch(request_body)
有关如何将 SDK 添加 到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档 。
响应
下面是一个响应示例。 注意:为简洁起见,可能会截断此处显示的响应对象。 将从实际调用中返回所有属性。
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 651
{
"@odata.type": "#microsoft.graph.deviceAndAppManagementRoleDefinition",
"id": "bca1dfb5-dfb5-bca1-b5df-a1bcb5dfa1bc",
"displayName": "Display Name value",
"description": "Description value",
"rolePermissions": [
{
"@odata.type": "microsoft.graph.rolePermission",
"resourceActions": [
{
"@odata.type": "microsoft.graph.resourceAction",
"allowedResourceActions": [
"Allowed Resource Actions value"
],
"notAllowedResourceActions": [
"Not Allowed Resource Actions value"
]
}
]
}
],
"isBuiltIn": true
}