-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Repository Pages client #1061
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1a5e3d1
Add regular interface and models
M-Zuber 15c8ff9
Add implementation and unit tests
M-Zuber 4265b62
Figured out how to include the files for the other projects
M-Zuber 3003fb3
Add IObservable + impl
M-Zuber 0435cd2
:lipstick: usings and fix missing files
M-Zuber e690e22
Fix up xml and add missing docs
M-Zuber c113292
Fix convention errors
M-Zuber 564dea5
Add missing words
M-Zuber 0201d01
fix merge conflicts
M-Zuber ca187df
Renaming for :kiss:
M-Zuber 134f44f
Merge branch 'master' of https://github.com/octokit/octokit.net into …
M-Zuber ef06aa4
I feel dumb for this one
M-Zuber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public interface IObservableRepositoryPagesClient | ||
{ | ||
/// <summary> | ||
/// Gets the page metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] | ||
IObservable<Page> Get(string owner, string repositoryName); | ||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
IObservable<PagesBuild> GetAll(string owner, string repositoryName); | ||
/// <summary> | ||
/// Gets the build metadata for the last build for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
IObservable<PagesBuild> GetLatest(string owner, string repositoryName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Octokit.Reactive.Internal; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reactive.Threading.Tasks; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public class ObservableRepositoryPagesClient : IObservableRepositoryPagesClient | ||
{ | ||
readonly IRepositoryPagesClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservableRepositoryPagesClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
_client = client.Repository.Page; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the page metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] | ||
public IObservable<Page> Get(string owner, string repositoryName) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.Get(owner, repositoryName).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
public IObservable<PagesBuild> GetAll(string owner, string repositoryName) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _connection.GetAndFlattenAllPages<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the build metadata for the last build for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
public IObservable<PagesBuild> GetLatest(string owner, string repositoryName) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); | ||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); | ||
|
||
return _client.GetLatest(owner, repositoryName).ToObservable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using NSubstitute; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Clients | ||
{ | ||
public class RepositoryPagesClientTests | ||
{ | ||
public class TheGetMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
client.Get("fake", "repo"); | ||
|
||
connection.Received().Get<Page>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages"), null); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name")); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null)); | ||
} | ||
} | ||
|
||
public class TheGetBuildsMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
client.GetAll("fake", "repo"); | ||
|
||
connection.Received().GetAll<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds")); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name")); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null)); | ||
} | ||
} | ||
|
||
public class TheGetLatestBuildMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
client.GetLatest("fake", "repo"); | ||
|
||
connection.Received().Get<PagesBuild>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pages/builds/latest"), null); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new RepositoryPagesClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name")); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Threading.Tasks; | ||
|
||
namespace Octokit | ||
{ | ||
/// <summary> | ||
/// A client for GitHub's Repository Pages API. | ||
/// </summary> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/">Repository Pages API documentation</a> for more information. | ||
/// </remarks> | ||
public interface IRepositoryPagesClient | ||
{ | ||
/// <summary> | ||
/// Gets the page metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] | ||
Task<Page> Get(string owner, string repositoryName); | ||
/// <summary> | ||
/// Gets all build metadata for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
Task<IReadOnlyList<PagesBuild>> GetAll(string owner, string repositoryName); | ||
/// <summary> | ||
/// Gets the build metadata for the last build for a given repository | ||
/// </summary> | ||
/// <param name="owner">The owner of the repository</param> | ||
/// <param name="repositoryName">The name of the repository</param> | ||
/// <remarks> | ||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information. | ||
/// </remarks> | ||
/// <returns></returns> | ||
Task<PagesBuild> GetLatest(string owner, string repositoryName); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how these tests should have passed before the merge, as I managed to break an old PR when I merged
master
back in. See 5ca6633 for the fix to these tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh!
I was going to remove that. Should I open a new PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, I'll merge that first pass at the documentation into
master
- so the fix will land there soon.