Share via


IDocumentClient.ReplacePermissionAsync Method

Definition

Overloads

ReplacePermissionAsync(Permission, RequestOptions)

Replaces a Permission in the Azure Cosmos DB service as an asynchronous operation.

ReplacePermissionAsync(Uri, Permission, RequestOptions)

Replaces a permission as an asynchronous operation in the Azure Cosmos DB service.

ReplacePermissionAsync(Permission, RequestOptions)

Replaces a Permission in the Azure Cosmos DB service as an asynchronous operation.

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

Parameters

permission
Permission

The updated Permission to replace the existing resource with.

options
RequestOptions

(Optional) The request options for the request.

Returns

A System.Threading.Tasks containing a ResourceResponse<TResource> which wraps a Permission containing the updated resource record.

Exceptions

If permission is not set.

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
404NotFound - This means the resource you tried to delete did not exist.

Examples

//Fetch the resource to be updated
Permission permission = client.CreatePermissionQuery(permissionsLink)
                                    .Where(r => r.Id == "permission id")
                                    .AsEnumerable()
                                    .SingleOrDefault();

//Change the permission mode to All
permission.PermissionMode = PermissionMode.All;

//Now persist these changes to the database by replacing the original resource
Permission updated = await client.ReplacePermissionAsync(permission);

See also

Applies to

ReplacePermissionAsync(Uri, Permission, RequestOptions)

Replaces a permission as an asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Permission>> ReplacePermissionAsync (Uri permissionUri, Microsoft.Azure.Documents.Permission permission, Microsoft.Azure.Documents.Client.RequestOptions options = default);
abstract member ReplacePermissionAsync : 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 ReplacePermissionAsync (permissionUri As Uri, permission As Permission, Optional options As RequestOptions = Nothing) As Task(Of ResourceResponse(Of Permission))

Parameters

permissionUri
Uri

The URI for the permission to be updated.

permission
Permission

The updated permission.

options
RequestOptions

(Optional) The RequestOptions for the request.

Returns

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

Applies to