Skip to content

Commit 58b62c8

Browse files
authored
Merge pull request #4 from cnblogs/create-project-for-specified-user
Create projects for specified user
2 parents 5b7bd7c + 5db6562 commit 58b62c8

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/GitLabApiClient/IProjectsClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ public interface IProjectsClient
8282
/// <returns>Newly created project.</returns>
8383
Task<Project> CreateAsync(CreateProjectRequest request);
8484

85+
/// <summary>
86+
/// Creates a new project owned by the specified user
87+
/// </summary>
88+
/// <param name="userId">The userId of the project owner.</param>
89+
/// <param name="request">Create project request.</param>
90+
/// <returns></returns>
91+
Task<Project> CreateForUserAsync(int userId, CreateProjectRequest request);
92+
8593
/// <summary>
8694
/// Creates new project label.
8795
/// </summary>

src/GitLabApiClient/Internal/Utilities/Guard.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static void NotEmpty<T>(IEnumerable<T> arg, string argName)
3737
}
3838

3939
public static void NotNull<T>(T arg, string argName)
40-
where T : class
4140
{
4241
if (arg == null)
4342
throw new ArgumentException($"ArgumentException: {argName} is null");

src/GitLabApiClient/ProjectsClient.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ public async Task<Project> CreateAsync(CreateProjectRequest request)
136136
return await _httpFacade.Post<Project>("projects", request);
137137
}
138138

139+
//// <summary>
140+
/// Creates a new project owned by the specified user
141+
/// </summary>
142+
/// <param name="userId">The userId of the project owner.</param>
143+
/// <param name="request">Create project request.</param>
144+
/// <returns></returns>
145+
public async Task<Project> CreateForUserAsync(int userId, CreateProjectRequest request)
146+
{
147+
Guard.NotNull(request, nameof(request));
148+
request.UserId = userId;
149+
return await _httpFacade.Post<Project>($"projects/user/{userId}", request);
150+
}
151+
139152
/// <summary>
140153
/// Creates new project label.
141154
/// </summary>

0 commit comments

Comments
 (0)