private static string Members_AddMemberToProjectAsync_BuildUrl(Meziantou.GitLab.AddMemberToProjectRequest request) { string url; using (Meziantou.GitLab.Internals.UrlBuilder urlBuilder = new Meziantou.GitLab.Internals.UrlBuilder()) { urlBuilder.Append("projects/"); if (request.Id.HasValue) { urlBuilder.AppendParameter(request.Id.GetValueOrDefault().ValueAsString); } urlBuilder.Append("/members"); url = urlBuilder.ToString(); } return(url); }
System.Threading.Tasks.Task <Member> Meziantou.GitLab.IGitLabMembersClient.AddMemberToProjectAsync(Meziantou.GitLab.AddMemberToProjectRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken) { return(this.Members_AddMemberToProjectAsync(request, requestOptions, cancellationToken)); }
private async System.Threading.Tasks.Task <Member> Members_AddMemberToProjectAsync(Meziantou.GitLab.AddMemberToProjectRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { string url = Meziantou.GitLab.GitLabClient.Members_AddMemberToProjectAsync_BuildUrl(request); using (System.Net.Http.HttpRequestMessage requestMessage = new System.Net.Http.HttpRequestMessage()) { requestMessage.Method = System.Net.Http.HttpMethod.Post; requestMessage.RequestUri = new System.Uri(url, System.UriKind.RelativeOrAbsolute); requestMessage.Content = new Meziantou.GitLab.Internals.JsonContent(request, Meziantou.GitLab.Serialization.JsonSerialization.Options); HttpResponse?response = null; try { response = await this.SendAsync(requestMessage, requestOptions, cancellationToken).ConfigureAwait(false); await response.EnsureStatusCodeAsync(cancellationToken).ConfigureAwait(false); Member?result = await response.ToObjectAsync <Member>(cancellationToken).ConfigureAwait(false); if ((result == null)) { throw new Meziantou.GitLab.GitLabException(response.RequestMethod, response.RequestUri, response.StatusCode, "The response cannot be converted to 'Member' because the body is null or empty"); } return(result); } finally { if ((response != null)) { response.Dispose(); } } } }
public static System.Threading.Tasks.Task <Member> AddMemberToProjectAsync(this Meziantou.GitLab.IGitLabMembersClient client, ProjectIdOrPathRef id, UserIdRef userId, AccessLevel accessLevel, System.DateTime?expiresAt = default(System.DateTime?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Meziantou.GitLab.AddMemberToProjectRequest request = new Meziantou.GitLab.AddMemberToProjectRequest(id, userId, accessLevel); request.ExpiresAt = expiresAt; return(client.AddMemberToProjectAsync(request, requestOptions, cancellationToken)); }