Files
octokit.net/Octokit/Clients/IRepositoryContentsClient.cs
T
2022-07-20 17:17:10 -05:00

318 lines
18 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Octokit.Internal;
namespace Octokit
{
/// <summary>
/// Client for accessing contents of files within a repository as base64 encoded content.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/">Repository Contents API documentation</a> for more information.
/// </remarks>
public interface IRepositoryContentsClient
{
/// <summary>
/// Returns the contents of a file or directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The content path</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContents(string owner, string name, string path);
/// <summary>
/// Returns the raw content of the file at the given <paramref name="path"/> or <c>null</c> if the path is a directory.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The content path</param>
Task<byte[]> GetRawContent(string owner, string name, string path);
/// <summary>
/// Returns the contents of a file or directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The content path</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContents(long repositoryId, string path);
/// <summary>
/// Returns the contents of the root directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContents(string owner, string name);
/// <summary>
/// Returns the contents of the root directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContents(long repositoryId);
/// <summary>
/// Returns the contents of a file or directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The content path</param>
/// <param name="reference">The name of the commit/branch/tag. Default: the repositorys default branch (usually main)</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string path, string reference);
/// <summary>
/// Returns the raw content of the file at the given <paramref name="path"/> or <c>null</c> if the path is a directory.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The content path</param>
/// <param name="reference">The name of the commit/branch/tag.</param>
Task<byte[]> GetRawContentByRef(string owner, string name, string path, string reference);
/// <summary>
/// Returns the contents of a file or directory in a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The content path</param>
/// <param name="reference">The name of the commit/branch/tag. Default: the repositorys default branch (usually main)</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string path, string reference);
/// <summary>
/// Returns the contents of the root directory in a repository.
/// </summary>
/// <remarks>
/// If given a path to a single file, this method returns a collection containing only that file.
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The name of the commit/branch/tag. Default: the repositorys default branch (usually main)</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string reference);
/// <summary>
/// Returns the contents of the root directory in a repository.
/// </summary>
/// <remarks>
/// If given a path to a single file, this method returns a collection containing only that file.
/// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="reference">The name of the commit/branch/tag. Default: the repositorys default branch (usually main)</param>
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")]
Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string reference);
/// <summary>
/// Gets the preferred README for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<Readme> GetReadme(string owner, string name);
/// <summary>
/// Gets the preferred README for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<Readme> GetReadme(long repositoryId);
/// <summary>
/// Gets the preferred README's HTML for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<string> GetReadmeHtml(string owner, string name);
/// <summary>
/// Gets the preferred README's HTML for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
Task<string> GetReadmeHtml(long repositoryId);
/// <summary>
/// Get an archive of a given repository's contents
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
Task<byte[]> GetArchive(string owner, string name);
/// <summary>
/// Get an archive of a given repository's contents
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="repositoryId">The Id of the repository</param>
Task<byte[]> GetArchive(long repositoryId);
/// <summary>
/// Get an archive of a given repository's contents, in a specific format
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat);
/// <summary>
/// Get an archive of a given repository's contents, in a specific format
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
Task<byte[]> GetArchive(long repositoryId, ArchiveFormat archiveFormat);
/// <summary>
/// Get an archive of a given repository's contents, using a specific format and reference
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
/// <param name="reference">A valid Git reference.</param>
Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference);
/// <summary>
/// Get an archive of a given repository's contents, using a specific format and reference
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
/// <param name="reference">A valid Git reference.</param>
Task<byte[]> GetArchive(long repositoryId, ArchiveFormat archiveFormat, string reference);
/// <summary>
/// Get an archive of a given repository's contents, in a specific format
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
/// <param name="reference">A valid Git reference.</param>
/// <param name="timeout"> Time span until timeout </param>
Task<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout);
/// <summary>
/// Get an archive of a given repository's contents, in a specific format
/// </summary>
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
/// <param name="reference">A valid Git reference.</param>
/// <param name="timeout"> Time span until timeout </param>
Task<byte[]> GetArchive(long repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout);
/// <summary>
/// Creates a commit that creates a new file in a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to create</param>
Task<RepositoryContentChangeSet> CreateFile(string owner, string name, string path, CreateFileRequest request);
/// <summary>
/// Creates a commit that creates a new file in a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to create</param>
Task<RepositoryContentChangeSet> CreateFile(long repositoryId, string path, CreateFileRequest request);
/// <summary>
/// Creates a commit that updates the contents of a file in a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to update</param>
Task<RepositoryContentChangeSet> UpdateFile(string owner, string name, string path, UpdateFileRequest request);
/// <summary>
/// Creates a commit that updates the contents of a file in a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to update</param>
Task<RepositoryContentChangeSet> UpdateFile(long repositoryId, string path, UpdateFileRequest request);
/// <summary>
/// Creates a commit that deletes a file in a repository.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
Task DeleteFile(string owner, string name, string path, DeleteFileRequest request);
/// <summary>
/// Creates a commit that deletes a file in a repository.
/// </summary>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="path">The path to the file</param>
/// <param name="request">Information about the file to delete</param>
Task DeleteFile(long repositoryId, string path, DeleteFileRequest request);
}
/// <summary>
/// The archive format to return from the server
/// </summary>
public enum ArchiveFormat
{
/// <summary>
/// The TAR archive format
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tarball")]
[Parameter(Value = "tarball")]
Tarball,
/// <summary>
/// The ZIP archive format
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zipball")]
[Parameter(Value = "zipball")]
Zipball
}
}