diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index a329ba24c4..4f1456b93c 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -96,6 +96,18 @@ public interface IObservableRepositoryContentsClient /// 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. + /// 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 da864190a4..b83d516e19 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -74,7 +74,7 @@ public IObservable GetArchiveLink(string owner, string name) /// A promise, containing the binary contents of the archive public IObservable GetArchive(string owner, string name) { - return _client.Repository.Content.GetArchive(owner, name).ToObservable(); + return GetArchive(owner, name, ArchiveFormat.Tarball); } /// @@ -104,7 +104,7 @@ public IObservable GetArchiveLink(string owner, string name, ArchiveForm /// A promise, containing the binary contents of the archive public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat) { - return _client.Repository.Content.GetArchive(owner, name, archiveFormat).ToObservable(); + return GetArchive(owner, name, archiveFormat, string.Empty); } /// @@ -139,7 +139,7 @@ public IObservable GetArchiveLink(string owner, string name, ArchiveForm /// A promise, containing the binary contents of the archive public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference) { - return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference).ToObservable(); + return GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60)); } /// @@ -165,6 +165,25 @@ public IObservable GetAllContents(string owner, string name, .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. + /// Time span until timeout + /// The binary contents of the archive + public IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.GreaterThanZero(timeout, "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 d29234782b..45ae800b28 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -137,6 +137,18 @@ public interface IRepositoryContentsClient /// 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. + /// 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 f23b10b4fc..3e350e3f7a 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -187,14 +187,30 @@ public Task GetArchiveLink(string owner, string name, ArchiveFormat arch /// 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, 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"); + Ensure.GreaterThanZero(timeout, "timeout"); 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; }