예제 #1
0
        public async stt::Task AllocateQuotaRequestObjectAsync()
        {
            moq::Mock <QuotaController.QuotaControllerClient> mockGrpcClient = new moq::Mock <QuotaController.QuotaControllerClient>(moq::MockBehavior.Strict);
            AllocateQuotaRequest request = new AllocateQuotaRequest
            {
                ServiceName       = "service_named5df05d5",
                AllocateOperation = new QuotaOperation(),
                ServiceConfigId   = "service_config_id1616022f",
            };
            AllocateQuotaResponse expectedResponse = new AllocateQuotaResponse
            {
                OperationId    = "operation_id8a494117",
                AllocateErrors = { new QuotaError(), },
                QuotaMetrics   =
                {
                    new MetricValueSet(),
                },
                ServiceConfigId = "service_config_id1616022f",
            };

            mockGrpcClient.Setup(x => x.AllocateQuotaAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AllocateQuotaResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            QuotaControllerClient client = new QuotaControllerClientImpl(mockGrpcClient.Object, null);
            AllocateQuotaResponse responseCallSettings = await client.AllocateQuotaAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            AllocateQuotaResponse responseCancellationToken = await client.AllocateQuotaAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public void AllocateQuotaRequestObject()
        {
            moq::Mock <QuotaController.QuotaControllerClient> mockGrpcClient = new moq::Mock <QuotaController.QuotaControllerClient>(moq::MockBehavior.Strict);
            AllocateQuotaRequest request = new AllocateQuotaRequest
            {
                ServiceName       = "service_named5df05d5",
                AllocateOperation = new QuotaOperation(),
                ServiceConfigId   = "service_config_id1616022f",
            };
            AllocateQuotaResponse expectedResponse = new AllocateQuotaResponse
            {
                OperationId    = "operation_id8a494117",
                AllocateErrors = { new QuotaError(), },
                QuotaMetrics   =
                {
                    new MetricValueSet(),
                },
                ServiceConfigId = "service_config_id1616022f",
            };

            mockGrpcClient.Setup(x => x.AllocateQuota(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            QuotaControllerClient client   = new QuotaControllerClientImpl(mockGrpcClient.Object, null);
            AllocateQuotaResponse response = client.AllocateQuota(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
 /// <summary>Snippet for AllocateQuota</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void AllocateQuotaRequestObject()
 {
     // Create client
     QuotaControllerClient quotaControllerClient = QuotaControllerClient.Create();
     // Initialize request argument(s)
     AllocateQuotaRequest request = new AllocateQuotaRequest
     {
         ServiceName       = "",
         AllocateOperation = new QuotaOperation(),
         ServiceConfigId   = "",
     };
     // Make the request
     AllocateQuotaResponse response = quotaControllerClient.AllocateQuota(request);
 }
        /// <summary>Snippet for AllocateQuotaAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task AllocateQuotaRequestObjectAsync()
        {
            // Create client
            QuotaControllerClient quotaControllerClient = await QuotaControllerClient.CreateAsync();

            // Initialize request argument(s)
            AllocateQuotaRequest request = new AllocateQuotaRequest
            {
                ServiceName       = "",
                AllocateOperation = new QuotaOperation(),
                ServiceConfigId   = "",
            };
            // Make the request
            AllocateQuotaResponse response = await quotaControllerClient.AllocateQuotaAsync(request);
        }
예제 #5
0
        /// <summary>Snippet for AllocateQuotaAsync</summary>
        public async Task AllocateQuotaRequestObjectAsync()
        {
            // Snippet: AllocateQuotaAsync(AllocateQuotaRequest, CallSettings)
            // Additional: AllocateQuotaAsync(AllocateQuotaRequest, CancellationToken)
            // Create client
            QuotaControllerClient quotaControllerClient = await QuotaControllerClient.CreateAsync();

            // Initialize request argument(s)
            AllocateQuotaRequest request = new AllocateQuotaRequest
            {
                ServiceName       = "",
                AllocateOperation = new QuotaOperation(),
                ServiceConfigId   = "",
            };
            // Make the request
            AllocateQuotaResponse response = await quotaControllerClient.AllocateQuotaAsync(request);

            // End snippet
        }
 /// <summary>
 /// Attempts to allocate quota for the specified consumer. It should be called
 /// before the operation is executed.
 ///
 /// This method requires the `servicemanagement.services.quota`
 /// permission on the specified service. For more information, see
 /// [Cloud IAM](https://cloud.google.com/iam).
 ///
 /// **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
 /// `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
 /// reliability, the server may inject these errors to prohibit any hard
 /// dependency on the quota functionality.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <AllocateQuotaResponse> AllocateQuotaAsync(AllocateQuotaRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_AllocateQuotaRequest(ref request, ref callSettings);
     return(_callAllocateQuota.Async(request, callSettings));
 }
 /// <summary>
 /// Attempts to allocate quota for the specified consumer. It should be called
 /// before the operation is executed.
 ///
 /// This method requires the `servicemanagement.services.quota`
 /// permission on the specified service. For more information, see
 /// [Cloud IAM](https://cloud.google.com/iam).
 ///
 /// **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
 /// `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
 /// reliability, the server may inject these errors to prohibit any hard
 /// dependency on the quota functionality.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override AllocateQuotaResponse AllocateQuota(AllocateQuotaRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_AllocateQuotaRequest(ref request, ref callSettings);
     return(_callAllocateQuota.Sync(request, callSettings));
 }
 partial void Modify_AllocateQuotaRequest(ref AllocateQuotaRequest request, ref gaxgrpc::CallSettings settings);
 /// <summary>
 /// Attempts to allocate quota for the specified consumer. It should be called
 /// before the operation is executed.
 ///
 /// This method requires the `servicemanagement.services.quota`
 /// permission on the specified service. For more information, see
 /// [Cloud IAM](https://cloud.google.com/iam).
 ///
 /// **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
 /// `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
 /// reliability, the server may inject these errors to prohibit any hard
 /// dependency on the quota functionality.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <AllocateQuotaResponse> AllocateQuotaAsync(AllocateQuotaRequest request, st::CancellationToken cancellationToken) =>
 AllocateQuotaAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 /// <summary>
 /// Attempts to allocate quota for the specified consumer. It should be called
 /// before the operation is executed.
 ///
 /// This method requires the `servicemanagement.services.quota`
 /// permission on the specified service. For more information, see
 /// [Cloud IAM](https://cloud.google.com/iam).
 ///
 /// **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
 /// `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
 /// reliability, the server may inject these errors to prohibit any hard
 /// dependency on the quota functionality.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <AllocateQuotaResponse> AllocateQuotaAsync(AllocateQuotaRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// Attempts to allocate quota for the specified consumer. It should be called
 /// before the operation is executed.
 ///
 /// This method requires the `servicemanagement.services.quota`
 /// permission on the specified service. For more information, see
 /// [Cloud IAM](https://cloud.google.com/iam).
 ///
 /// **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
 /// `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
 /// reliability, the server may inject these errors to prohibit any hard
 /// dependency on the quota functionality.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual AllocateQuotaResponse AllocateQuota(AllocateQuotaRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
예제 #12
0
        /// <summary>
        /// Attempts to allocate quota for the specified consumer. It should be calledbefore the operation is executed.This method requires the `servicemanagement.services.quota`permission on the specified service. For more information, see[Cloud IAM](https://cloud.google.com/iam).**NOTE:** The client **must** fail-open on server errors `INTERNAL`,`UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure systemreliability, the server may inject these errors to prohibit any harddependency on the quota functionality.
        /// Documentation https://developers.google.com/servicecontrol/v1/reference/services/allocateQuota
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Servicecontrol service.</param>
        /// <param name="serviceName">Name of the service as specified in the service configuration. For example,`"pubsub.googleapis.com"`.See google.api.Service for the definition of a service name.</param>
        /// <param name="body">A valid Servicecontrol v1 body.</param>
        /// <returns>AllocateQuotaResponseResponse</returns>
        public static AllocateQuotaResponse AllocateQuota(ServicecontrolService service, string serviceName, AllocateQuotaRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (serviceName == null)
                {
                    throw new ArgumentNullException(serviceName);
                }

                // Make the request.
                return(service.Services.AllocateQuota(body, serviceName).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Services.AllocateQuota failed.", ex);
            }
        }