示例#1
0
 /// <summary>Snippet for CreateAutoscalingPolicy</summary>
 public void CreateAutoscalingPolicyResourceNames2()
 {
     // Snippet: CreateAutoscalingPolicy(RegionName, AutoscalingPolicy, CallSettings)
     // Create client
     AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = AutoscalingPolicyServiceClient.Create();
     // Initialize request argument(s)
     RegionName        parent = RegionName.FromProjectRegion("[PROJECT]", "[REGION]");
     AutoscalingPolicy policy = new AutoscalingPolicy();
     // Make the request
     AutoscalingPolicy response = autoscalingPolicyServiceClient.CreateAutoscalingPolicy(parent, policy);
     // End snippet
 }
示例#2
0
        /// <summary>Snippet for CreateAutoscalingPolicyAsync</summary>
        public async Task CreateAutoscalingPolicyResourceNames2Async()
        {
            // Snippet: CreateAutoscalingPolicyAsync(RegionName, AutoscalingPolicy, CallSettings)
            // Additional: CreateAutoscalingPolicyAsync(RegionName, AutoscalingPolicy, CancellationToken)
            // Create client
            AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync();

            // Initialize request argument(s)
            RegionName        parent = RegionName.FromProjectRegion("[PROJECT]", "[REGION]");
            AutoscalingPolicy policy = new AutoscalingPolicy();
            // Make the request
            AutoscalingPolicy response = await autoscalingPolicyServiceClient.CreateAutoscalingPolicyAsync(parent, policy);

            // End snippet
        }
示例#3
0
        /// <summary>Snippet for ListAutoscalingPolicies</summary>
        public async Task ListAutoscalingPoliciesResourceNames2Async()
        {
            // Snippet: ListAutoscalingPoliciesAsync(RegionName, string, int?, CallSettings)
            // Create client
            AutoscalingPolicyServiceClient autoscalingPolicyServiceClient = await AutoscalingPolicyServiceClient.CreateAsync();

            // Initialize request argument(s)
            RegionName parent = RegionName.FromProjectRegion("[PROJECT]", "[REGION]");
            // Make the request
            PagedAsyncEnumerable <ListAutoscalingPoliciesResponse, AutoscalingPolicy> response = autoscalingPolicyServiceClient.ListAutoscalingPoliciesAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((AutoscalingPolicy item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListAutoscalingPoliciesResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (AutoscalingPolicy item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <AutoscalingPolicy> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (AutoscalingPolicy item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        public async stt::Task CreateWorkflowTemplateRequestObjectAsync()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateWorkflowTemplateRequest request = new CreateWorkflowTemplateRequest
            {
                ParentAsRegionName = RegionName.FromProjectRegion("[PROJECT]", "[REGION]"),
                Template           = new WorkflowTemplate(),
            };
            WorkflowTemplate expectedResponse = new WorkflowTemplate
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Id         = "id74b70bb8",
                Version    = 271578922,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Placement  = new WorkflowTemplatePlacement(),
                Jobs       = { new OrderedJob(), },
                Parameters =
                {
                    new TemplateParameter(),
                },
                DagTimeout = new wkt::Duration(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void CreateWorkflowTemplateResourceNames2()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateWorkflowTemplateRequest request = new CreateWorkflowTemplateRequest
            {
                ParentAsRegionName = RegionName.FromProjectRegion("[PROJECT]", "[REGION]"),
                Template           = new WorkflowTemplate(),
            };
            WorkflowTemplate expectedResponse = new WorkflowTemplate
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Id         = "id74b70bb8",
                Version    = 271578922,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Placement  = new WorkflowTemplatePlacement(),
                Jobs       = { new OrderedJob(), },
                Parameters =
                {
                    new TemplateParameter(),
                },
                DagTimeout = new wkt::Duration(),
            };

            mockGrpcClient.Setup(x => x.CreateWorkflowTemplate(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            WorkflowTemplate response            = client.CreateWorkflowTemplate(request.ParentAsLocationName, request.Template);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }