命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
创建用户 权限 对象,该对象将此权限添加到 fileStorageContainerType。 只有现有所有者 (容器类型的权限集合中具有owner角色的用户) 、SharePoint Embedded Administrators 或全局管理员可以添加权限。
以下约束适用:
- 每个容器类型最多允许 3 个权限。 添加第四个权限将返回错误
400 Bad Request 。
- 重复权限被视为幂等权限。 如果指定的用户已对容器类型具有权限,则服务不会做出任何更改,并在响应正文中返回状态
201 Created 的现有权限资源,即使未创建新的权限也是如此。
- 目前仅支持角色
owner 。
注意
- 来宾用户不能是容器类型权限的收件人。
- 来宾用户无法执行此操作。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
❌ |
❌ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
FileStorageContainerType.Manage.All |
不可用。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
不支持。 |
不支持。 |
HTTP 请求
POST /storage/fileStorage/containerTypes/{fileStorageContainerTypeId}/permissions
| 名称 |
说明 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
请求正文
在请求正文中,提供 权限 对象的 JSON 表示形式。
创建 权限时,可以指定以下属性。
| 属性 |
类型 |
说明 |
| grantedToV2 |
sharePointIdentitySet |
要向其授予权限的用户的标识。 仅支持具有 用户ID 的用户属性;不支持组和应用程序标识。 必填。 |
| 角色 |
String 集合 |
授予用户的角色。 目前仅 owner 支持。 必填。 |
响应
如果成功,此方法在 201 Created 响应正文中返回响应代码和 权限 对象。
如果请求超出每个容器类型三个权限的限制,此方法将 400 Bad Request 返回响应代码。
示例
请求
以下示例演示向容器类型添加所有者权限的请求。
POST https://graph.microsoft.com/beta/storage/fileStorage/containerTypes/de988700-d700-020e-0a00-0831f3042f00/permissions
Content-Type: application/json
{
"roles": ["owner"],
"grantedToV2": {
"user": {
"id": "11111111-1111-1111-1111-111111111111"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Permission
{
Roles = new List<string>
{
"owner",
},
GrantedToV2 = new SharePointIdentitySet
{
User = new Identity
{
Id = "11111111-1111-1111-1111-111111111111",
},
},
};
// To initialize your graphClient, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Storage.FileStorage.ContainerTypes["{fileStorageContainerType-id}"].Permissions.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewPermission()
roles := []string {
"owner",
}
requestBody.SetRoles(roles)
grantedToV2 := graphmodels.NewSharePointIdentitySet()
user := graphmodels.NewIdentity()
id := "11111111-1111-1111-1111-111111111111"
user.SetId(&id)
grantedToV2.SetUser(user)
requestBody.SetGrantedToV2(grantedToV2)
// To initialize your graphClient, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=go
permissions, err := graphClient.Storage().FileStorage().ContainerTypes().ByFileStorageContainerTypeId("fileStorageContainerType-id").Permissions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Permission permission = new Permission();
LinkedList<String> roles = new LinkedList<String>();
roles.add("owner");
permission.setRoles(roles);
SharePointIdentitySet grantedToV2 = new SharePointIdentitySet();
Identity user = new Identity();
user.setId("11111111-1111-1111-1111-111111111111");
grantedToV2.setUser(user);
permission.setGrantedToV2(grantedToV2);
Permission result = graphClient.storage().fileStorage().containerTypes().byFileStorageContainerTypeId("{fileStorageContainerType-id}").permissions().post(permission);
const options = {
authProvider,
};
const client = Client.init(options);
const permission = {
roles: ['owner'],
grantedToV2: {
user: {
id: '11111111-1111-1111-1111-111111111111'
}
}
};
await client.api('/storage/fileStorage/containerTypes/de988700-d700-020e-0a00-0831f3042f00/permissions')
.version('beta')
.post(permission);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\Permission;
use Microsoft\Graph\Beta\Generated\Models\SharePointIdentitySet;
use Microsoft\Graph\Beta\Generated\Models\Identity;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Permission();
$requestBody->setRoles(['owner', ]);
$grantedToV2 = new SharePointIdentitySet();
$grantedToV2User = new Identity();
$grantedToV2User->setId('11111111-1111-1111-1111-111111111111');
$grantedToV2->setUser($grantedToV2User);
$requestBody->setGrantedToV2($grantedToV2);
$result = $graphServiceClient->storage()->fileStorage()->containerTypes()->byFileStorageContainerTypeId('fileStorageContainerType-id')->permissions()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.permission import Permission
from msgraph_beta.generated.models.share_point_identity_set import SharePointIdentitySet
from msgraph_beta.generated.models.identity import Identity
# To initialize your graph_client, see https://dotnet.territoriali.olinfo.it/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Permission(
roles = [
"owner",
],
granted_to_v2 = SharePointIdentitySet(
user = Identity(
id = "11111111-1111-1111-1111-111111111111",
),
),
)
result = await graph_client.storage.file_storage.container_types.by_file_storage_container_type_id('fileStorageContainerType-id').permissions.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.permission",
"id": "b3duZXJfMTExMTExMTEtMTExMS0xMTExLTExMTEtMTExMTExMTExMTEx",
"roles": ["owner"],
"grantedToV2": {
"user": {
"id": "11111111-1111-1111-1111-111111111111"
}
}
}