diff --git a/Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
index 8b9c19ad7b..fab7b1e556 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
@@ -25,7 +25,7 @@ public interface IObservableRepositoryPagesClient
///
/// Gets the page metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -45,7 +45,7 @@ public interface IObservableRepositoryPagesClient
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -65,7 +65,7 @@ public interface IObservableRepositoryPagesClient
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
@@ -85,10 +85,29 @@ public interface IObservableRepositoryPagesClient
///
/// Gets the build metadata for the last build for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
IObservable GetLatest(int repositoryId);
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ IObservable RequestPageBuild(string owner, string name);
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The Id of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ IObservable RequestPageBuild(int repositoryId);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
index 1c61be78e5..08afa26f78 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
@@ -44,7 +44,7 @@ public IObservable Get(string owner, string name)
///
/// Gets the page metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -72,7 +72,7 @@ public IObservable GetAll(string owner, string name)
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -102,7 +102,7 @@ public IObservable GetAll(string owner, string name, ApiOptions opti
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
@@ -133,7 +133,7 @@ public IObservable GetLatest(string owner, string name)
///
/// Gets the build metadata for the last build for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -141,5 +141,33 @@ public IObservable GetLatest(int repositoryId)
{
return _client.GetLatest(repositoryId).ToObservable();
}
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ public IObservable RequestPageBuild(string owner, string name)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
+ return _client.RequestPageBuild(owner, name).ToObservable();
+ }
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The Id of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ public IObservable RequestPageBuild(int repositoryId)
+ {
+ return _client.RequestPageBuild(repositoryId).ToObservable();
+ }
}
}
diff --git a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs
index 1addcc7af6..0e7fbfcfa6 100644
--- a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs
@@ -49,6 +49,9 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.Get(null, "name"));
await Assert.ThrowsAsync(() => client.Get("owner", null));
+
+ await Assert.ThrowsAsync(() => client.Get("", "name"));
+ await Assert.ThrowsAsync(() => client.Get("owner", ""));
}
}
@@ -161,6 +164,47 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.GetLatest(null, "name"));
await Assert.ThrowsAsync(() => client.GetLatest("owner", null));
+
+ await Assert.ThrowsAsync(() => client.GetLatest("", "name"));
+ await Assert.ThrowsAsync(() => client.GetLatest("owner", ""));
+ }
+ }
+
+ public class TheRequestPageBuildMethod
+ {
+ [Fact]
+ public async Task PostsToCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryPagesClient(connection);
+
+ await client.RequestPageBuild("fake", "repo");
+
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/pages/builds"), "application/vnd.github.mister-fantastic-preview+json");
+ }
+
+ [Fact]
+ public async Task PostsToCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryPagesClient(connection);
+
+ await client.RequestPageBuild(1);
+
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/pages/builds"), "application/vnd.github.mister-fantastic-preview+json");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryPagesClient(connection);
+
+ await Assert.ThrowsAsync(() => client.RequestPageBuild(null, "name"));
+ await Assert.ThrowsAsync(() => client.RequestPageBuild("owner", null));
+
+ await Assert.ThrowsAsync(() => client.RequestPageBuild("", "name"));
+ await Assert.ThrowsAsync(() => client.RequestPageBuild("owner", ""));
}
}
}
diff --git a/Octokit.Tests/Reactive/ObservableRepositoryPagesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryPagesClientTests.cs
index 90ceef4346..a0fe1e78e1 100644
--- a/Octokit.Tests/Reactive/ObservableRepositoryPagesClientTests.cs
+++ b/Octokit.Tests/Reactive/ObservableRepositoryPagesClientTests.cs
@@ -48,6 +48,9 @@ public void EnsuresNonNullArguments()
Assert.Throws(() => client.Get(null, "name"));
Assert.Throws(() => client.Get("owner", null));
+
+ Assert.Throws(() => client.Get("", "name"));
+ Assert.Throws(() => client.Get("owner", ""));
}
}
@@ -160,6 +163,47 @@ public void EnsuresNonNullArguments()
Assert.Throws(() => client.GetLatest(null, "name"));
Assert.Throws(() => client.GetLatest("owner", null));
+
+ Assert.Throws(() => client.GetLatest("", "name"));
+ Assert.Throws(() => client.GetLatest("owner", ""));
+ }
+ }
+
+ public class TheRequestPageBuildMethod
+ {
+ [Fact]
+ public void PostsToCorrectUrl()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryPagesClient(gitHubClient);
+
+ client.RequestPageBuild("fake", "repo");
+
+ gitHubClient.Received().Repository.Page.RequestPageBuild("fake", "repo");
+ }
+
+ [Fact]
+ public void PostsToCorrectUrlWithRepositoryId()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryPagesClient(gitHubClient);
+
+ client.RequestPageBuild(1);
+
+ gitHubClient.Received().Repository.Page.RequestPageBuild(1);
+ }
+
+ [Fact]
+ public void EnsuresNonNullArguments()
+ {
+ var gitHubClient = Substitute.For();
+ var client = new ObservableRepositoryPagesClient(gitHubClient);
+
+ Assert.Throws(() => client.RequestPageBuild(null, "name"));
+ Assert.Throws(() => client.RequestPageBuild("owner", null));
+
+ Assert.Throws(() => client.RequestPageBuild("", "name"));
+ Assert.Throws(() => client.RequestPageBuild("owner", ""));
}
}
}
diff --git a/Octokit/Clients/IRepositoryPagesClient.cs b/Octokit/Clients/IRepositoryPagesClient.cs
index 56747d9d2f..614abd2717 100644
--- a/Octokit/Clients/IRepositoryPagesClient.cs
+++ b/Octokit/Clients/IRepositoryPagesClient.cs
@@ -26,7 +26,7 @@ public interface IRepositoryPagesClient
///
/// Gets the page metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -46,7 +46,7 @@ public interface IRepositoryPagesClient
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -66,7 +66,7 @@ public interface IRepositoryPagesClient
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
@@ -86,10 +86,29 @@ public interface IRepositoryPagesClient
///
/// Gets the build metadata for the last build for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
Task GetLatest(int repositoryId);
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ Task RequestPageBuild(string owner, string name);
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The Id of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ Task RequestPageBuild(int repositoryId);
}
}
diff --git a/Octokit/Clients/RepositoryPagesClient.cs b/Octokit/Clients/RepositoryPagesClient.cs
index af3ff7c791..808e43073c 100644
--- a/Octokit/Clients/RepositoryPagesClient.cs
+++ b/Octokit/Clients/RepositoryPagesClient.cs
@@ -38,7 +38,7 @@ public Task Get(string owner, string name)
///
/// Gets the page metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -66,7 +66,7 @@ public Task> GetAll(string owner, string name)
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -97,7 +97,7 @@ public Task> GetAll(string owner, string name, ApiOpti
///
/// Gets all build metadata for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
@@ -129,7 +129,7 @@ public Task GetLatest(string owner, string name)
///
/// Gets the build metadata for the last build for a given repository
///
- /// The ID of the repository
+ /// The Id of the repository
///
/// See the API documentation for more information.
///
@@ -137,5 +137,33 @@ public Task GetLatest(int repositoryId)
{
return ApiConnection.Get(ApiUrls.RepositoryPageBuildsLatest(repositoryId));
}
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ public Task RequestPageBuild(string owner, string name)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
+ return ApiConnection.Post(ApiUrls.RepositoryPageBuilds(owner, name), AcceptHeaders.PagesApiPreview);
+ }
+
+ ///
+ /// Requests your site be built from the latest revision on the default branch for a given repository
+ ///
+ /// The Id of the repository
+ ///
+ /// See the API documentation for more information.
+ ///
+ public Task RequestPageBuild(int repositoryId)
+ {
+ return ApiConnection.Post(ApiUrls.RepositoryPageBuilds(repositoryId), AcceptHeaders.PagesApiPreview);
+ }
}
}
diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs
index dfb37c0ec3..169fed930c 100644
--- a/Octokit/Helpers/AcceptHeaders.cs
+++ b/Octokit/Helpers/AcceptHeaders.cs
@@ -34,5 +34,7 @@ public static class AcceptHeaders
public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview";
public const string DeploymentApiPreview = "application/vnd.github.ant-man-preview+json";
+
+ public const string PagesApiPreview = "application/vnd.github.mister-fantastic-preview+json";
}
}
diff --git a/Octokit/Models/Response/Page.cs b/Octokit/Models/Response/Page.cs
index 7a2aeda8f1..10a8672b4b 100644
--- a/Octokit/Models/Response/Page.cs
+++ b/Octokit/Models/Response/Page.cs
@@ -10,14 +10,17 @@ public enum PagesBuildStatus
/// The site has yet to be built
///
Null,
+
///
/// The build is in progress
///
Building,
+
///
/// The site has been built
///
Built,
+
///
/// An error occurred during the build
///
@@ -46,15 +49,23 @@ public Page(string url, PagesBuildStatus status, string cname, bool custom404)
/// The pages's API URL.
///
public string Url { get; protected set; }
+
+ ///
+ /// Absolute URL to the rendered site.
+ ///
+ public string HtmlUrl { get; protected set; }
+
///
/// Build status of the pages site.
///
public PagesBuildStatus Status { get; protected set; }
+
///
/// CName of the pages site. Will be null if no CName was provided by the user.
///
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "CName")]
public string CName { get; protected set; }
+
///
/// Is a custom 404 page provided.
///
@@ -62,10 +73,7 @@ public Page(string url, PagesBuildStatus status, string cname, bool custom404)
internal string DebuggerDisplay
{
- get
- {
- return string.Format(CultureInfo.InvariantCulture, "CName: {0}, Status: {1}", CName, Status.ToString());
- }
+ get { return string.Format(CultureInfo.InvariantCulture, "CName: {0}, Status: {1}", CName, Status.ToString()); }
}
}
}