示例#1
0
        public void Get()
        {
            moq::Mock <TargetHttpProxies.TargetHttpProxiesClient> mockGrpcClient = new moq::Mock <TargetHttpProxies.TargetHttpProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
            {
                TargetHttpProxy = "target_http_proxy02d2fd7b",
                Project         = "projectaa6ff846",
            };
            TargetHttpProxy expectedResponse = new TargetHttpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Fingerprint       = "fingerprint009e6052",
                ProxyBind         = false,
                UrlMap            = "url_map3ccdbf57",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for PatchAsync</summary>
        public async Task PatchAsync()
        {
            // Snippet: PatchAsync(string, string, TargetHttpProxy, CallSettings)
            // Additional: PatchAsync(string, string, TargetHttpProxy, CancellationToken)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = await TargetHttpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string          project                 = "";
            string          targetHttpProxy         = "";
            TargetHttpProxy targetHttpProxyResource = new TargetHttpProxy();
            // Make the request
            lro::Operation <Operation, Operation> response = await targetHttpProxiesClient.PatchAsync(project, targetHttpProxy, targetHttpProxyResource);

            // 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 targetHttpProxiesClient.PollOncePatchAsync(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
        }
        /// <summary>Snippet for Insert</summary>
        public void Insert()
        {
            // Snippet: Insert(string, TargetHttpProxy, CallSettings)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = TargetHttpProxiesClient.Create();
            // Initialize request argument(s)
            string          project = "";
            TargetHttpProxy targetHttpProxyResource = new TargetHttpProxy();
            // Make the request
            lro::Operation <Operation, Operation> response = targetHttpProxiesClient.Insert(project, targetHttpProxyResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = response.PollUntilCompleted();
            // 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 = targetHttpProxiesClient.PollOnceInsert(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
        }
示例#4
0
        /// <summary>
        /// Creates a TargetHttpProxy resource in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/beta/reference/targetHttpProxies/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 beta body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(ComputeService service, string project, TargetHttpProxy body, TargetHttpProxiesInsertOptionalParms 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.TargetHttpProxies.Insert(body, project);

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

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetHttpProxies.Insert failed.", ex);
            }
        }
        /// <summary>
        /// Creates a TargetHttpProxy resource in the specified project using the data included in the request.
        /// Documentation https://developers.google.com/compute/beta/reference/targetHttpProxies/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 beta body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Insert(computeService service, string project, TargetHttpProxy 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.TargetHttpProxies.Insert(body, project).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetHttpProxies.Insert failed.", ex);
            }
        }
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <RegionTargetHttpProxies.RegionTargetHttpProxiesClient> mockGrpcClient = new moq::Mock <RegionTargetHttpProxies.RegionTargetHttpProxiesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetRegionTargetHttpProxyRequest request = new GetRegionTargetHttpProxyRequest
            {
                Region          = "regionedb20d96",
                TargetHttpProxy = "target_http_proxy02d2fd7b",
                Project         = "projectaa6ff846",
            };
            TargetHttpProxy expectedResponse = new TargetHttpProxy
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                CreationTimestamp = "creation_timestamp235e59a1",
                Region            = "regionedb20d96",
                Fingerprint       = "fingerprint009e6052",
                ProxyBind         = false,
                UrlMap            = "url_map3ccdbf57",
                Description       = "description2cf9da67",
                SelfLink          = "self_link7e87f12d",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#7
0
 /// <summary>Snippet for Insert</summary>
 public void Insert()
 {
     // Snippet: Insert(string, TargetHttpProxy, CallSettings)
     // Create client
     TargetHttpProxiesClient targetHttpProxiesClient = TargetHttpProxiesClient.Create();
     // Initialize request argument(s)
     string          project = "";
     TargetHttpProxy targetHttpProxyResource = new TargetHttpProxy();
     // Make the request
     Operation response = targetHttpProxiesClient.Insert(project, targetHttpProxyResource);
     // End snippet
 }
示例#8
0
 /// <summary>Snippet for Get</summary>
 public void Get()
 {
     // Snippet: Get(string, string, CallSettings)
     // Create client
     TargetHttpProxiesClient targetHttpProxiesClient = TargetHttpProxiesClient.Create();
     // Initialize request argument(s)
     string project         = "";
     string targetHttpProxy = "";
     // Make the request
     TargetHttpProxy response = targetHttpProxiesClient.Get(project, targetHttpProxy);
     // End snippet
 }
示例#9
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, TargetHttpProxy, CallSettings)
            // Additional: InsertAsync(string, TargetHttpProxy, CancellationToken)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = await TargetHttpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string          project = "";
            TargetHttpProxy targetHttpProxyResource = new TargetHttpProxy();
            // Make the request
            Operation response = await targetHttpProxiesClient.InsertAsync(project, targetHttpProxyResource);

            // End snippet
        }
示例#10
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, CallSettings)
            // Additional: GetAsync(string, string, CancellationToken)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = await TargetHttpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            string project         = "";
            string targetHttpProxy = "";
            // Make the request
            TargetHttpProxy response = await targetHttpProxiesClient.GetAsync(project, targetHttpProxy);

            // End snippet
        }
示例#11
0
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetTargetHttpProxyRequest, CallSettings)
     // Create client
     TargetHttpProxiesClient targetHttpProxiesClient = TargetHttpProxiesClient.Create();
     // Initialize request argument(s)
     GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
     {
         TargetHttpProxy = "",
         Project         = "",
     };
     // Make the request
     TargetHttpProxy response = targetHttpProxiesClient.Get(request);
     // End snippet
 }
示例#12
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetTargetHttpProxyRequest, CallSettings)
            // Additional: GetAsync(GetTargetHttpProxyRequest, CancellationToken)
            // Create client
            TargetHttpProxiesClient targetHttpProxiesClient = await TargetHttpProxiesClient.CreateAsync();

            // Initialize request argument(s)
            GetTargetHttpProxyRequest request = new GetTargetHttpProxyRequest
            {
                TargetHttpProxy = "",
                Project         = "",
            };
            // Make the request
            TargetHttpProxy response = await targetHttpProxiesClient.GetAsync(request);

            // End snippet
        }