コード例 #1
0
        public async Task ErrorReportingTest()
        {
            Task <ErrorStatsServiceClient> clientTask = ErrorStatsServiceClient.CreateAsync();

            // Create a test server and make an http.
            using (TestServer server = TestServer.Create <ErrorReportingApplication>())
            {
                await server.HttpClient.GetAsync("");

                // Create a request that will filter on the TestId which is set to the service and version.
                ListGroupStatsRequest request = new ListGroupStatsRequest
                {
                    ProjectName   = new ProjectName(ProjectId).ToString(),
                    ServiceFilter = new ServiceContextFilter
                    {
                        Service = TestId,
                        Version = TestId
                    }
                };

                // Check that we have the proper results and the TestId shows up in the error.
                ErrorStatsServiceClient client = await clientTask;
                ErrorGroupStats         stats  = await client.ListGroupStatsAsync(request).FirstOrDefault();

                Assert.NotNull(stats);
                Assert.True(stats.Count > 0);
                Assert.Contains(TestId, stats.Representative.Message);
            }
        }
        /// <summary>Snippet for ListGroupStats</summary>
        public async Task ListGroupStatsAsync_RequestObject()
        {
            // Snippet: ListGroupStatsAsync(ListGroupStatsRequest, CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = await ErrorStatsServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListGroupStatsRequest request = new ListGroupStatsRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
                GroupId            = { "", },
                ServiceFilter      = new ServiceContextFilter(),
                TimeRange          = new QueryTimeRange(),
                TimedCountDuration = new Duration(),
                Alignment          = TimedCountAlignment.ErrorCountAlignmentUnspecified,
                AlignmentTime      = new Timestamp(),
                Order = ErrorGroupOrder.GroupOrderUnspecified,
            };
            // Make the request
            PagedAsyncEnumerable <ListGroupStatsResponse, ErrorGroupStats> response = errorStatsServiceClient.ListGroupStatsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((ErrorGroupStats 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((ListGroupStatsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ErrorGroupStats 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 <ErrorGroupStats> 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 (ErrorGroupStats 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
        }
        /// <summary>Snippet for ListGroupStats</summary>
        public void ListGroupStats_RequestObject()
        {
            // Snippet: ListGroupStats(ListGroupStatsRequest,CallSettings)
            // Create client
            ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.Create();
            // Initialize request argument(s)
            ListGroupStatsRequest request = new ListGroupStatsRequest
            {
                ProjectNameAsProjectName = new ProjectName("[PROJECT]"),
                TimeRange = new QueryTimeRange(),
            };
            // Make the request
            PagedEnumerable <ListGroupStatsResponse, ErrorGroupStats> response =
                errorStatsServiceClient.ListGroupStats(request);

            // 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 pages (of server-defined size), performing one RPC per page
            foreach (ListGroupStatsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ErrorGroupStats item in page)
                {
                    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 <ErrorGroupStats> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (ErrorGroupStats item in singlePage)
            {
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
コード例 #4
0
        /// <summary>
        /// Lists the specified groups.
        /// </summary>
        /// <param name="projectName">
        /// [Required] The resource name of the Google Cloud Platform project. Written
        /// as <code>projects/</code> plus the
        /// <a href="https://support.google.com/cloud/answer/6158840">Google Cloud
        /// Platform project ID</a>.
        ///
        /// Example: <code>projects/my-project-123</code>.
        /// </param>
        /// <param name="timeRange">
        /// [Required] List data for the given time range.
        /// Only <code>ErrorGroupStats</code> with a non-zero count in the given time
        /// range are returned, unless the request contains an explicit group_id list.
        /// If a group_id list is given, also <code>ErrorGroupStats</code> with zero
        /// occurrences are returned.
        /// </param>
        /// <param name="pageToken">
        /// The token returned from the previous request.
        /// A value of <c>null</c> or an empty string retrieves the first page.
        /// </param>
        /// <param name="pageSize">
        /// The size of page to request. The response will not be larger than this, but may be smaller.
        /// A value of <c>null</c> or 0 uses a server-defined page size.
        /// </param>
        /// <param name="callSettings">
        /// If not null, applies overrides to this RPC call.
        /// </param>
        /// <returns>
        /// A pageable sequence of <see cref="ErrorGroupStats"/> resources.
        /// </returns>
        public override IPagedEnumerable <ListGroupStatsResponse, ErrorGroupStats> ListGroupStats(
            string projectName,
            QueryTimeRange timeRange,
            string pageToken          = null,
            int?pageSize              = null,
            CallSettings callSettings = null)
        {
            ListGroupStatsRequest request = new ListGroupStatsRequest
            {
                ProjectName = projectName,
                TimeRange   = timeRange,
                PageToken   = pageToken ?? "",
                PageSize    = pageSize ?? 0,
            };

            Modify_ListGroupStatsRequest(ref request, ref callSettings);
            return(new PagedEnumerable <ListGroupStatsRequest, ListGroupStatsResponse, ErrorGroupStats>(_callListGroupStats, request, callSettings));
        }
コード例 #5
0
 // Partial modifier methods contain '_' to ensure no name conflicts with RPC methods.
 partial void Modify_ListGroupStatsRequest(ref ListGroupStatsRequest request, ref CallSettings settings);