예제 #1
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, TargetTcpProxy, CallSettings)
            // Additional: InsertAsync(string, TargetTcpProxy, CancellationToken)
            // Create client
            TargetTcpProxiesClient targetTcpProxiesClient = await TargetTcpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            TargetTcpProxy targetTcpProxyResource = new TargetTcpProxy();
            // Make the request
            lro::Operation <Operation, Operation> response = await targetTcpProxiesClient.InsertAsync(project, targetTcpProxyResource);

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

            // Retrieve the operation result
            Operation 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
            lro::Operation <Operation, Operation> retrievedResponse = await targetTcpProxiesClient.PollOnceInsertAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
예제 #2
0
        /// <summary>
        /// Creates a TargetTcpProxy resource in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/alpha/reference/targetTcpProxies/insert
        /// 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 Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="body">A valid Compute alpha body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(ComputeService service, string project, TargetTcpProxy body, TargetTcpProxiesInsertOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }

                // Building the initial request.
                var request = service.TargetTcpProxies.Insert(body, project);

                // Applying optional parameters to the request.
                request = (TargetTcpProxiesResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetTcpProxies.Insert failed.", ex);
            }
        }
        public void Get()
        {
            moq::Mock <TargetTcpProxies.TargetTcpProxiesClient> mockGrpcClient = new moq::Mock <TargetTcpProxies.TargetTcpProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetTcpProxyRequest request = new GetTargetTcpProxyRequest
            {
                Project        = "projectaa6ff846",
                TargetTcpProxy = "target_tcp_proxy074a59b9",
            };
            TargetTcpProxy expectedResponse = new TargetTcpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                ProxyHeader       = "proxy_headercff40018",
                ProxyBind         = false,
                Service           = "serviced3f0abaa",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <TargetTcpProxies.TargetTcpProxiesClient> mockGrpcClient = new moq::Mock <TargetTcpProxies.TargetTcpProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetTcpProxyRequest request = new GetTargetTcpProxyRequest
            {
                Project        = "projectaa6ff846",
                TargetTcpProxy = "target_tcp_proxy074a59b9",
            };
            TargetTcpProxy expectedResponse = new TargetTcpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                ProxyHeader       = "proxy_headercff40018",
                ProxyBind         = false,
                Service           = "serviced3f0abaa",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Creates a TargetTcpProxy resource in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/alpha/reference/targetTcpProxies/insert
        /// 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 compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="body">A valid compute alpha body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(computeService service, string project, TargetTcpProxy body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }

                // Make the request.
                return(service.TargetTcpProxies.Insert(body, project).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetTcpProxies.Insert failed.", ex);
            }
        }
예제 #6
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, CallSettings)
     // Create client
     TargetTcpProxiesClient targetTcpProxiesClient = TargetTcpProxiesClient.Create();
     // Initialize request argument(s)
     string project        = "";
     string targetTcpProxy = "";
     // Make the request
     TargetTcpProxy response = targetTcpProxiesClient.Get(project, targetTcpProxy);
     // End snippet
 }
예제 #7
0
 /// <summary>Snippet for Insert</summary>
 public void Insert()
 {
     // Snippet: Insert(string, TargetTcpProxy, CallSettings)
     // Create client
     TargetTcpProxiesClient targetTcpProxiesClient = TargetTcpProxiesClient.Create();
     // Initialize request argument(s)
     string         project = "";
     TargetTcpProxy targetTcpProxyResource = new TargetTcpProxy();
     // Make the request
     Operation response = targetTcpProxiesClient.Insert(project, targetTcpProxyResource);
     // End snippet
 }
예제 #8
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, CallSettings)
            // Additional: GetAsync(string, string, CancellationToken)
            // Create client
            TargetTcpProxiesClient targetTcpProxiesClient = await TargetTcpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string project        = "";
            string targetTcpProxy = "";
            // Make the request
            TargetTcpProxy response = await targetTcpProxiesClient.GetAsync(project, targetTcpProxy);

            // End snippet
        }
예제 #9
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetTargetTcpProxyRequest, CallSettings)
     // Create client
     TargetTcpProxiesClient targetTcpProxiesClient = TargetTcpProxiesClient.Create();
     // Initialize request argument(s)
     GetTargetTcpProxyRequest request = new GetTargetTcpProxyRequest
     {
         Project        = "",
         TargetTcpProxy = "",
     };
     // Make the request
     TargetTcpProxy response = targetTcpProxiesClient.Get(request);
     // End snippet
 }
예제 #10
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, TargetTcpProxy, CallSettings)
            // Additional: InsertAsync(string, TargetTcpProxy, CancellationToken)
            // Create client
            TargetTcpProxiesClient targetTcpProxiesClient = await TargetTcpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            TargetTcpProxy targetTcpProxyResource = new TargetTcpProxy();
            // Make the request
            Operation response = await targetTcpProxiesClient.InsertAsync(project, targetTcpProxyResource);

            // End snippet
        }
예제 #11
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetTargetTcpProxyRequest, CallSettings)
            // Additional: GetAsync(GetTargetTcpProxyRequest, CancellationToken)
            // Create client
            TargetTcpProxiesClient targetTcpProxiesClient = await TargetTcpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            GetTargetTcpProxyRequest request = new GetTargetTcpProxyRequest
            {
                Project        = "",
                TargetTcpProxy = "",
            };
            // Make the request
            TargetTcpProxy response = await targetTcpProxiesClient.GetAsync(request);

            // End snippet
        }