Skip to content

Commit 223e544

Browse files
authored
Merge pull request #6 from cnblogs/feat/get-user-projects
feat: get projects for specified user
2 parents f48d617 + 3149a24 commit 223e544

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/GitLabApiClient/IProjectsClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4+
45
using GitLabApiClient.Internal.Paths;
56
using GitLabApiClient.Models.Job.Requests;
67
using GitLabApiClient.Models.Job.Responses;
@@ -30,6 +31,13 @@ public interface IProjectsClient
3031
/// <param name="options">Query options.</param>
3132
Task<IList<Project>> GetAsync(Action<ProjectQueryOptions> options = null);
3233

34+
/// <summary>
35+
/// Get a list of projects for specified user
36+
/// </summary>
37+
/// <param name="userId">Id of the user.</param>
38+
/// <returns></returns>
39+
Task<IList<Project>> GetByUser(int userId);
40+
3341
/// <summary>
3442
/// Get the users list of a project.
3543
/// </summary>

src/GitLabApiClient/ProjectsClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Net.Http;
44
using System.Threading.Tasks;
5+
56
using GitLabApiClient.Internal.Http;
67
using GitLabApiClient.Internal.Paths;
78
using GitLabApiClient.Internal.Queries;
@@ -61,6 +62,16 @@ public async Task<IList<Project>> GetAsync(Action<ProjectQueryOptions> options =
6162
return await _httpFacade.GetPagedList<Project>(url);
6263
}
6364

65+
/// <summary>
66+
/// Get a list of projects for specified user
67+
/// </summary>
68+
/// <param name="userId">Id of the user.</param>
69+
/// <returns></returns>
70+
public async Task<IList<Project>> GetByUser(int userId)
71+
{
72+
return await _httpFacade.GetPagedList<Project>($"users/{userId}/projects");
73+
}
74+
6475
/// <summary>
6576
/// Get the users list of a project.
6677
/// </summary>

0 commit comments

Comments
 (0)