Beispiel #1
0
        private async System.Threading.Tasks.Task <License> License_AddLicenseAsync(Meziantou.GitLab.AddLicenseRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            string url = Meziantou.GitLab.GitLabClient.License_AddLicenseAsync_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);
                HttpResponse?response = null;
                try
                {
                    response = await this.SendAsync(requestMessage, requestOptions, cancellationToken).ConfigureAwait(false);

                    await response.EnsureStatusCodeAsync(cancellationToken).ConfigureAwait(false);

                    License?result = await response.ToObjectAsync <License>(cancellationToken).ConfigureAwait(false);

                    if ((result == null))
                    {
                        throw new Meziantou.GitLab.GitLabException(response.RequestMethod, response.RequestUri, response.StatusCode, "The response cannot be converted to 'License' because the body is null or empty");
                    }

                    return(result);
                }
                finally
                {
                    if ((response != null))
                    {
                        response.Dispose();
                    }
                }
            }
        }
Beispiel #2
0
        private static string License_AddLicenseAsync_BuildUrl(Meziantou.GitLab.AddLicenseRequest request)
        {
            string url;

            using (Meziantou.GitLab.Internals.UrlBuilder urlBuilder = new Meziantou.GitLab.Internals.UrlBuilder())
            {
                urlBuilder.Append("license");
                char separator = '?';
                if ((!object.ReferenceEquals(request.License, null)))
                {
                    urlBuilder.Append(separator);
                    separator = '&';
                    urlBuilder.Append("license=");
                    urlBuilder.AppendParameter(request.License);
                }

                url = urlBuilder.ToString();
            }

            return(url);
        }
Beispiel #3
0
 System.Threading.Tasks.Task <License> Meziantou.GitLab.IGitLabLicenseClient.AddLicenseAsync(Meziantou.GitLab.AddLicenseRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken)
 {
     return(this.License_AddLicenseAsync(request, requestOptions, cancellationToken));
 }