Esempio n. 1
0
        private static string ProjectWikis_CreateWikiPageAsync_BuildUrl(Meziantou.GitLab.CreateWikiPageProjectWikiRequest 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("/wikis");
                url = urlBuilder.ToString();
            }

            return(url);
        }
Esempio n. 2
0
 System.Threading.Tasks.Task <WikiPage> Meziantou.GitLab.IGitLabProjectWikisClient.CreateWikiPageAsync(Meziantou.GitLab.CreateWikiPageProjectWikiRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken)
 {
     return(this.ProjectWikis_CreateWikiPageAsync(request, requestOptions, cancellationToken));
 }
Esempio n. 3
0
        private async System.Threading.Tasks.Task <WikiPage> ProjectWikis_CreateWikiPageAsync(Meziantou.GitLab.CreateWikiPageProjectWikiRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            string url = Meziantou.GitLab.GitLabClient.ProjectWikis_CreateWikiPageAsync_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);

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

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

                    return(result);
                }
                finally
                {
                    if ((response != null))
                    {
                        response.Dispose();
                    }
                }
            }
        }