コード例 #1
0
        /// <summary>
        /// Retrieves issues from a group.
        /// By default retrieves opened issues from all users.
        /// </summary>
        /// <param name="groupId">The name of the group.</param>
        /// <param name="options">Issues retrieval options.</param>
        /// <returns>Issues satisfying options.</returns>
        public async Task <IList <Issue> > GetForGroupAsync(ProjectId groupId, Action <IssuesQueryOptions> options = null)
        {
            var queryOptions = new IssuesQueryOptions();

            options?.Invoke(queryOptions);

            string url = _queryBuilder.Build($"groups/{groupId}/issues", queryOptions);

            return(await _httpFacade.GetPagedList <Issue>(url));
        }
コード例 #2
0
        public void NonDefaultQueryBuilt()
        {
            var sut = new IssuesQueryBuilder();

            string query = sut.Build(
                "https://gitlab.com/api/v4/issues",
                new IssuesQueryOptions
            {
                State          = IssueState.Opened,
                Labels         = { "label1", "label2" },
                MilestoneTitle = "milestone1",
                Scope          = Scope.All,
                AuthorId       = 1,
                AssigneeId     = 2,
                IssueIds       = { 3, 4 },
                Order          = IssuesOrder.UpdatedAt,
                SortOrder      = SortOrder.Ascending,
                Filter         = "filter"
            });

            query.Should().Be("https://gitlab.com/api/v4/issues?" +
                              "state=opened&" +
                              "labels=label1%2clabel2&" +
                              "milestone=milestone1&" +
                              "scope=all&" +
                              "author_id=1&" +
                              "assignee_id=2&" +
                              "iids%5b%5d=3&iids%5b%5d=4&" +
                              "order_by=updated_at&" +
                              "sort=asc&" +
                              "search=filter");
        }
コード例 #3
0
        /// <summary>
        /// Retrieves issues linked to an epic.
        /// </summary>
        /// <param name="groupId">The ID, path or <see cref="Group"/> of the group.</param>
        /// <param name="epicIid">Iid of the epic.</param>
        /// <param name="options">Issues retrieval options.</param>
        /// <returns>Epic satisfying options.</returns>
        public async Task <IList <Issue> > GetIssusAsync(GroupId groupId, int epicIid, Action <IssuesQueryOptions> options = null)
        {
            var queryOptions = new IssuesQueryOptions();

            options?.Invoke(queryOptions);

            string url = _issuesQueryBuilder.Build($"groups/{groupId}/epics/{epicIid}/issues", queryOptions);

            return(await _httpFacade.GetPagedList <Issue>(url));
        }
コード例 #4
0
        /// <summary>
        /// Retrieves issues from all projects.
        /// By default retrieves opened issues from all users.
        /// </summary>
        /// <param name="options">Issues retrieval options.</param>
        /// <returns>Issues satisfying options.</returns>
        public async Task <IList <Issue> > GetAsync(Action <IssuesQueryOptions> options = null)
        {
            var queryOptions = new IssuesQueryOptions();

            options?.Invoke(queryOptions);

            string url = _queryBuilder.Build("issues", queryOptions);

            return(await _httpFacade.GetPagedList <Issue>(url));
        }
