public static System.Threading.Tasks.Task <SystemHook> AddHookAsync(this Meziantou.GitLab.IGitLabSystemHooksClient client, System.Uri url, string?token = default(string?), bool?pushEvents = default(bool?), bool?tagPushEvents = default(bool?), bool?mergeRequestsEvents = default(bool?), bool?repositoryUpdateEvents = default(bool?), bool?enableSslVerification = default(bool?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Meziantou.GitLab.AddHookSystemHookRequest request = new Meziantou.GitLab.AddHookSystemHookRequest(url); request.Token = token; request.PushEvents = pushEvents; request.TagPushEvents = tagPushEvents; request.MergeRequestsEvents = mergeRequestsEvents; request.RepositoryUpdateEvents = repositoryUpdateEvents; request.EnableSslVerification = enableSslVerification; return(client.AddHookAsync(request, requestOptions, cancellationToken)); }
System.Threading.Tasks.Task <SystemHook> Meziantou.GitLab.IGitLabSystemHooksClient.AddHookAsync(Meziantou.GitLab.AddHookSystemHookRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken) { return(this.SystemHooks_AddHookAsync(request, requestOptions, cancellationToken)); }
private async System.Threading.Tasks.Task <SystemHook> SystemHooks_AddHookAsync(Meziantou.GitLab.AddHookSystemHookRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { string url = Meziantou.GitLab.GitLabClient.SystemHooks_AddHookAsync_BuildUrl(); 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); SystemHook?result = await response.ToObjectAsync <SystemHook>(cancellationToken).ConfigureAwait(false); if ((result == null)) { throw new Meziantou.GitLab.GitLabException(response.RequestMethod, response.RequestUri, response.StatusCode, "The response cannot be converted to 'SystemHook' because the body is null or empty"); } return(result); } finally { if ((response != null)) { response.Dispose(); } } } }