From 1a5e3d15dc7ca4ded16d498bd5682e0e053ffd01 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber <mez613@gmail.com> Date: Fri, 15 Jan 2016 12:38:23 +0200 Subject: [PATCH] Add regular interface and models --- Octokit/Clients/IRepositoryPagesClient.cs | 40 ++++++++++++ Octokit/Models/Response/Page.cs | 76 +++++++++++++++++++++++ Octokit/Models/Response/PagesBuild.cs | 53 ++++++++++++++++ Octokit/Octokit.csproj | 3 + 4 files changed, 172 insertions(+) create mode 100644 Octokit/Clients/IRepositoryPagesClient.cs create mode 100644 Octokit/Models/Response/Page.cs create mode 100644 Octokit/Models/Response/PagesBuild.cs diff --git a/Octokit/Clients/IRepositoryPagesClient.cs b/Octokit/Clients/IRepositoryPagesClient.cs new file mode 100644 index 0000000000..71709f9f96 --- /dev/null +++ b/Octokit/Clients/IRepositoryPagesClient.cs @@ -0,0 +1,40 @@ +using Octokit.Models.Response; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Clients +{ + /// <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> + interface IRepositoryPagesClient + { + /// <summary> + /// Gets the page metadata for a given repository + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns></returns> + Task<IReadOnlyList<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="name">The name of the repository</param> + /// <returns></returns> + Task<IReadOnlyList<PagesBuild>> GetBuilds(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="name">The name of the repository</param> + /// <returns></returns> + Task<PagesBuild> GetLatestBuild(string owner, string repositoryName); + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Page.cs b/Octokit/Models/Response/Page.cs new file mode 100644 index 0000000000..ddfff06cf2 --- /dev/null +++ b/Octokit/Models/Response/Page.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Models.Response +{ + public enum PagesBuildStatus + { + /// <summary> + /// The site has yet to be built + /// </summary> + Null, + /// <summary> + /// The build is in progress + /// </summary> + Building, + /// <summary> + /// The site has been built + /// </summary> + Built, + /// <summary> + /// An error occurred during the build + /// </summary> + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Errored")] + Errored, + } + + ///<summary> + /// Information about your GitHub Pages configuration + ///</summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class Page + { + public Page() { } + + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "cname")] + public Page(string url, PagesBuildStatus status, string cname, bool custom404) + { + Url = url; + Status = status; + CName = cname; + Custom404 = custom404; + } + + /// <summary> + /// The pages's API URL. + /// </summary> + public string Url { get; protected set; } + /// <summary> + /// Build status of the pages site. + /// </summary> + public PagesBuildStatus Status { get; protected set; } + /// <summary> + /// CName of the pages site. Will be null if no CName was provided by the user. + /// </summary> + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "CName")] + public string CName { get; protected set; } + /// <summary> + /// Is a custom 404 page provided. + /// </summary> + public bool Custom404 { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "CName: {0}, Status: {1}", CName, Status.ToString()); + } + } + } +} diff --git a/Octokit/Models/Response/PagesBuild.cs b/Octokit/Models/Response/PagesBuild.cs new file mode 100644 index 0000000000..cc11a47d08 --- /dev/null +++ b/Octokit/Models/Response/PagesBuild.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Models.Response +{ + /// <summary> + /// Metadata of a Github Pages build. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PagesBuild + { + public PagesBuild() { } + + public PagesBuild(string url, PagesBuildStatus status, User pusher, Commit commit, TimeSpan duration, DateTime createdAt, DateTime updatedAt) + { + Url = url; + Status = status; + Pusher = pusher; + Commit = commit; + Duration = duration; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + } + + /// <summary> + /// The pages's API URL. + /// </summary> + public string Url { get; protected set; } + /// <summary> + /// The status of the build. + /// </summary> + public PagesBuildStatus Status { get; protected set; } + /// <summary> + /// The user whose commit intiated the build. + /// </summary> + public User Pusher { get; protected set; } + /// <summary> + /// Commit SHA. + /// </summary> + public Commit Commit { get; protected set; } + /// <summary> + /// Duration of the build + /// </summary> + public TimeSpan Duration { get; protected set; } + public DateTime CreatedAt { get; protected set; } + public DateTime UpdatedAt { get; protected set; } + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3bd8bb7a7c..7238ed974d 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -62,6 +62,7 @@ <Compile Include="Clients\IOAuthClient.cs" /> <Compile Include="Clients\IRepositoryCommitsClient.cs" /> <Compile Include="Clients\IRepositoryDeployKeysClient.cs" /> + <Compile Include="Clients\IRepositoryPagesClient.cs" /> <Compile Include="Clients\IUserKeysClient.cs" /> <Compile Include="Clients\MergingClient.cs" /> <Compile Include="Clients\OAuthClient.cs" /> @@ -133,6 +134,8 @@ <Compile Include="Models\Response\GitHubCommitFile.cs" /> <Compile Include="Models\Response\Meta.cs" /> <Compile Include="Models\Response\MiscellaneousRateLimit.cs" /> + <Compile Include="Models\Response\Page.cs" /> + <Compile Include="Models\Response\PagesBuild.cs" /> <Compile Include="Models\Response\PublicKey.cs" /> <Compile Include="Models\Response\PullRequestFile.cs" /> <Compile Include="Models\Response\ResourceRateLimit.cs" />