private static async Task <IReadOnlyList <Label> > GetAllLabels(GitHubClient client, Repository repoId)
        {
            int          page           = 0;
            int          totalProcessed = 0;
            int          totalExpected  = 1;
            List <Label> labels         = new List <Label>();

            while (totalProcessed < totalExpected)
            {
                page++;

                var request = new SearchLabelsRequest("\"\"", repoId.Id)
                {
                    RepositoryId = repoId.Id,
                    Page         = page
                };
                var result = await client.Search.SearchLabels(request);

                totalExpected = result.TotalCount;

                foreach (var label in result.Items)
                {
                    labels.Add(label);
                }
                totalProcessed += result.Items.Count;
            }
            return(labels.OrderBy(e => e.Name).ToList());
        }
    public async Task SearchForAllLabelsUsingTermAndRepositoryId()
    {
        var request = new SearchLabelsRequest("category", 7528679);

        var labels = await _gitHubClient.Search.SearchLabels(request);

        Assert.NotEmpty(labels.Items);
    }
Example #3
0
        private static async Task LabelAllFieldsExample(GitHubClient client, Repository repository)
        {
            string term = "category";

            var request = new SearchLabelsRequest(term, repository.Id)
            {
                Order     = SortDirection.Descending,
                SortField = LabelSearchSort.Created
            };

            SearchLabelsResult result = await client.Search.SearchLabels(request);

            Console.WriteLine($"Search.SearchLabels (All Fields): TotalCount={result.TotalCount}");
        }
Example #4
0
        public static async Task <IEnumerable <string> > GetAreaLabels(string owner, string repo)
        {
            var repository = await _client.Repository.Get(owner, repo);

            var request = new SearchLabelsRequest("area-", repository.Id);

            request.Page = 0;
            var labels = Enumerable.Empty <Label>();
            SearchLabelsResult areasFound = null;

            do
            {
                request.Page += 1;
                areasFound    = await _client.Search.SearchLabels(request);

                labels = areasFound.Items.Union(labels);
            } while (labels.Count() < areasFound.TotalCount);

            return(labels.Select(x => x.Name));
        }
 /// <summary>
 /// search labels
 /// https://developer.github.com/v3/search/#search-labels
 /// </summary>
 /// <param name="search"></param>
 /// <returns>List of labels</returns>
 public IObservable <SearchLabelsResult> SearchLabels(SearchLabelsRequest search)
 {
     Ensure.ArgumentNotNull(search, nameof(search));
     return(_client.SearchLabels(search).ToObservable());
 }