Share via


IDocumentClient.UpsertPermissionAsync Method

Definition

Overloads

UpsertPermissionAsync(String, Permission, RequestOptions)

Upserts a permission on a user object in the Azure Cosmos DB service as an asychronous operation.

UpsertPermissionAsync(Uri, Permission, RequestOptions)

Upserts a permission as an asychronous operation in the Azure Cosmos DB service.

UpsertPermissionAsync(String, Permission, RequestOptions)

Upserts a permission on a user object in the Azure Cosmos DB service as an asychronous operation.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>> UpsertPermissionAsync (string userLink, Microsoft.Azure.Documents.Permission permission, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertPermissionAsync : string * Microsoft.Azure.Documents.Permission * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>>
Public Function UpsertPermissionAsync (userLink As String, permission As Permission, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Permission))

Parameters

userLink
String

The link of the user to Upsert the permission for. E.g. dbs/db_rid/users/user_rid/

permission
Permission

The Permission object.

options
RequestOptions

(Optional) The request options for the request.

Returns

A task object representing the service response for the asynchronous operation which contains the upserted Permission object.

Exceptions

If either userLink or permission is not set.

Represents a consolidation of failures that occured during async processing. Look within InnerExceptions to find the actual exception(s)

This exception can encapsulate many different types of errors. To determine the specific error always look at the StatusCode property. Some common codes you may get when creating a Document are:

StatusCodeReason for exception
400BadRequest - This means something was wrong with the request supplied.
403Forbidden - You have reached your quota of permission objects. Contact support to have this quota increased.
409Conflict - This means a Permission with an id matching the id you supplied already existed.

Examples

//Upsert a read-only permission object for a specific user
Permission p = await client.UpsertPermissionAsync(userLink, new Permission { Id = "ReadPermission", PermissionMode = PermissionMode.Read });

See also

Applies to

UpsertPermissionAsync(Uri, Permission, RequestOptions)

Upserts a permission as an asychronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>> UpsertPermissionAsync (Uri userUri, Microsoft.Azure.Documents.Permission permission, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member UpsertPermissionAsync : Uri * Microsoft.Azure.Documents.Permission * Microsoft.Azure.Documents.Client.RequestOptions -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>>
Public Function UpsertPermissionAsync (userUri As Uri, permission As Permission, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Permission))

Parameters

userUri
Uri

The URI of the user to upsert the permission for.

permission
Permission

The Permission object.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

The task object representing the service response for the asynchronous operation.

Applies to