/// <summary>Snippet for ListEvents</summary> public void ListEvents() { // Snippet: ListEvents(ProjectName,string,string,int?,CallSettings) // Create client ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.Create(); // Initialize request argument(s) ProjectName projectName = new ProjectName("[PROJECT]"); string groupId = ""; // Make the request PagedEnumerable <ListEventsResponse, ErrorEvent> response = errorStatsServiceClient.ListEvents(projectName, groupId); // Iterate over all response items, lazily performing RPCs as required foreach (ErrorEvent 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 (ListEventsResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (ErrorEvent 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 <ErrorEvent> 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 (ErrorEvent item in singlePage) { Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Gets error events that contain the passed in testId in the message. Will poll /// and wait for the entries to appear. /// </summary> /// <param name="startTime">The earliest error event time that will be looked at.</param> /// <param name="testId">The test id to filter error events on.</param> /// <param name="minEntries">The minimum number of error events that should be waited for. /// If minEntries is zero this method will wait the full timeout before checking for the /// entries.</param> public IEnumerable <ErrorEvent> GetEvents(DateTime startTime, string testId, int minEntries) { return(GetEntries(minEntries, () => { List <ErrorEvent> errorEvents = new List <ErrorEvent>(); var groups = _client.ListGroupStats(_projectName, s_oneHour); foreach (var group in groups) { ListEventsRequest request = new ListEventsRequest { ProjectName = _projectName.ToString(), GroupId = group.Group.GroupId, TimeRange = s_oneHour }; var events = _client.ListEvents(request); errorEvents.AddRange(events.Where(e => e.Message.Contains(testId))); } return errorEvents; })); }