/// <summary>Snippet for DeleteConnector</summary>
        public void DeleteConnectorRequestObject()
        {
            // Snippet: DeleteConnector(DeleteConnectorRequest, CallSettings)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.Create();
            // Initialize request argument(s)
            DeleteConnectorRequest request = new DeleteConnectorRequest
            {
                ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
            };
            // Make the request
            Operation <Empty, OperationMetadata> response = vpcAccessServiceClient.DeleteConnector(request);

            // Poll until the returned long-running operation is complete
            Operation <Empty, OperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Empty result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, OperationMetadata> retrievedResponse = vpcAccessServiceClient.PollOnceDeleteConnector(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Empty retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>Snippet for DeleteConnectorAsync</summary>
        public async Task DeleteConnectorResourceNamesAsync()
        {
            // Snippet: DeleteConnectorAsync(ConnectorName, CallSettings)
            // Additional: DeleteConnectorAsync(ConnectorName, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            ConnectorName name = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
            // Make the request
            Operation <Empty, OperationMetadata> response = await vpcAccessServiceClient.DeleteConnectorAsync(name);

            // Poll until the returned long-running operation is complete
            Operation <Empty, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Empty result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, OperationMetadata> retrievedResponse = await vpcAccessServiceClient.PollOnceDeleteConnectorAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Empty retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
示例#3
0
        public void GetConnector()
        {
            moq::Mock <VpcAccessService.VpcAccessServiceClient> mockGrpcClient = new moq::Mock <VpcAccessService.VpcAccessServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetConnectorRequest request = new GetConnectorRequest
            {
                ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
            };
            Connector expectedResponse = new Connector
            {
                ConnectorName     = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
                Network           = "networkd22ce091",
                IpCidrRange       = "ip_cidr_range745a04d3",
                State             = Connector.Types.State.Unspecified,
                MinThroughput     = -1306078102,
                MaxThroughput     = 1609945563,
                ConnectedProjects =
                {
                    "connected_projects7e2fb014",
                },
                Subnet = new Connector.Types.Subnet(),
            };

            mockGrpcClient.Setup(x => x.GetConnector(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            VpcAccessServiceClient client = new VpcAccessServiceClientImpl(mockGrpcClient.Object, null);
            Connector response            = client.GetConnector(request.Name);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#4
0
        public async stt::Task GetConnectorRequestObjectAsync()
        {
            moq::Mock <VpcAccessService.VpcAccessServiceClient> mockGrpcClient = new moq::Mock <VpcAccessService.VpcAccessServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetConnectorRequest request = new GetConnectorRequest
            {
                ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
            };
            Connector expectedResponse = new Connector
            {
                ConnectorName     = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
                Network           = "networkd22ce091",
                IpCidrRange       = "ip_cidr_range745a04d3",
                State             = Connector.Types.State.Unspecified,
                MinThroughput     = -1306078102,
                MaxThroughput     = 1609945563,
                ConnectedProjects =
                {
                    "connected_projects7e2fb014",
                },
                Subnet = new Connector.Types.Subnet(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for GetConnector</summary>
 public void GetConnectorResourceNames()
 {
     // Snippet: GetConnector(ConnectorName, CallSettings)
     // Create client
     VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.Create();
     // Initialize request argument(s)
     ConnectorName name = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
     // Make the request
     Connector response = vpcAccessServiceClient.GetConnector(name);
     // End snippet
 }
        /// <summary>Snippet for GetConnectorAsync</summary>
        public async Task GetConnectorResourceNamesAsync()
        {
            // Snippet: GetConnectorAsync(ConnectorName, CallSettings)
            // Additional: GetConnectorAsync(ConnectorName, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            ConnectorName name = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
            // Make the request
            Connector response = await vpcAccessServiceClient.GetConnectorAsync(name);

            // End snippet
        }
 /// <summary>Snippet for GetConnector</summary>
 public void GetConnectorRequestObject()
 {
     // Snippet: GetConnector(GetConnectorRequest, CallSettings)
     // Create client
     VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.Create();
     // Initialize request argument(s)
     GetConnectorRequest request = new GetConnectorRequest
     {
         ConnectorName = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]"),
     };
     // Make the request
     Connector response = vpcAccessServiceClient.GetConnector(request);
     // End snippet
 }