Beispiel #1
0
        public async stt::Task ListAsync()
        {
            moq::Mock <Regions.RegionsClient> mockGrpcClient = new moq::Mock <Regions.RegionsClient>(moq::MockBehavior.Strict);
            ListRegionsRequest request = new ListRegionsRequest
            {
                Project = "projectaa6ff846",
            };
            RegionList expectedResponse = new RegionList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Region(), },
                SelfLink      = "self_link7e87f12d",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public void ListRequestObject()
        {
            moq::Mock <Regions.RegionsClient> mockGrpcClient = new moq::Mock <Regions.RegionsClient>(moq::MockBehavior.Strict);
            ListRegionsRequest request = new ListRegionsRequest
            {
                PageToken            = "page_tokenf09e5538",
                MaxResults           = 2806814450U,
                OrderBy              = "order_byb4d33ada",
                Project              = "projectaa6ff846",
                Filter               = "filtere47ac9b2",
                ReturnPartialSuccess = false,
            };
            RegionList expectedResponse = new RegionList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Region(), },
                SelfLink      = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RegionsClient client   = new RegionsClientImpl(mockGrpcClient.Object, null);
            RegionList    response = client.List(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        private static async Task ListOciRegions(IdentityClient client)
        {
            // Create a Retry configuration to override defaults
            RetryConfiguration retryConfiguration = new RetryConfiguration
            {
                // Enable exponential backoff.
                GetNextDelayInSeconds = DelayStrategy.GetExponentialDelayInSeconds,
                //  Defines total duration in seconds for which the retry attempts.
                TotalElapsedTimeInSecs = 600,
                // Defines the total number of retry attempts.
                MaxAttempts = 4,
                // Retryable status code family. This will make the SDK retry for all 5xx.
                RetryableStatusCodeFamilies = new List <int>(new int[] { 5 }),
                // Retrying on certain HTTP Status Ccode and Error code combo.
                RetryableErrors = new Collection <Tuple <int, string> >(new Tuple <int, string>[] {
                    new Tuple <int, string>(409, "IncorrectState"),
                    new Tuple <int, string>(429, "TooManyRequests")
                })
            };
            // List regions
            var listRegionsRequest = new ListRegionsRequest();
            ListRegionsResponse listRegionsResponse = await client.ListRegions(listRegionsRequest, retryConfiguration);

            logger.Info("List Regions");
            logger.Info("=============");
            foreach (Oci.IdentityService.Models.Region reg in listRegionsResponse.Items)
            {
                logger.Info($"{reg.Key} : {reg.Name}");
            }
        }
Beispiel #4
0
        private static async Task ListOciRegions(IdentityClient client)
        {
            // List regions
            var listRegionsRequest = new ListRegionsRequest();
            ListRegionsResponse listRegionsResponse = await client.ListRegions(listRegionsRequest);

            logger.Info("List Regions");
            logger.Info("=============");
            foreach (Oci.IdentityService.Models.Region reg in listRegionsResponse.Items)
            {
                logger.Info($"{reg.Key} : {reg.Name}");
            }
        }
Beispiel #5
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListRegionsRequest, CallSettings)
            // Create client
            RegionsClient regionsClient = await RegionsClient.CreateAsync();

            // Initialize request argument(s)
            ListRegionsRequest request = new ListRegionsRequest
            {
                OrderBy = "",
                Project = "",
                Filter  = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <RegionList, Region> response = regionsClient.ListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Region 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((RegionList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Region 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 <Region> 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 (Region 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
        }
Beispiel #6
0
 /// <summary>Snippet for List</summary>
 public void ListRequestObject()
 {
     // Snippet: List(ListRegionsRequest, CallSettings)
     // Create client
     RegionsClient regionsClient = RegionsClient.Create();
     // Initialize request argument(s)
     ListRegionsRequest request = new ListRegionsRequest
     {
         PageToken            = "",
         MaxResults           = 0U,
         OrderBy              = "",
         Project              = "",
         Filter               = "",
         ReturnPartialSuccess = false,
     };
     // Make the request
     RegionList response = regionsClient.List(request);
     // End snippet
 }
Beispiel #7
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListRegionsRequest request;

            try
            {
                request = new ListRegionsRequest
                {
                };

                response = client.ListRegions(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Items, true);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Beispiel #8
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListRegionsRequest, CallSettings)
            // Additional: ListAsync(ListRegionsRequest, CancellationToken)
            // Create client
            RegionsClient regionsClient = await RegionsClient.CreateAsync();

            // Initialize request argument(s)
            ListRegionsRequest request = new ListRegionsRequest
            {
                PageToken            = "",
                MaxResults           = 0U,
                OrderBy              = "",
                Project              = "",
                Filter               = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            RegionList response = await regionsClient.ListAsync(request);

            // End snippet
        }
Beispiel #9
0
        public void List()
        {
            moq::Mock <Regions.RegionsClient> mockGrpcClient = new moq::Mock <Regions.RegionsClient>(moq::MockBehavior.Strict);
            ListRegionsRequest request = new ListRegionsRequest
            {
                Project = "projectaa6ff846",
            };
            RegionList expectedResponse = new RegionList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Region(), },
                SelfLink      = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RegionsClient client   = new RegionsClientImpl(mockGrpcClient.Object, null);
            RegionList    response = client.List(request.Project);

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