public override Task <UserDefinedFunctionResponse> ReplaceUserDefinedFunctionAsync( CosmosUserDefinedFunctionProperties userDefinedFunctionSettings, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { if (userDefinedFunctionSettings == null) { throw new ArgumentNullException(nameof(userDefinedFunctionSettings)); } if (string.IsNullOrEmpty(userDefinedFunctionSettings.Id)) { throw new ArgumentNullException(nameof(userDefinedFunctionSettings.Id)); } if (string.IsNullOrEmpty(userDefinedFunctionSettings.Body)) { throw new ArgumentNullException(nameof(userDefinedFunctionSettings.Body)); } return(this.ProcessUserDefinedFunctionOperationAsync( id: userDefinedFunctionSettings.Id, operationType: OperationType.Replace, streamPayload: CosmosResource.ToStream(userDefinedFunctionSettings), requestOptions: requestOptions, cancellationToken: cancellationToken)); }
/// <summary> /// Replaces a <see cref="CosmosUserDefinedFunctionProperties"/> in the Azure Cosmos DB service as an asynchronous operation. /// </summary> /// <param name="userDefinedFunctionSettings">The <see cref="CosmosUserDefinedFunctionProperties"/> object.</param> /// <param name="requestOptions">(Optional) The options for the user defined function request <see cref="RequestOptions"/></param> /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param> /// <returns> /// A <see cref="Task"/> containing a <see cref="UserDefinedFunctionResponse"/> which wraps a <see cref="CosmosUserDefinedFunctionProperties"/> containing the updated resource record. /// </returns> /// <example> /// This examples replaces an existing user defined function. /// <code language="c#"> /// <![CDATA[ /// CosmosScripts scripts = this.container.GetScripts(); /// //Updated settings /// CosmosUserDefinedFunctionSettings settings = new CosmosUserDefinedFunctionSettings /// { /// Id = "testUserDefinedFunId", /// Body = "function(amt) { return amt * 0.15; }", /// }; /// /// UserDefinedFunctionResponse response = await scripts.ReplaceUserDefinedFunctionAsync(settings); /// CosmosUserDefinedFunctionSettings settings = response; /// ]]> /// </code> /// </example> public abstract Task <UserDefinedFunctionResponse> ReplaceUserDefinedFunctionAsync( CosmosUserDefinedFunctionProperties userDefinedFunctionSettings, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken));