using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Repository Pages API.
///
///
/// See the Repository Pages API documentation for more information.
///
public class RepositoryPagesClient : ApiClient, IRepositoryPagesClient
{
///
/// Initializes a new GitHub Repository Pages API client.
///
/// An API connection.
public RepositoryPagesClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
/// Gets the page metadata for a given repository
///
/// The owner of the repository
/// The name of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repos/{owner}/{repo}/pages")]
public Task Get(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Get(ApiUrls.RepositoryPage(owner, name));
}
///
/// Gets the page metadata for a given repository
///
/// The Id of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repositories/{id}/pages")]
public Task Get(long repositoryId)
{
return ApiConnection.Get(ApiUrls.RepositoryPage(repositoryId));
}
///
/// Gets all build metadata for a given repository
///
/// The owner of the repository
/// The name of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repos/{owner}/{repo}/pages/builds")]
public Task> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAll(owner, name, ApiOptions.None);
}
///
/// Gets all build metadata for a given repository
///
/// The Id of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repositories/{id}/pages/builds")]
public Task> GetAll(long repositoryId)
{
return GetAll(repositoryId, ApiOptions.None);
}
///
/// Gets all build metadata for a given repository
///
/// The owner of the repository
/// The name of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repos/{owner}/{repo}/pages/builds")]
public Task> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
var endpoint = ApiUrls.RepositoryPageBuilds(owner, name);
return ApiConnection.GetAll(endpoint, options);
}
///
/// Gets all build metadata for a given repository
///
/// The Id of the repository
/// Options to change the API response
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repositories/{id}/pages/builds")]
public Task> GetAll(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
var endpoint = ApiUrls.RepositoryPageBuilds(repositoryId);
return ApiConnection.GetAll(endpoint, options);
}
///
/// Gets the build metadata for the last build for a given repository
///
/// The owner of the repository
/// The name of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repos/{owner}/{repo}/pages/builds/latest")]
public Task GetLatest(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Get(ApiUrls.RepositoryPageBuildsLatest(owner, name));
}
///
/// Gets the build metadata for the last build for a given repository
///
/// The Id of the repository
///
/// See the API documentation for more information.
///
[ManualRoute("GET", "/repositories/{id}/pages/builds/latest")]
public Task GetLatest(long 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.
///
[ManualRoute("POST", "/repos/{owner}/{repo}/pages/builds")]
public Task RequestPageBuild(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Post(ApiUrls.RepositoryPageBuilds(owner, 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.
///
[ManualRoute("POST", "/repositories/{id}/pages/builds")]
public Task RequestPageBuild(long repositoryId)
{
return ApiConnection.Post(ApiUrls.RepositoryPageBuilds(repositoryId));
}
}
}