예제 #1
0
        public void ListOperations()
        {
            // Snippet: ListOperations(string,string,string,int?,CallSettings)
            // Create client
            OperationsClient operationsClient = OperationsClient.Create();
            // Initialize request argument(s)
            string name   = "";
            string filter = "";
            // Make the request
            IPagedEnumerable <ListOperationsResponse, Operation> response =
                operationsClient.ListOperations(name, filter);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Operation item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <Operation> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Operation item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
        public void ListTraces()
        {
            // Snippet: ListTraces(string,string,int?,CallSettings)
            // Create client
            TraceServiceClient traceServiceClient = TraceServiceClient.Create();
            // Initialize request argument(s)
            string projectId = "";
            // Make the request
            IPagedEnumerable <ListTracesResponse, Trace> response =
                traceServiceClient.ListTraces(projectId);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Trace item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <Trace> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Trace item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
        public void ListLogMetrics()
        {
            // Snippet: ListLogMetrics(string,string,int?,CallSettings)
            // Create client
            MetricsServiceV2Client metricsServiceV2Client = MetricsServiceV2Client.Create();
            // Initialize request argument(s)
            string formattedParent = MetricsServiceV2Client.FormatParentName("[PROJECT]");
            // Make the request
            IPagedEnumerable <ListLogMetricsResponse, LogMetric> response =
                metricsServiceV2Client.ListLogMetrics(formattedParent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (LogMetric item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <LogMetric> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (LogMetric item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
예제 #4
0
        public void WithFixedSize()
        {
            string projectId            = _fixture.ProjectId;
            string pageTokenFromRequest = "";

            // Sample: WithFixedSize
            PublisherClient client      = PublisherClient.Create();
            string          projectName = PublisherClient.FormatProjectName(projectId);
            IPagedEnumerable <ListTopicsResponse, Topic> topics = client.ListTopics(projectName, pageTokenFromRequest);

            IEnumerable <FixedSizePage <Topic> > fixedSizePages = topics.AsPages().WithFixedSize(3);
            // With fixed size pages, if there are no more resources, there are no more pages.
            FixedSizePage <Topic> nextPage = fixedSizePages.FirstOrDefault();

            if (nextPage != null)
            {
                // In a web application, this would be a matter of including the topics in the web page.
                foreach (Topic topic in nextPage)
                {
                    Console.WriteLine(topic.Name);
                }
                // ... and embedding the next page token into a "next page" link.
                Console.WriteLine($"Next page token: {nextPage.NextPageToken}");
            }
            // End sample
        }
        public void ListLogEntries()
        {
            // Snippet: ListLogEntries(IEnumerable<string>,string,string,string,int?,CallSettings)
            // Create client
            LoggingServiceV2Client loggingServiceV2Client = LoggingServiceV2Client.Create();
            // Initialize request argument(s)
            IEnumerable <string> projectIds = new List <string>();
            string filter  = "";
            string orderBy = "";
            // Make the request
            IPagedEnumerable <ListLogEntriesResponse, LogEntry> response =
                loggingServiceV2Client.ListLogEntries(projectIds, filter, orderBy);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (LogEntry item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <LogEntry> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (LogEntry item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
        public void ListGroupMembers()
        {
            // Snippet: ListGroupMembers(string,string,int?,CallSettings)
            // Create client
            GroupServiceClient groupServiceClient = GroupServiceClient.Create();
            // Initialize request argument(s)
            string formattedName = GroupServiceClient.FormatGroupName("[PROJECT]", "[GROUP]");
            // Make the request
            IPagedEnumerable <ListGroupMembersResponse, MonitoredResource> response =
                groupServiceClient.ListGroupMembers(formattedName);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (MonitoredResource item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <MonitoredResource> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (MonitoredResource item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
예제 #7
0
        public void ListGroupStats()
        {
            // Snippet: ListGroupStats(string,QueryTimeRange,string,int?,CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.Create();
            // Initialize request argument(s)
            string         formattedProjectName = ErrorStatsServiceClient.FormatProjectName("[PROJECT]");
            QueryTimeRange timeRange            = new QueryTimeRange();
            // Make the request
            IPagedEnumerable <ListGroupStatsResponse, ErrorGroupStats> response =
                errorStatsServiceClient.ListGroupStats(formattedProjectName, timeRange);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (ErrorGroupStats item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <ErrorGroupStats> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ErrorGroupStats item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
        public void ListSubscriptions()
        {
            // Snippet: ListSubscriptions(string,string,int?,CallSettings)
            // Create client
            SubscriberClient subscriberClient = SubscriberClient.Create();
            // Initialize request argument(s)
            string formattedProject = SubscriberClient.FormatProjectName("[PROJECT]");
            // Make the request
            IPagedEnumerable <ListSubscriptionsResponse, Subscription> response =
                subscriberClient.ListSubscriptions(formattedProject);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Subscription item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <Subscription> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Subscription item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }
예제 #9
0
        public void SingleResponse()
        {
            string projectId = _fixture.ProjectId;
            // Sample: SingleResponse
            PublisherClient client      = PublisherClient.Create();
            string          projectName = PublisherClient.FormatProjectName(projectId);
            IPagedEnumerable <ListTopicsResponse, Topic>    topics     = client.ListTopics(projectName, pageSize: 3);
            IResponseEnumerable <ListTopicsResponse, Topic> topicPages = topics.AsPages();
            // This is just the regular LINQ First() method. The sequence of pages will never be empty,
            // but the page may have no resources.
            ListTopicsResponse firstPage = topicPages.First();

            Console.WriteLine("Topics in response:");
            foreach (Topic topic in firstPage.Topics)
            {
                Console.WriteLine($"  {topic.Name}");
            }
            // If you were processing items in batches, you might wish to store this
            // in order to recover from failures. The page token can be passed into the ListTopics method.
            Console.WriteLine($"Next page token: {firstPage.NextPageToken}");
            // End sample
        }
예제 #10
0
        public void Responses()
        {
            string projectId = _fixture.ProjectId;
            // Sample: Responses
            PublisherClient client      = PublisherClient.Create();
            string          projectName = PublisherClient.FormatProjectName(projectId);
            IPagedEnumerable <ListTopicsResponse, Topic>    topics     = client.ListTopics(projectName, pageSize: 3);
            IResponseEnumerable <ListTopicsResponse, Topic> topicPages = topics.AsPages();

            foreach (ListTopicsResponse page in topicPages)
            {
                Console.WriteLine("Topics in response:");
                foreach (Topic topic in page.Topics)
                {
                    Console.WriteLine($"  {topic.Name}");
                }
                // If you were processing items in batches, you might wish to store this
                // in order to recover from failures. The page token can be passed into the ListTopics method.
                Console.WriteLine($"Next page token: {page.NextPageToken}");
            }
            // End sample
        }
예제 #11
0
        public void ListTimeSeries()
        {
            // Snippet: ListTimeSeries(string,string,TimeInterval,ListTimeSeriesRequest.Types.TimeSeriesView,string,int?,CallSettings)
            // Create client
            MetricServiceClient metricServiceClient = MetricServiceClient.Create();
            // Initialize request argument(s)
            string       formattedName = MetricServiceClient.FormatProjectName("[PROJECT]");
            string       filter        = "";
            TimeInterval interval      = new TimeInterval();

            ListTimeSeriesRequest.Types.TimeSeriesView view = ListTimeSeriesRequest.Types.TimeSeriesView.Full;
            // Make the request
            IPagedEnumerable <ListTimeSeriesResponse, TimeSeries> response =
                metricServiceClient.ListTimeSeries(formattedName, filter, interval, view);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (TimeSeries item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over fixed-sized pages, lazily performing RPCs as required
            int pageSize = 10;

            foreach (FixedSizePage <TimeSeries> page in response.AsPages().WithFixedSize(pageSize))
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (TimeSeries item in page)
                {
                    Console.WriteLine(item);
                }
            }
            // End snippet
        }