コード例 #5
0
        public void NonDefaultQueryBuiltWithUserNames()
        {
            var sut = new IssuesQueryBuilder();

            string query = sut.Build(
                "https://gitlab.com/api/v4/issues",
                new IssuesQueryOptions
            {
                State            = EpicIssueState.Opened,
                Labels           = { "label1", "label2" },
                MilestoneTitle   = "milestone1",
                Scope            = Scope.All,
                AuthorId         = null,
                AssigneeId       = null,
                IssueIds         = { 3, 4 },
                Order            = EpicsIssuesOrder.UpdatedAt,
                SortOrder        = SortOrder.Ascending,
                Filter           = "filter",
                In               = SearchIn.Title,
                CreatedAfter     = new DateTime(1991, 11, 11, 1, 1, 1),
                CreatedBefore    = new DateTime(1991, 12, 12, 2, 2, 2),
                UpdatedAfter     = new DateTime(1991, 4, 4, 4, 4, 4),
                UpdatedBefore    = new DateTime(1991, 5, 5, 5, 5, 5),
                IsConfidential   = true,
                AuthorUsername   = "******",
                AssigneeUsername = new List <string> {
                    "user_1", "user_2"
                }
            });

            query.Should().BeEquivalentTo("https://gitlab.com/api/v4/issues?" +
                                          "state=opened&" +
                                          "labels=label1%2Clabel2&" +
                                          "milestone=milestone1&" +
                                          "scope=all&" +
                                          "author_username=user_1&" +
                                          "assignee_username=user_1%2Cuser_2&" +
                                          "iids%5B%5D=3&iids%5B%5D=4&" +
                                          "order_by=updated_at&" +
                                          "sort=asc&" +
                                          "search=filter&" +
                                          "in=title&" +
                                          "confidential=true&" +
                                          "created_before=1991-12-12T02%3a02%3a02.0000000&" +
                                          "created_after=1991-11-11T01%3a01%3a01.0000000&" +
                                          "updated_before=1991-05-05T05%3a05%3a05.0000000&" +
                                          "updated_after=1991-04-04T04%3a04%3a04.0000000");
        }
コード例 #6
0
        /// <summary>
        /// Retrieves issues.
        /// By default retrieves opened issues from all users. The more specific setting win (if both project and group are set, only project issues will be retrieved).
        /// </summary>
        /// <example>
        /// <code>
        /// /* Get all issues */
        /// var client = new GitLabClient("https://gitlab.com", "PRIVATE-TOKEN");
        /// var allIssues = await client.Issues.GetAllAsync();
        /// </code>
        /// <code>
        /// /* Get project issues */
        /// var client = new GitLabClient("https://gitlab.com", "PRIVATE-TOKEN");
        /// string projectPath = "dev/group/project-1";
        /// var allIssues = await client.Issues.GetAllAsync(projectId: projectPath);
        /// // OR
        /// int projectId = 55;
        /// var allIssues = await client.Issues.GetAllAsync(projectId: projectId);
        /// // OR - Group ID is skipped, project ID is more specific
        /// int projectId = 55;
        /// int groupId = 181;
        /// var allIssues = await client.Issues.GetAllAsync(projectId: projectId, groupId: groupId);
        /// </code>
        /// <code>
        /// /* Get group issues */
        /// var client = new GitLabClient("https://gitlab.com", "PRIVATE-TOKEN");
        /// string groupPath = "dev/group1/subgroup-1";
        /// var allIssues = await client.Issues.GetAllAsync(groupId: groupPath);
        /// // OR
        /// int groupId = 55;
        /// var allIssues = await client.Issues.GetAllAsync(groupId: groupId);
        /// </code>
        /// </example>
        /// <param name="projectId">The ID, path or <see cref="Project"/> of the project.</param>
        /// <param name="groupId">The ID, path or <see cref="Group"/> of the group.</param>
        /// <param name="options">Issues retrieval options.</param>
        /// <returns>Issues satisfying options.</returns>
        public async Task <IList <Issue> > GetAllAsync(ProjectId projectId = null, GroupId groupId = null,
                                                       Action <IssuesQueryOptions> options = null)
        {
            var queryOptions = new IssuesQueryOptions();

            options?.Invoke(queryOptions);

            string path = "issues";

            if (projectId != null)
            {
                path = $"projects/{projectId}/issues";
            }
            else if (groupId != null)
            {
                path = $"groups/{groupId}/issues";
            }

            string url = _queryBuilder.Build(path, queryOptions);

            return(await _httpFacade.GetPagedList <Issue>(url));
        }