Exemplo n.º 1
0
        private async System.Threading.Tasks.Task <Issue> Issues_CreateAsync(Meziantou.GitLab.CreateIssueRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            string url = Meziantou.GitLab.GitLabClient.Issues_CreateAsync_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);

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

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

                    return(result);
                }
                finally
                {
                    if ((response != null))
                    {
                        response.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
 public static System.Threading.Tasks.Task <Issue> CreateAsync(this Meziantou.GitLab.IGitLabIssuesClient client, ProjectIdOrPathRef id, string title, string?description = default(string?), bool?confidential = default(bool?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     Meziantou.GitLab.CreateIssueRequest request = new Meziantou.GitLab.CreateIssueRequest(id, title);
     request.Description  = description;
     request.Confidential = confidential;
     return(client.CreateAsync(request, requestOptions, cancellationToken));
 }
Exemplo n.º 3
0
        private static string Issues_CreateAsync_BuildUrl(Meziantou.GitLab.CreateIssueRequest 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("/issues");
                url = urlBuilder.ToString();
            }

            return(url);
        }
Exemplo n.º 4
0
 System.Threading.Tasks.Task <Issue> Meziantou.GitLab.IGitLabIssuesClient.CreateAsync(Meziantou.GitLab.CreateIssueRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken)
 {
     return(this.Issues_CreateAsync(request, requestOptions, cancellationToken));
 }