From ce8afcad6f5c1c5c20cdbb9872fb5a9f9e8d9458 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 21 Mar 2015 23:33:26 +1000 Subject: [PATCH] Add GetArchiveLink Observable client --- .../IObservableRepositoryContentsClient.cs | 39 ++++++++++++++ .../ObservableRepositoryContentsClient.cs | 52 +++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index bfe4cb3e..4b56ed1b 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -24,6 +24,45 @@ namespace Octokit.Reactive /// IObservable GetReadmeHtml(string owner, string name); + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// + IObservable GetArchiveLink(string owner, string name); + + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// 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 + /// + IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat); + + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// 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. + /// + IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference); + /// /// 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 0a45ca68..1a644aea 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Threading.Tasks; +using Microsoft.SqlServer.Server; using Octokit.Reactive.Internal; namespace Octokit.Reactive @@ -49,6 +50,57 @@ namespace Octokit.Reactive } + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// https://developer.github.com/v3/repos/contents/#get-archive-link + /// The owner of the repository + /// The name of the repository + /// + public IObservable GetArchiveLink(string owner, string name) + { + return GetArchiveLink(owner, name, ArchiveFormat.Tarball, string.Empty); + } + + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// 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 + /// + public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat) + { + return GetArchiveLink(owner, name, archiveFormat, String.Empty); + } + + /// + /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. + /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the + /// Location header to make a second GET request. + /// Note: For private repositories, these links are temporary and expire quickly. + /// + /// 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. + /// + public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.Repository.Content.GetArchiveLink(owner, name, archiveFormat, reference).ToObservable(); + } + /// /// Returns the contents of a file or directory in a repository. ///