using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
namespace Octokit
{
///
/// A client for GitHub's Repositories API.
///
///
/// See the Repositories API documentation for more details.
///
public class RepositoriesClient : ApiClient, IRepositoriesClient
{
///
/// Initializes a new GitHub Repos API client.
///
/// An API connection
public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
{
Status = new CommitStatusClient(apiConnection);
Hooks = new RepositoryHooksClient(apiConnection);
Forks = new RepositoryForksClient(apiConnection);
Collaborator = new RepoCollaboratorsClient(apiConnection);
Statistics = new StatisticsClient(apiConnection);
Deployment = new DeploymentsClient(apiConnection);
PullRequest = new PullRequestsClient(apiConnection);
Comment = new RepositoryCommentsClient(apiConnection);
Commit = new RepositoryCommitsClient(apiConnection);
Release = new ReleasesClient(apiConnection);
DeployKeys = new RepositoryDeployKeysClient(apiConnection);
Merging = new MergingClient(apiConnection);
Content = new RepositoryContentsClient(apiConnection);
Page = new RepositoryPagesClient(apiConnection);
Invitation = new RepositoryInvitationsClient(apiConnection);
Branch = new RepositoryBranchesClient(apiConnection);
Traffic = new RepositoryTrafficClient(apiConnection);
Project = new ProjectsClient(apiConnection);
}
///
/// Creates a new repository for the current user.
///
///
/// See the API documentation for more information.
///
/// A instance describing the new repository to create
/// Thrown when a general API error occurs.
/// A instance for the created repository.
[ManualRoute("POST", "/user/repos")]
public Task Create(NewRepository newRepository)
{
Ensure.ArgumentNotNull(newRepository, nameof(newRepository));
return Create(ApiUrls.Repositories(), null, newRepository);
}
///
/// Creates a new repository in the specified organization.
///
///
/// See the API documentation for more information.
///
/// Login of the organization in which to create the repository
/// A instance describing the new repository to create
/// Thrown when a general API error occurs.
/// A instance for the created repository
[ManualRoute("POST", "/orgs/{org}/repos")]
public Task Create(string organizationLogin, NewRepository newRepository)
{
Ensure.ArgumentNotNull(organizationLogin, nameof(organizationLogin));
Ensure.ArgumentNotNull(newRepository, nameof(newRepository));
if (string.IsNullOrEmpty(newRepository.Name))
throw new ArgumentException("The new repository's name must not be null.");
return Create(ApiUrls.OrganizationRepositories(organizationLogin), organizationLogin, newRepository);
}
async Task Create(Uri url, string organizationLogin, NewRepository newRepository)
{
try
{
return await ApiConnection.Post(url, newRepository).ConfigureAwait(false);
}
catch (ApiValidationException e)
{
string errorMessage = e.ApiError.FirstErrorMessageSafe();
if (string.Equals(
"name already exists on this account",
errorMessage,
StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(organizationLogin))
{
throw new RepositoryExistsException(newRepository.Name, e);
}
var baseAddress = Connection.BaseAddress.Host != GitHubClient.GitHubApiUrl.Host
? Connection.BaseAddress
: new Uri("https://github.com/");
throw new RepositoryExistsException(
organizationLogin,
newRepository.Name,
baseAddress, e);
}
if (string.Equals(
"please upgrade your plan to create a new private repository.",
errorMessage,
StringComparison.OrdinalIgnoreCase))
{
throw new PrivateRepositoryQuotaExceededException(e);
}
if (string.Equals(
"name can't be private. You are over your quota.",
errorMessage,
StringComparison.OrdinalIgnoreCase))
{
throw new PrivateRepositoryQuotaExceededException(e);
}
if (errorMessage != null && errorMessage.EndsWith("is an unknown gitignore template.", StringComparison.OrdinalIgnoreCase))
{
throw new InvalidGitIgnoreTemplateException(e);
}
throw;
}
}
///
/// Deletes the specified repository.
///
///
/// See the API documentation for more information.
/// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required.
///
/// The owner of the repository
/// The name of the repository
/// Thrown when a general API error occurs.
[ManualRoute("DELETE", "/repos/{owner}/{repo}")]
public Task Delete(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Delete(ApiUrls.Repository(owner, name));
}
///
/// Deletes the specified repository.
///
///
/// See the API documentation for more information.
/// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required.
///
/// The Id of the repository
/// Thrown when a general API error occurs.
[ManualRoute("DELETE", "/repositories/{id}")]
public Task Delete(long repositoryId)
{
return ApiConnection.Delete(ApiUrls.Repository(repositoryId));
}
///
/// Transfers the ownership of the specified repository.
///
///
/// See the API documentation for more information.
///
/// The current owner of the repository
/// The name of the repository
/// Repository transfer information
/// A
[ManualRoute("POST", "/repos/{owner}/{repo}/transfer")]
public Task Transfer(string owner, string name, RepositoryTransfer repositoryTransfer)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(repositoryTransfer, nameof(repositoryTransfer));
return ApiConnection.Post(ApiUrls.RepositoryTransfer(owner, name), repositoryTransfer);
}
///
/// Transfers the ownership of the specified repository.
///
///
/// See the API documentation for more information.
///
/// The id of the repository
/// Repository transfer information
/// A
[ManualRoute("POST", "/repositories/{id}/transfer")]
public Task Transfer(long repositoryId, RepositoryTransfer repositoryTransfer)
{
Ensure.ArgumentNotNull(repositoryTransfer, nameof(repositoryTransfer));
return ApiConnection.Post(ApiUrls.RepositoryTransfer(repositoryId), repositoryTransfer);
}
///
/// Updates the specified repository with the values given in
///
/// The owner of the repository
/// The name of the repository
/// New values to update the repository with
/// The updated
[ManualRoute("PATCH", "/repos/{owner}/{repo}")]
public Task Edit(string owner, string name, RepositoryUpdate update)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(update, nameof(update));
Ensure.ArgumentNotNull(update.Name, nameof(update.Name));
return ApiConnection.Patch(ApiUrls.Repository(owner, name), update);
}
///
/// Updates the specified repository with the values given in
///
/// The Id of the repository
/// New values to update the repository with
/// The updated
[ManualRoute("PATCH", "/repositories/{id}")]
public Task Edit(long repositoryId, RepositoryUpdate update)
{
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Patch(ApiUrls.Repository(repositoryId), update);
}
///
/// Gets the specified repository.
///
///
/// See the API documentation for more information.
///
/// The owner of the repository
/// The name of the repository
/// Thrown when a general API error occurs.
/// A
[ManualRoute("GET", "/repos/{owner}/{repo}")]
public Task Get(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Get(ApiUrls.Repository(owner, name));
}
///
/// Gets the specified repository.
///
///
/// See the API documentation for more information.
///
/// The Id of the repository
/// Thrown when a general API error occurs.
/// A
[ManualRoute("GET", "/repositories/{id}")]
public Task Get(long repositoryId)
{
return ApiConnection.Get(ApiUrls.Repository(repositoryId));
}
///
/// Gets all public repositories.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/repositories")]
public Task> GetAllPublic()
{
return ApiConnection.GetAll(ApiUrls.AllPublicRepositories());
}
///
/// Gets all public repositories since the integer Id of the last Repository that you've seen.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Search parameters of the last repository seen
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/repositories")]
public Task> GetAllPublic(PublicRepositoryRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
var url = ApiUrls.AllPublicRepositories(request.Since);
return ApiConnection.GetAll(url);
}
///
/// Gets all repositories owned by the current user.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/repos")]
public Task> GetAllForCurrent()
{
return GetAllForCurrent(ApiOptions.None);
}
///
/// Gets all repositories owned by the current user.
///
///
/// See the API documentation for more information.
///
/// Options for changing the API response
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/repos")]
public Task> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Repositories(), options);
}
///
/// Gets all repositories owned by the current user.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Search parameters to filter results on
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/repos")]
public Task> GetAllForCurrent(RepositoryRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForCurrent(request, ApiOptions.None);
}
///
/// Gets all repositories owned by the current user.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Search parameters to filter results on
/// Options for changing the API response
/// Thrown if the client is not authenticated.
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/repos")]
public Task> GetAllForCurrent(RepositoryRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Repositories(), request.ToParametersDictionary(), options);
}
///
/// Gets all repositories owned by the specified user.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// The account name to search for
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/{username}/repos")]
public Task> GetAllForUser(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));
return GetAllForUser(login, ApiOptions.None);
}
///
/// Gets all repositories owned by the specified user.
///
///
/// See the API documentation for more information.
///
/// The account name to search for
/// Options for changing the API response
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/user/{username}/repos")]
public Task> GetAllForUser(string login, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Repositories(login), options);
}
///
/// Gets all repositories owned by the specified organization.
///
///
/// See the API documentation for more information.
/// The default page size on GitHub.com is 30.
///
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/orgs/{org}/repos")]
public Task> GetAllForOrg(string organization)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
return GetAllForOrg(organization, ApiOptions.None);
}
///
/// Gets all repositories owned by the specified organization.
///
///
/// See the API documentation for more information.
///
/// The organization name to search for
/// Options for changing the API response
/// Thrown when a general API error occurs.
/// A of .
[ManualRoute("GET", "/orgs/{org}/repos")]
public Task> GetAllForOrg(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.OrganizationRepositories(organization), options);
}
///
/// A client for GitHub's Repository Branches API.
///
///
/// See the Branches API documentation for more details
///
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public IRepositoryBranchesClient Branch { get; private set; }
///
/// A client for GitHub's Commit Status API.
///
///
/// See the Commit Status API documentation for more
/// details. Also check out the blog post
/// that announced this feature.
///
public ICommitStatusClient Status { get; private set; }
///
/// A client for GitHub's Repository Hooks API.
///
/// See Hooks API documentation for more information.
public IRepositoryHooksClient Hooks { get; private set; }
///
/// A client for GitHub's Repository Forks API.
///
/// See Forks API documentation for more information.
public IRepositoryForksClient Forks { get; private set; }
///
/// A client for GitHub's Repo Collaborators.
///
///
/// See the Collaborators API documentation for more details
///
public IRepoCollaboratorsClient Collaborator { get; private set; }
///
/// Client for GitHub's Repository Deployments API
///
///
/// See the Deployments API documentation for more details
///
public IDeploymentsClient Deployment { get; private set; }
///
/// Client for GitHub's Repository Statistics API
/// Note that the GitHub API uses caching on these endpoints,
/// see a word about caching for more details.
///
///
/// See the Statistics API documentation for more details
///
public IStatisticsClient Statistics { get; private set; }
///
/// Client for GitHub's Repository Commits API
///
///
/// See the Commits API documentation for more details
///
public IRepositoryCommitsClient Commit { get; private set; }
///
/// Access GitHub's Releases API.
///
///
/// Refer to the API documentation for more information: https://developer.github.com/v3/repos/releases/
///
public IReleasesClient Release { get; private set; }
///
/// Client for GitHub's Repository Merging API
///
///
/// See the Merging API documentation for more details
///
public IMergingClient Merging { get; private set; }
///
/// Client for managing pull requests.
///
///
/// See the Pull Requests API documentation for more details
///
public IPullRequestsClient PullRequest { get; private set; }
///
/// Client for managing commit comments in a repository.
///
///
/// See the Repository Comments API documentation for more information.
///
public IRepositoryCommentsClient Comment { get; private set; }
///
/// Client for managing deploy keys in a repository.
///
///
/// See the Repository Deploy Keys API documentation for more information.
///
public IRepositoryDeployKeysClient DeployKeys { get; private set; }
///
/// Client for managing the contents of a repository.
///
///
/// See the Repository Contents API documentation for more information.
///
public IRepositoryContentsClient Content { get; private set; }
///
/// Gets all contributors for the specified repository. Does not include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// All contributors of the repository.
[ManualRoute("GET", "/repos/{owner}/{repo}/contributors")]
public Task> GetAllContributors(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllContributors(owner, name, false);
}
///
/// Gets all contributors for the specified repository. Does not include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// All contributors of the repository.
[ManualRoute("GET", "/repositories/{id}/contributors")]
public Task> GetAllContributors(long repositoryId)
{
return GetAllContributors(repositoryId, false);
}
///
/// Gets all contributors for the specified repository. Does not include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
/// All contributors of the repository.
[ManualRoute("GET", "/repos/{owner}/{repo}/contributors")]
public Task> GetAllContributors(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return GetAllContributors(owner, name, false, options);
}
///
/// Gets all contributors for the specified repository. Does not include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// Options for changing the API response
/// All contributors of the repository.
[ManualRoute("GET", "/repositories/{id}/contributors")]
public Task> GetAllContributors(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return GetAllContributors(repositoryId, false, options);
}
///
/// Gets all contributors for the specified repository. With the option to include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// True if anonymous contributors should be included in result; Otherwise false
/// All contributors of the repository.
[ManualRoute("GET", "/repos/{owner}/{repo}/contributors")]
public Task> GetAllContributors(string owner, string name, bool includeAnonymous)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllContributors(owner, name, includeAnonymous, ApiOptions.None);
}
///
/// Gets all contributors for the specified repository. With the option to include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// True if anonymous contributors should be included in result; Otherwise false
/// All contributors of the repository.
[ManualRoute("GET", "/repositories/{id}/contributors")]
public Task> GetAllContributors(long repositoryId, bool includeAnonymous)
{
return GetAllContributors(repositoryId, includeAnonymous, ApiOptions.None);
}
///
/// Gets all contributors for the specified repository. With the option to include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// True if anonymous contributors should be included in result; Otherwise false
/// Options for changing the API response
/// All contributors of the repository.
[ManualRoute("GET", "/repos/{owner}/{repo}/contributors")]
public Task> GetAllContributors(string owner, string name, bool includeAnonymous, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
var parameters = new Dictionary();
if (includeAnonymous)
parameters.Add("anon", "1");
return ApiConnection.GetAll(ApiUrls.RepositoryContributors(owner, name), parameters, options);
}
///
/// Gets all contributors for the specified repository. With the option to include anonymous contributors.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// True if anonymous contributors should be included in result; Otherwise false
/// Options for changing the API response
/// All contributors of the repository.
[ManualRoute("GET", "/repositories/{id}/contributors")]
public Task> GetAllContributors(long repositoryId, bool includeAnonymous, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
var parameters = new Dictionary();
if (includeAnonymous)
parameters.Add("anon", "1");
return ApiConnection.GetAll(ApiUrls.RepositoryContributors(repositoryId), parameters, options);
}
///
/// Gets all languages for the specified repository.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// All languages used in the repository and the number of bytes of each language.
[ManualRoute("GET", "/repos/{owner}/{repo}/languages")]
public async Task> GetAllLanguages(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
var endpoint = ApiUrls.RepositoryLanguages(owner, name);
var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false);
return new ReadOnlyCollection(
(data ?? new Dictionary())
.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList());
}
///
/// Gets all languages for the specified repository.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// All languages used in the repository and the number of bytes of each language.
[ManualRoute("GET", "/repositories/{id}/languages")]
public async Task> GetAllLanguages(long repositoryId)
{
var endpoint = ApiUrls.RepositoryLanguages(repositoryId);
var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false);
return new ReadOnlyCollection(
(data ?? new Dictionary())
.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList());
}
///
/// Gets all teams for the specified repository.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// All s associated with the repository
[ManualRoute("GET", "/repos/{owner}/{repo}/teams")]
public Task> GetAllTeams(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllTeams(owner, name, ApiOptions.None);
}
///
/// Gets all teams for the specified repository.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// All s associated with the repository
[ManualRoute("GET", "/repositories/{id}/teams")]
public Task> GetAllTeams(long repositoryId)
{
return GetAllTeams(repositoryId, ApiOptions.None);
}
///
/// Gets all teams for the specified repository.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
/// All s associated with the repository
[ManualRoute("GET", "/repos/{owner}/{repo}/teams")]
public Task> GetAllTeams(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.RepositoryTeams(owner, name), options);
}
///
/// Gets all teams for the specified repository.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// Options for changing the API response
/// All s associated with the repository
[ManualRoute("GET", "/repositories/{id}/teams")]
public Task> GetAllTeams(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.RepositoryTeams(repositoryId), options);
}
///
/// Gets all tags for the specified repository.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// All of the repositories tags.
[ManualRoute("GET", "/repos/{owner}/{repo}/tags")]
public Task> GetAllTags(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllTags(owner, name, ApiOptions.None);
}
///
/// Gets all tags for the specified repository.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// All of the repositories tags.
[ManualRoute("GET", "/repositories/{id}/tags")]
public Task> GetAllTags(long repositoryId)
{
return GetAllTags(repositoryId, ApiOptions.None);
}
///
/// Gets all tags for the specified repository.
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
/// All of the repositories tags.
[ManualRoute("GET", "/repos/{owner}/{repo}/tags")]
public Task> GetAllTags(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.RepositoryTags(owner, name), options);
}
///
/// Gets all tags for the specified repository.
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// Options for changing the API response
/// All of the repositories tags.
[ManualRoute("GET", "/repositories/{id}/tags")]
public Task> GetAllTags(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.RepositoryTags(repositoryId), options);
}
///
/// Get the contents of a repository's license
///
///
/// See the API documentation for more details
///
/// The owner of the repository
/// The name of the repository
/// Returns the contents of the repository's license file, if one is detected.
[ManualRoute("GET", "/repos/{owner}/{repo}/license")]
public Task GetLicenseContents(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return ApiConnection.Get(ApiUrls.RepositoryLicense(owner, name));
}
///
/// Get the contents of a repository's license
///
///
/// See the API documentation for more details
///
/// The Id of the repository
/// Returns the contents of the repository's license file, if one is detected.
[ManualRoute("GET", "/repositories/{id}/license")]
public Task GetLicenseContents(long repositoryId)
{
return ApiConnection.Get(ApiUrls.RepositoryLicense(repositoryId));
}
///
/// A client for GitHub's Repository Pages API.
///
///
/// See the Repository Pages API documentation for more information.
///
public IRepositoryPagesClient Page { get; private set; }
///
/// A client for GitHub's Repository Invitations API.
///
///
/// See the Repository Invitations API documentation for more information.
///
public IRepositoryInvitationsClient Invitation { get; private set; }
///
/// Access GitHub's Repository Traffic API
///
///
/// Refer to the API documentation for more information: https://developer.github.com/v3/repos/traffic/
///
public IRepositoryTrafficClient Traffic { get; private set; }
///
/// Access GitHub's Repository Projects API
///
///
/// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/
///
public IProjectsClient Project { get; private set; }
}
}