Пример #1
0
        /// <summary>
        /// Creates a Route resource in the specified project using the data included in the request.
        /// </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 lro::Operation <Operation, Operation> Insert(InsertRouteRequest request, gaxgrpc::CallSettings callSettings = null)
        {
            Modify_InsertRouteRequest(ref request, ref callSettings);
            Operation response = _callInsert.Sync(request, callSettings);
            GetGlobalOperationRequest pollRequest = GetGlobalOperationRequest.FromInitialResponse(response);

            request.PopulatePollRequestFields(pollRequest);
            return(new lro::Operation <Operation, Operation>(response.ToLroResponse(pollRequest.ToLroOperationName()), InsertOperationsClient));
        }
Пример #2
0
        /// <summary>
        /// Creates a Route resource in the specified project using the data included in the request.
        /// </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 async stt::Task <lro::Operation <Operation, Operation> > InsertAsync(InsertRouteRequest request, gaxgrpc::CallSettings callSettings = null)
        {
            Modify_InsertRouteRequest(ref request, ref callSettings);
            Operation response = await _callInsert.Async(request, callSettings).ConfigureAwait(false);

            GetGlobalOperationRequest pollRequest = GetGlobalOperationRequest.FromInitialResponse(response);

            request.PopulatePollRequestFields(pollRequest);
            return(new lro::Operation <Operation, Operation>(response.ToLroResponse(pollRequest.ToLroOperationName()), InsertOperationsClient));
        }
Пример #3
0
    public static async Task <Operation> PollUntilCompletedAsync(this Operation operation, string projectId)
    {
        GlobalOperationsClient operationsClient = await GlobalOperationsClient.CreateAsync();

        GetGlobalOperationRequest pollRequest = new GetGlobalOperationRequest
        {
            Operation = operation.Name,
            Project   = projectId,
        };

        async Task <Operation> Poller() => await operationsClient.GetAsync(pollRequest);

        return(await operation.PollUntilCompletedAsync(Poller));
    }
Пример #4
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetGlobalOperationRequest, CallSettings)
     // Create client
     GlobalOperationsClient globalOperationsClient = GlobalOperationsClient.Create();
     // Initialize request argument(s)
     GetGlobalOperationRequest request = new GetGlobalOperationRequest
     {
         Operation = "",
         Project   = "",
     };
     // Make the request
     Operation response = globalOperationsClient.Get(request);
     // End snippet
 }
Пример #5
0
        public async stt::Task GetAsync()
        {
            moq::Mock <GlobalOperations.GlobalOperationsClient> mockGrpcClient = new moq::Mock <GlobalOperations.GlobalOperationsClient>(moq::MockBehavior.Strict);
            GetGlobalOperationRequest request = new GetGlobalOperationRequest
            {
                Operation = "operation615a23f7",
                Project   = "projectaa6ff846",
            };
            Operation expectedResponse = new Operation
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = 6263187990225347157UL,
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Operation responseCancellationToken = await client.GetAsync(request.Project, request.Operation, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #6
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetGlobalOperationRequest, CallSettings)
            // Additional: GetAsync(GetGlobalOperationRequest, CancellationToken)
            // Create client
            GlobalOperationsClient globalOperationsClient = await GlobalOperationsClient.CreateAsync();

            // Initialize request argument(s)
            GetGlobalOperationRequest request = new GetGlobalOperationRequest
            {
                Operation = "",
                Project   = "",
            };
            // Make the request
            Operation response = await globalOperationsClient.GetAsync(request);

            // End snippet
        }
Пример #7
0
        public void Get()
        {
            moq::Mock <GlobalOperations.GlobalOperationsClient> mockGrpcClient = new moq::Mock <GlobalOperations.GlobalOperationsClient>(moq::MockBehavior.Strict);
            GetGlobalOperationRequest request = new GetGlobalOperationRequest
            {
                Operation = "operation615a23f7",
                Project   = "projectaa6ff846",
            };
            Operation expectedResponse = new Operation
            {
                Id   = "id74b70bb8",
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                User = "******",
                Zone = "zone255f4ea8",
                CreationTimestamp   = "creation_timestamp235e59a1",
                StartTime           = "start_timebd8dd9c4",
                OperationGroupId    = "operation_group_idd2040cf0",
                TargetLink          = "target_link9b435dc0",
                Progress            = 278622268,
                Error               = new Error(),
                EndTime             = "end_time89285d30",
                Region              = "regionedb20d96",
                OperationType       = "operation_typeece9e153",
                Status              = Operation.Types.Status.Pending,
                HttpErrorMessage    = "http_error_messageb5ef3c7f",
                TargetId            = "target_id16dfe255",
                ClientOperationId   = "client_operation_id4e51b631",
                StatusMessage       = "status_message2c618f86",
                HttpErrorStatusCode = 1766362655,
                Description         = "description2cf9da67",
                InsertTime          = "insert_time7467185a",
                SelfLink            = "self_link7e87f12d",
                Warnings            = { new Warnings(), },
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GlobalOperationsClient client = new GlobalOperationsClientImpl(mockGrpcClient.Object, null);
            Operation response            = client.Get(request.Project, request.Operation);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #8
0
 private Func <Operation> CreatePoller(Operation operation)
 {
     if (operation.HasRegion && !operation.HasZone)
     {
         RegionOperationsClient    client  = RegionOperationsClient.Create();
         GetRegionOperationRequest request = new GetRegionOperationRequest
         {
             Operation = operation.Name,
             Region    = Region,
             Project   = ProjectId,
         };
         return(() => client.Get(request));
     }
     else if (operation.HasZone && !operation.HasRegion)
     {
         ZoneOperationsClient    client  = ZoneOperationsClient.Create();
         GetZoneOperationRequest request = new GetZoneOperationRequest
         {
             Operation = operation.Name,
             Zone      = Zone,
             Project   = ProjectId,
         };
         return(() => client.Get(request));
     }
     else if (!operation.HasZone && !operation.HasRegion)
     {
         GlobalOperationsClient    client  = GlobalOperationsClient.Create();
         GetGlobalOperationRequest request = new GetGlobalOperationRequest
         {
             Operation = operation.Name,
             Project   = ProjectId,
         };
         return(() => client.Get(request));
     }
     throw new ArgumentException($"Unable to determine operation type for {operation}");
 }