예제 #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListCatalogsRequest request;

            try
            {
                request = new ListCatalogsRequest
                {
                    CompartmentId  = CompartmentId,
                    DisplayName    = DisplayName,
                    Limit          = Limit,
                    Page           = Page,
                    LifecycleState = LifecycleState,
                    SortOrder      = SortOrder,
                    SortBy         = SortBy,
                    OpcRequestId   = OpcRequestId
                };
                IEnumerable <ListCatalogsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListCatalogsRequest request;

            try
            {
                request = new ListCatalogsRequest
                {
                    CompartmentId  = CompartmentId,
                    DisplayName    = DisplayName,
                    Limit          = Limit,
                    Page           = Page,
                    LifecycleState = LifecycleState,
                    SortOrder      = SortOrder,
                    SortBy         = SortBy,
                    OpcRequestId   = OpcRequestId
                };
                IEnumerable <ListCatalogsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
예제 #3
0
        /// <summary>Snippet for ListCatalogsAsync</summary>
        public async Task ListCatalogsRequestObjectAsync()
        {
            // Snippet: ListCatalogsAsync(ListCatalogsRequest, CallSettings)
            // Create client
            CatalogServiceClient catalogServiceClient = await CatalogServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListCatalogsRequest request = new ListCatalogsRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListCatalogsResponse, Catalog> response = catalogServiceClient.ListCatalogsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Catalog 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((ListCatalogsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Catalog 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 <Catalog> 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 (Catalog 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
        }