Beispiel #1
0
 public static System.Threading.Tasks.Task <FileUpdated> UpdateFileAsync(this Meziantou.GitLab.IGitLabRepositoryFilesClient client, ProjectIdOrPathRef id, string filePath, string branch, Meziantou.GitLab.TextOrBinaryData content, string commitMessage, string?startBranch = default(string?), string?authorEmail = default(string?), string?authorName = default(string?), Meziantou.GitLab.GitObjectId?lastCommitId = default(Meziantou.GitLab.GitObjectId?), Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     Meziantou.GitLab.UpdateFileRepositoryFileRequest request = new Meziantou.GitLab.UpdateFileRepositoryFileRequest(id, filePath, branch, content, commitMessage);
     request.StartBranch  = startBranch;
     request.AuthorEmail  = authorEmail;
     request.AuthorName   = authorName;
     request.LastCommitId = lastCommitId;
     return(client.UpdateFileAsync(request, requestOptions, cancellationToken));
 }
Beispiel #2
0
        private static string RepositoryFiles_UpdateFileAsync_BuildUrl(Meziantou.GitLab.UpdateFileRepositoryFileRequest 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("/repository/files/");
                if ((!object.ReferenceEquals(request.FilePath, null)))
                {
                    urlBuilder.AppendParameter(request.FilePath);
                }

                url = urlBuilder.ToString();
            }

            return(url);
        }
Beispiel #3
0
 System.Threading.Tasks.Task <FileUpdated> Meziantou.GitLab.IGitLabRepositoryFilesClient.UpdateFileAsync(Meziantou.GitLab.UpdateFileRepositoryFileRequest request, Meziantou.GitLab.RequestOptions?requestOptions, System.Threading.CancellationToken cancellationToken)
 {
     return(this.RepositoryFiles_UpdateFileAsync(request, requestOptions, cancellationToken));
 }
Beispiel #4
0
        private async System.Threading.Tasks.Task <FileUpdated> RepositoryFiles_UpdateFileAsync(Meziantou.GitLab.UpdateFileRepositoryFileRequest request, Meziantou.GitLab.RequestOptions?requestOptions = default(Meziantou.GitLab.RequestOptions), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            string url = Meziantou.GitLab.GitLabClient.RepositoryFiles_UpdateFileAsync_BuildUrl(request);

            using (System.Net.Http.HttpRequestMessage requestMessage = new System.Net.Http.HttpRequestMessage())
            {
                requestMessage.Method     = System.Net.Http.HttpMethod.Put;
                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);

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

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

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