コード例 #1
0
        public override Task <CosmosContainerResponse> DeleteAsync(
            CosmosContainerRequestOptions requestOptions = null,
            CancellationToken cancellationToken          = default(CancellationToken))
        {
            Task <CosmosResponseMessage> response = this.DeleteStreamAsync(
                requestOptions: requestOptions,
                cancellationToken: cancellationToken);

            return(this.Client.ResponseFactory.CreateContainerResponse(this, response));
        }
コード例 #2
0
 public override Task <CosmosResponseMessage> ReadStreamAsync(
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken))
 {
     return(this.ProcessStreamAsync(
                streamPayload: null,
                operationType: OperationType.Read,
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
コード例 #3
0
 /// <summary>
 /// Delete a <see cref="CosmosContainerSettings"/> from the Azure Cosmos DB service as an asynchronous operation.
 /// </summary>
 /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>A <see cref="Task"/> containing a <see cref="CosmosContainerResponse"/> which will contain information about the request issued.</returns>
 /// <exception cref="CosmosException">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:
 /// <list type="table">
 ///     <listheader>
 ///         <term>StatusCode</term><description>Reason for exception</description>
 ///     </listheader>
 ///     <item>
 ///         <term>404</term><description>NotFound - This means the resource you tried to delete did not exist.</description>
 ///     </item>
 /// </list>
 /// </exception>
 /// <example>
 /// <code language="c#">
 /// <![CDATA[
 /// CosmosContainer cosmosContainer = this.database.Containers["containerId"];
 /// CosmosContainerResponse response = cosmosContainer.DeleteAsync();
 ///]]>
 /// </code>
 /// </example>
 public virtual Task <CosmosContainerResponse> DeleteAsync(
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken))
 {
     return(ProcessAsync(
                null,
                operationType: OperationType.Delete,
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
コード例 #4
0
 /// <summary>
 /// Delete a <see cref="CosmosContainerSettings"/> from the Azure Cosmos DB service as an asynchronous operation.
 /// </summary>
 /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>A <see cref="Task"/> containing a <see cref="CosmosResponseMessage"/> which will contain information about the request issued.</returns>
 internal virtual Task <CosmosResponseMessage> DeleteStreamAsync(
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken))
 {
     return(this.ProcessStreamAsync(
                streamPayload: null,
                operationType: OperationType.Delete,
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
コード例 #5
0
        /// <summary>
        /// Replace a <see cref="CosmosContainerSettings"/> from the Azure Cosmos service as an asynchronous operation.
        /// </summary>
        /// <param name="containerSettings">The <see cref="CosmosContainerSettings"/> object.</param>
        /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
        /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
        /// <returns>
        /// A <see cref="Task"/> containing a <see cref="CosmosContainerResponse"/> which wraps a <see cref="CosmosContainerSettings"/> containing the replace resource record.
        /// </returns>
        /// <exception cref="CosmosException">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:
        /// <list type="table">
        ///     <listheader>
        ///         <term>StatusCode</term><description>Reason for exception</description>
        ///     </listheader>
        ///     <item>
        ///         <term>404</term><description>NotFound - This means the resource you tried to read did not exist.</description>
        ///     </item>
        ///     <item>
        ///         <term>429</term><description>TooManyRequests - This means you have exceeded the number of request units per second. Consult the DocumentClientException.RetryAfter value to see how long you should wait before retrying this operation.</description>
        ///     </item>
        /// </list>
        /// </exception>
        /// <example>
        /// Update the cosmosContainer to disable automatic indexing
        /// <code language="c#">
        /// <![CDATA[
        /// ContainerSettings setting = containerReadResponse;
        /// setting.IndexingPolicy.Automatic = false;
        /// CosmosContainerResponse response = cosmosContainer.ReplaceAsync(setting);
        /// ContainerSettings settings = response;
        /// ]]>
        /// </code>
        /// </example>
        public virtual Task <CosmosContainerResponse> ReplaceAsync(
            CosmosContainerSettings containerSettings,
            CosmosContainerRequestOptions requestOptions = null,
            CancellationToken cancellationToken          = default(CancellationToken))
        {
            this.Database.Client.DocumentClient.ValidateResource(containerSettings);

            return(ProcessAsync(
                       containerSettings,
                       operationType: OperationType.Replace,
                       requestOptions: requestOptions,
                       cancellationToken: cancellationToken));
        }
コード例 #6
0
        public override Task <CosmosContainerResponse> ReplaceAsync(
            CosmosContainerSettings containerSettings,
            CosmosContainerRequestOptions requestOptions = null,
            CancellationToken cancellationToken          = default(CancellationToken))
        {
            this.Client.DocumentClient.ValidateResource(containerSettings.Id);

            Task <CosmosResponseMessage> response = this.ReplaceStreamAsync(
                streamPayload: CosmosResource.ToStream(containerSettings),
                requestOptions: requestOptions,
                cancellationToken: cancellationToken);

            return(this.Client.ResponseFactory.CreateContainerResponse(this, response));
        }
コード例 #7
0
 private Task <CosmosResponseMessage> ProcessStreamAsync(
     Stream streamPayload,
     OperationType operationType,
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken))
 {
     return(ExecUtils.ProcessResourceOperationStreamAsync(
                client: this.Client,
                resourceUri: this.LinkUri,
                resourceType: ResourceType.Collection,
                operationType: operationType,
                partitionKey: null,
                streamPayload: streamPayload,
                requestOptions: requestOptions,
                requestEnricher: null,
                cancellationToken: cancellationToken));
 }
コード例 #8
0
 private Task <CosmosContainerResponse> ProcessAsync(
     CosmosContainerSettings containerSettings,
     OperationType operationType,
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken))
 {
     return(ExecUtils.ProcessResourceOperationAsync <CosmosContainerResponse>(
                this.Client,
                this.LinkUri,
                ResourceType.Collection,
                operationType,
                requestOptions,
                containerSettings?.GetResourceStream(),
                response =>
                this.Client.ResponseFactory.CreateContainerResponse(response, this),
                cancellationToken));
 }
コード例 #9
0
 /// <summary>
 /// Delete a <see cref="CosmosContainerSettings"/> from the Azure Cosmos DB service as an asynchronous operation.
 /// </summary>
 /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>A <see cref="Task"/> containing a <see cref="CosmosResponseMessage"/> which will contain information about the request issued.</returns>
 public abstract Task <CosmosResponseMessage> DeleteStreamAsync(
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken));
コード例 #10
0
 /// <summary>
 /// Replace a <see cref="CosmosContainerSettings"/> from the Azure Cosmos service as an asynchronous operation.
 /// </summary>
 /// <param name="streamPayload">The <see cref="Stream"/> object.</param>
 /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>
 /// A <see cref="Task"/> containing a <see cref="CosmosResponseMessage"/> containing the replace resource record.
 /// </returns>
 public abstract Task <CosmosResponseMessage> ReplaceStreamAsync(
     Stream streamPayload,
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken));
コード例 #11
0
 /// <summary>
 /// Replace a <see cref="CosmosContainerSettings"/> from the Azure Cosmos service as an asynchronous operation.
 /// </summary>
 /// <param name="containerSettings">The <see cref="CosmosContainerSettings"/> object.</param>
 /// <param name="requestOptions">(Optional) The options for the container request <see cref="CosmosRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>
 /// A <see cref="Task"/> containing a <see cref="CosmosContainerResponse"/> which wraps a <see cref="CosmosContainerSettings"/> containing the replace resource record.
 /// </returns>
 /// <exception cref="CosmosException">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:
 /// <list type="table">
 ///     <listheader>
 ///         <term>StatusCode</term><description>Reason for exception</description>
 ///     </listheader>
 ///     <item>
 ///         <term>404</term><description>NotFound - This means the resource you tried to read did not exist.</description>
 ///     </item>
 ///     <item>
 ///         <term>429</term><description>TooManyRequests - This means you have exceeded the number of request units per second. Consult the DocumentClientException.RetryAfter value to see how long you should wait before retrying this operation.</description>
 ///     </item>
 /// </list>
 /// </exception>
 /// <example>
 /// Update the cosmosContainer to disable automatic indexing
 /// <code language="c#">
 /// <![CDATA[
 /// ContainerSettings setting = containerReadResponse;
 /// setting.IndexingPolicy.Automatic = false;
 /// CosmosContainerResponse response = cosmosContainer.ReplaceAsync(setting);
 /// ContainerSettings settings = response;
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <CosmosContainerResponse> ReplaceAsync(
     CosmosContainerSettings containerSettings,
     CosmosContainerRequestOptions requestOptions = null,
     CancellationToken cancellationToken          = default(CancellationToken));