Add regular interface and models

This commit is contained in:
Mordechai Zuber
2016-01-15 12:38:23 +02:00
parent da45d9ebf6
commit 1a5e3d15dc
4 changed files with 172 additions and 0 deletions
+40
View File
@@ -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);
}
}
+76
View File
@@ -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());
}
}
}
}
+53
View File
@@ -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; }
}
}
+3
View File
@@ -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" />