Beispiel #1
0
 public override Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default)
 {
     return(TaskHelper.RunInlineIfNeededAsync(() => this.scripts.ReplaceStoredProcedureAsync(storedProcedureProperties, requestOptions, cancellationToken)));
 }
Beispiel #2
0
 public override Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default)
 {
     return(this.ClientContext.OperationHelperAsync(
                nameof(ReplaceStoredProcedureAsync),
                requestOptions,
                (diagnostics) => base.ReplaceStoredProcedureAsync(diagnostics, storedProcedureProperties, requestOptions, cancellationToken)));
 }
 public override Task <StoredProcedureResponse> CreateStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default)
 {
     return(this.ClientContext.OperationHelperAsync(
                nameof(CreateStoredProcedureAsync),
                requestOptions,
                (trace) => base.CreateStoredProcedureAsync(storedProcedureProperties, requestOptions, trace, cancellationToken)));
 }
 public override Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default)
 {
     return(this.ClientContext.OperationHelperAsync(
                nameof(ReplaceStoredProcedureAsync),
                requestOptions,
                (trace) => base.ReplaceStoredProcedureAsync(storedProcedureProperties, requestOptions, trace, cancellationToken),
                (response) => new OpenTelemetryResponse <StoredProcedureProperties>(response)));
 }
 public override Task <StoredProcedureResponse> CreateStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.ProcessStoredProcedureOperationAsync(
                linkUri: this.container.LinkUri,
                operationType: OperationType.Create,
                streamPayload: this.clientContext.SerializerCore.ToStream(storedProcedureProperties),
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
Beispiel #6
0
 public override Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.ProcessStoredProcedureOperationAsync(
                id: storedProcedureProperties.Id,
                operationType: OperationType.Replace,
                streamPayload: this.clientContext.PropertiesSerializer.ToStream(storedProcedureProperties),
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
 public Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     CosmosDiagnosticsContext diagnosticsContext,
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions,
     CancellationToken cancellationToken)
 {
     return(this.ProcessStoredProcedureOperationAsync(
                diagnosticsContext: diagnosticsContext,
                id: storedProcedureProperties.Id,
                operationType: OperationType.Replace,
                streamPayload: this.ClientContext.SerializerCore.ToStream(storedProcedureProperties),
                requestOptions: requestOptions,
                cancellationToken: cancellationToken));
 }
 public Task <StoredProcedureResponse> ReplaceStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions,
     ITrace trace,
     CancellationToken cancellationToken)
 {
     return(this.ProcessStoredProcedureOperationAsync(
                id: storedProcedureProperties.Id,
                operationType: OperationType.Replace,
                streamPayload: this.ClientContext.SerializerCore.ToStream(storedProcedureProperties),
                requestOptions: requestOptions,
                trace: trace,
                cancellationToken: cancellationToken));
 }
 public Task <StoredProcedureResponse> CreateStoredProcedureAsync(
     CosmosDiagnosticsContext diagnosticsContext,
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions,
     CancellationToken cancellationToken)
 {
     return(this.ProcessScriptsCreateOperationAsync(
                diagnosticsContext: diagnosticsContext,
                resourceUri: this.container.LinkUri,
                resourceType: ResourceType.StoredProcedure,
                operationType: OperationType.Create,
                streamPayload: this.ClientContext.SerializerCore.ToStream(storedProcedureProperties),
                requestOptions: requestOptions,
                responseFunc: this.ClientContext.ResponseFactory.CreateStoredProcedureResponse,
                cancellationToken: cancellationToken));
 }
 /// <summary>
 /// Creates a stored procedure as an asynchronous operation in the Azure Cosmos DB service.
 /// </summary>
 /// <param name="storedProcedureProperties">The Stored Procedure to create</param>
 /// <param name="requestOptions">(Optional) The options for the stored procedure request <see cref="RequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>The <see cref="StoredProcedureProperties"/> that was created contained within a <see cref="Task"/> object representing the service response for the asynchronous operation.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="storedProcedureProperties"/> is not set.</exception>
 /// <exception cref="System.AggregateException">Represents a consolidation of failures that occurred during async processing. Look within InnerExceptions to find the actual exception(s)</exception>
 /// <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>400</term><description>BadRequest - This means something was wrong with the request supplied. It is likely that an Id was not supplied for the stored procedure or the Body was malformed.</description>
 ///     </item>
 ///     <item>
 ///         <term>403</term><description>Forbidden - You have reached your quota of stored procedures for the collection supplied. Contact support to have this quota increased.</description>
 ///     </item>
 ///     <item>
 ///         <term>409</term><description>Conflict - This means a <see cref="StoredProcedureProperties"/> with an id matching the id you supplied already existed.</description>
 ///     </item>
 ///     <item>
 ///         <term>413</term><description>RequestEntityTooLarge - This means the body of the <see cref="StoredProcedureProperties"/> you tried to create was too large.</description>
 ///     </item>
 /// </list>
 /// </exception>
 /// <example>
 ///  This creates and executes a stored procedure that appends a string to the first item returned from the query.
 /// <code language="c#">
 /// <![CDATA[
 /// string sprocBody = @"function simple(prefix)
 ///    {
 ///        var collection = getContext().getCollection();
 ///
 ///        // Query documents and take 1st item.
 ///        var isAccepted = collection.queryDocuments(
 ///        collection.getSelfLink(),
 ///        'SELECT * FROM root r',
 ///        function(err, feed, options) {
 ///            if (err)throw err;
 ///
 ///            // Check the feed and if it's empty, set the body to 'no docs found',
 ///            // Otherwise just take 1st element from the feed.
 ///            if (!feed || !feed.length) getContext().getResponse().setBody(""no docs found"");
 ///            else getContext().getResponse().setBody(prefix + JSON.stringify(feed[0]));
 ///        });
 ///
 ///        if (!isAccepted) throw new Error(""The query wasn't accepted by the server. Try again/use continuation token between API and script."");
 ///    }";
 ///
 /// Scripts scripts = this.container.GetScripts();
 /// StoredProcedureProperties storedProcedure = new StoredProcedureProperties(id, sprocBody);
 /// CosmosStoredProcedure cosmosStoredProcedure = await scripts.CreateStoredProcedureAsync(storedProcedure);
 ///
 /// // Execute the stored procedure
 /// CosmosItemResponse<string> sprocResponse = await scripts.ExecuteStoredProcedureAsync<string, string>(testPartitionId, "appendString", "Item as a string: ");
 /// Console.WriteLine("sprocResponse.Resource");
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <StoredProcedureResponse> CreateStoredProcedureAsync(
     StoredProcedureProperties storedProcedureProperties,
     RequestOptions requestOptions       = null,
     CancellationToken cancellationToken = default(CancellationToken));