diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index a329ba24..248dc024 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -96,6 +96,30 @@ namespace Octokit.Reactive /// A promise, containing the binary contents of the archive IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference); + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Timeout in minutes + /// The binary contents of the archive + IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, int timeout); + + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Time span until timeout + /// The binary contents of the archive + IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout); + /// /// Returns the contents of a file or directory in a repository. /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs index da864190..c83feeab 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -165,6 +165,36 @@ namespace Octokit.Reactive .GetAndFlattenAllPages(ApiUrls.RepositoryContent(owner, name, path)); } + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Timeout in minutes + /// The binary contents of the archive + public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, int timeout) + { + return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable(); + } + + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Time span until timeout + /// The binary contents of the archive + public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) + { + return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable(); + } + /// /// Returns the contents of a file or directory in a repository. /// diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index d2923478..eedf27fa 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -137,6 +137,30 @@ namespace Octokit /// The binary contents of the archive Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference); + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Timeout in minutes + /// The binary contents of the archive + Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, int timeout); + + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Time span until timeout + /// The binary contents of the archive + Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout); + /// /// Creates a commit that creates a new file in a repository. /// diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index f23b10b4..0ef5ad92 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -187,14 +187,44 @@ namespace Octokit /// The format of the archive. Can be either tarball or zipball /// A valid Git reference. /// The binary contents of the archive - public async Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference) + public Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference) + { + return GetArchive(owner, name, archiveFormat, string.Empty, 60); + } + + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Timeout in minutes + /// The binary contents of the archive + public Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, int timeout) + { + return GetArchive(owner, name, archiveFormat, string.Empty, TimeSpan.FromMinutes(60)); + } + + /// + /// Get an archive of a given repository's contents, in a specific format + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// The format of the archive. Can be either tarball or zipball + /// A valid Git reference. + /// Time span until timeout + /// The binary contents of the archive + public async Task GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); - var response = await Connection.Get(endpoint, TimeSpan.FromMinutes(60)); + var response = await Connection.Get(endpoint, timeout); return response.Body; }