[FEAT] Self-hosted runners and Self-hosted runner groups APIs

This commit is contained in:
Liam Neville
2023-04-28 11:03:15 -07:00
committed by GitHub
parent a3299ac4b4
commit 2d4ba4e891
19 changed files with 3061 additions and 12 deletions

View File

@@ -1,4 +1,6 @@
namespace Octokit.Reactive
using System;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Actions Self-hosted runner groups API.
@@ -8,5 +10,127 @@
/// </remarks>
public interface IObservableActionsSelfHostedRunnerGroupsClient
{
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
IObservable<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise);
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="options">Options for changing the API response</param>
IObservable<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// List self-hosted runner groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
IObservable<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org);
/// <summary>
/// List self-hosted runner groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="options">Options for changing the API response</param>
IObservable<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org, ApiOptions options);
/// <summary>
/// Gets a list of all self-hosted runners in a group for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
IObservable<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId);
/// <summary>
/// Gets a list of all self-hosted runners in a group for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options);
/// <summary>
/// Gets a list of all self-hosted runners in a group for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId);
/// <summary>
/// Gets a list of all self-hosted runners in a group for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options);
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
}
}

View File

@@ -1,4 +1,8 @@
namespace Octokit.Reactive
using System;
using System.Collections.Generic;
using System.Reactive;
namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's Actions Self-hosted runners API.
@@ -8,5 +12,247 @@
/// </remarks>
public interface IObservableActionsSelfHostedRunnersClient
{
/// <summary>
/// Gets a list of all self-hosted runners for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
IObservable<RunnerResponse> ListAllRunnersForEnterprise(string enterprise);
/// <summary>
/// Gets a list of all self-hosted runners for an enterprise.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerResponse> ListAllRunnersForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// Gets a list of all self-hosted runners for an organization.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
IObservable<RunnerResponse> ListAllRunnersForOrganization(string organization);
/// <summary>
/// Gets a list of all self-hosted runners for an organization.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerResponse> ListAllRunnersForOrganization(string organization, ApiOptions options);
/// <summary>
/// Gets a list of all self-hosted runners for a repository.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
IObservable<RunnerResponse> ListAllRunnersForRepository(string owner, string name);
/// <summary>
/// Gets a list of all self-hosted runners for a repository.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerResponse> ListAllRunnersForRepository(string owner, string name, ApiOptions options);
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForEnterprise(string enterprise);
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForOrganization(string organization);
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options);
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForRepository(string owner, string name);
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<RunnerApplication> ListAllRunnerApplicationsForRepository(string owner, string name, ApiOptions options);
/// <summary>
/// Deletes a self-hosted runner from an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner ID.</param>
IObservable<Unit> DeleteEnterpriseRunner(string enterprise, long runnerId);
/// <summary>
/// Deletes a self-hosted runner from an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<Unit> DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions options);
/// <summary>
/// Deletes a self-hosted runner from an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner ID.</param>
IObservable<Unit> DeleteOrganizationRunner(string organization, long runnerId);
/// <summary>
/// Deletes a self-hosted runner from an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<Unit> DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options);
/// <summary>
/// Deletes a self-hosted runner from a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner ID.</param>
IObservable<Unit> DeleteRepositoryRunner(string owner, string name, long runnerId);
/// <summary>
/// Deletes a self-hosted runner from a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<Unit> DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options);
/// <summary>
/// Create a registration token for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
IObservable<AccessToken> CreateEnterpriseRegistrationToken(string enterprise);
/// <summary>
/// Create a registration token for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<AccessToken> CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options);
/// <summary>
/// Create a registration token for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
IObservable<AccessToken> CreateOrganizationRegistrationToken(string organization);
/// <summary>
/// Create a registration token for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<AccessToken> CreateOrganizationRegistrationToken(string organization, ApiOptions options);
/// <summary>
/// Create a registration token for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
IObservable<AccessToken> CreateRepositoryRegistrationToken(string owner, string name);
/// <summary>
/// Create a registration token for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
IObservable<AccessToken> CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options);
}
}

View File

@@ -1,8 +1,13 @@
namespace Octokit.Reactive
using System;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableActionsSelfHostedRunnerGroupsClient : IObservableActionsSelfHostedRunnerGroupsClient
{
readonly IActionsSelfHostedRunnerGroupsClient _client;
readonly IConnection _connection;
/// <summary>
/// Instantiate a new GitHub Actions Self-hosted runner groups API client.
@@ -13,6 +18,184 @@
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Actions.SelfHostedRunnerGroups;
}
_connection = client.Connection;
}
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
public IObservable<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise)
{
return ListAllRunnerGroupsForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnerGroupsForEnterprise(enterprise, options).ToObservable();
}
/// <summary>
/// List self-hosted runner groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
public IObservable<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org)
{
return ListAllRunnerGroupsForOrganization(org, ApiOptions.None);
}
/// <summary>
/// List self-hosted runner groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnerGroupsForOrganization(org, options).ToObservable();
}
/// <summary>
/// Lists all self-hosted runners in a self-hosted runner group configured in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="groupId">The runner group ID</param>
public IObservable<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long groupId)
{
return ListAllRunnersForEnterpriseRunnerGroup(enterprise, groupId, ApiOptions.None);
}
/// <summary>
/// Lists all self-hosted runners in a self-hosted runner group configured in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="groupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long groupId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnersForEnterpriseRunnerGroup(enterprise, groupId, options).ToObservable();
}
/// <summary>
/// Lists all self-hosted runners in a self-hosted runner group configured in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization name</param>
/// <param name="groupId">The runner group ID</param>
public IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long groupId)
{
return ListAllRunnersForOrganizationRunnerGroup(organization, groupId, ApiOptions.None);
}
/// <summary>
/// Lists all self-hosted runners in a self-hosted runner group configured in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization name</param>
/// <param name="groupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long groupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnersForOrganizationRunnerGroup(organization, groupId, options).ToObservable();
}
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
{
return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<Organization>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options);
}
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
{
return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options);
}
}
}

View File

@@ -1,8 +1,15 @@
namespace Octokit.Reactive
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Threading.Tasks;
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableActionsSelfHostedRunnersClient : IObservableActionsSelfHostedRunnersClient
{
readonly IActionsSelfHostedRunnersClient _client;
readonly IConnection _connection;
/// <summary>
/// Instantiate a new GitHub Actions Self-hosted runners API client.
@@ -13,6 +20,352 @@
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Actions.SelfHostedRunners;
_connection = client.Connection;
}
/// <summary>
/// Lists self-hosted runners for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
public IObservable<RunnerResponse> ListAllRunnersForEnterprise(string enterprise)
{
return ListAllRunnersForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// Lists self-hosted runners for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerResponse> ListAllRunnersForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnersForEnterprise(enterprise, options).ToObservable();
}
/// <summary>
/// Lists self-hosted runners for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
public IObservable<RunnerResponse> ListAllRunnersForOrganization(string organization)
{
return ListAllRunnersForOrganization(organization, ApiOptions.None);
}
/// <summary>
/// Lists self-hosted runners for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerResponse> ListAllRunnersForOrganization(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnersForOrganization(organization, options).ToObservable();
}
/// <summary>
/// Lists self-hosted runners for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
public IObservable<RunnerResponse> ListAllRunnersForRepository(string owner, string name)
{
return ListAllRunnersForRepository(owner, name, ApiOptions.None);
}
/// <summary>
/// Lists self-hosted runners for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerResponse> ListAllRunnersForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.ListAllRunnersForRepository(owner, name, options).ToObservable();
}
/// <summary>
/// Lists all runner applications for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForEnterprise(string enterprise)
{
return ListAllRunnerApplicationsForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// Lists all runner applications for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<RunnerApplication>(ApiUrls.ActionsListRunnerApplicationsForEnterprise(enterprise));
}
/// <summary>
/// Lists all runner applications for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForOrganization(string organization)
{
return ListAllRunnerApplicationsForOrganization(organization, ApiOptions.None);
}
/// <summary>
/// Lists all runner applications for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<RunnerApplication>(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization));
}
/// <summary>
/// Lists all runner applications for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForRepository(string owner, string name)
{
return ListAllRunnerApplicationsForRepository(owner, name, ApiOptions.None);
}
/// <summary>
/// Lists all runner applications for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RunnerApplication> ListAllRunnerApplicationsForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<RunnerApplication>(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, name));
}
/// <summary>
/// Deletes a self-hosted runner from an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner id.</param>
public IObservable<Unit> DeleteEnterpriseRunner(string enterprise, long runnerId)
{
return DeleteEnterpriseRunner(enterprise, runnerId, ApiOptions.None);
}
/// <summary>
/// Deletes a self-hosted runner from an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Unit> DeleteEnterpriseRunner(string enterprise, long groupId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.DeleteEnterpriseRunner(enterprise, groupId, options).ToObservable();
}
/// <summary>
/// Deletes a self-hosted runner from an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner id.</param>
public IObservable<Unit> DeleteOrganizationRunner(string organization, long runnerId)
{
return DeleteOrganizationRunner(organization, runnerId, ApiOptions.None);
}
/// <summary>
/// Deletes a self-hosted runner from an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Unit> DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.DeleteOrganizationRunner(organization, runnerId, options).ToObservable();
}
/// <summary>
/// Deletes a self-hosted runner from a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner id.</param>
public IObservable<Unit> DeleteRepositoryRunner(string owner, string name, long runnerId)
{
return DeleteRepositoryRunner(owner, name, runnerId, ApiOptions.None);
}
/// <summary>
/// Deletes a self-hosted runner from a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Unit> DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.DeleteRepositoryRunner(owner, name, runnerId, options).ToObservable();
}
/// <summary>
/// Creates a registration token for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
public IObservable<AccessToken> CreateEnterpriseRegistrationToken(string enterprise)
{
return CreateEnterpriseRegistrationToken(enterprise, ApiOptions.None);
}
/// <summary>
/// Creates a registration token for an enterprise.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<AccessToken> CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.CreateEnterpriseRegistrationToken(enterprise, options).ToObservable();
}
/// <summary>
/// Creates a registration token for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
public IObservable<AccessToken> CreateOrganizationRegistrationToken(string organization)
{
return CreateOrganizationRegistrationToken(organization, ApiOptions.None);
}
/// <summary>
/// Creates a registration token for an organization.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<AccessToken> CreateOrganizationRegistrationToken(string organization, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.CreateOrganizationRegistrationToken(organization, options).ToObservable();
}
/// <summary>
/// Creates a registration token for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
public IObservable<AccessToken> CreateRepositoryRegistrationToken(string owner, string name)
{
return CreateRepositoryRegistrationToken(owner, name, ApiOptions.None);
}
/// <summary>
/// Creates a registration token for a repository.
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<AccessToken> CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _client.CreateRepositoryRegistrationToken(owner, name, options).ToObservable();
}
}
}

View File

@@ -0,0 +1,210 @@
using System;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;
namespace Octokit.Tests.Clients
{
public class ActionsSelfHostedRunnerGroupsClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new ActionsSelfHostedRunnerGroupsClient(null));
}
}
public class TheListAllRunnerGroupsForEnterpriseMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnerGroupsForEnterprise("fake");
connection.Received().GetAll<RunnerGroupResponse>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runner-groups"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerGroupsForEnterprise(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerGroupsForEnterprise(""));
}
}
public class TheListAllRunnerGroupsForOrganizationMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnerGroupsForOrganization("fake");
connection.Received().GetAll<RunnerGroupResponse>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runner-groups"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerGroupsForOrganization(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerGroupsForOrganization(""));
}
}
public class TheListAllRunnersForEnterpriseRunnerGroupMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnersForEnterpriseRunnerGroup("fake", 1);
connection.Received().GetAll<RunnerResponse>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runner-groups/1/runners"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForEnterpriseRunnerGroup(null, 1));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForEnterpriseRunnerGroup("", 1));
}
}
public class TheListAllRunnersForOrganizationRunnerGroupMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnersForOrganizationRunnerGroup("fake", 1);
connection.Received().GetAll<RunnerResponse>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runner-groups/1/runners"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForOrganizationRunnerGroup(null, 1));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForOrganizationRunnerGroup("", 1));
}
}
public class TheListAllRunnerGroupOrganizationsForEnterpriseMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnerGroupOrganizationsForEnterprise("fake", 1);
connection.Received().GetAll<Organization>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runner-groups/1/organizations"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerGroupOrganizationsForEnterprise(null, 1, ApiOptions.None));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerGroupOrganizationsForEnterprise("", 1, ApiOptions.None));
}
}
public class TheListAllRunnerGroupRepositoriesForOrganizationMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
await client.ListAllRunnerGroupRepositoriesForOrganization("fake", 1, ApiOptions.None);
connection.Received().GetAll<Repository>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runner-groups/1/repositories"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerGroupRepositoriesForOrganization(null, 1, ApiOptions.None));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerGroupRepositoriesForOrganization("", 1, ApiOptions.None));
}
}
}
}

View File

@@ -0,0 +1,438 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NSubstitute;
using Xunit;
namespace Octokit.Tests.Clients
{
public class ActionsSelfHostedRunnersClientTests
{
public class TheCtor
{
[Fact]
public void EnsuresNonNullArguments()
{
Assert.Throws<ArgumentNullException>(() => new ActionsSelfHostedRunnersClient(null));
}
}
public class TheListAllRunnersForEnterproseMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnersForEnterprise("fake");
connection.Received().GetAll<RunnerResponse>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runners"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForEnterprise(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForEnterprise(""));
}
}
public class TheListAllRunnersForOrganizationMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnersForOrganization("fake");
connection.Received().GetAll<RunnerResponse>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runners"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForOrganization(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForOrganization(""));
}
}
public class TheListAllRunnersForRepositoryMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnersForRepository("fake", "repo");
connection.Received().GetAll<RunnerResponse>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runners"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForRepository(null, "repo"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnersForRepository("fake", null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForRepository("", "repo"));
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnersForRepository("fake", ""));
}
}
public class TheListAllRunnerApplicationsForEnterpriseMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnerApplicationsForEnterprise("fake");
connection.Received().GetAll<IReadOnlyList<RunnerApplication>>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runners/downloads"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerApplicationsForEnterprise(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerApplicationsForEnterprise(""));
}
}
public class TheListAllRunnerApplicationsForOrganizationMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnerApplicationsForOrganization("fake");
connection.Received().GetAll<IReadOnlyList<RunnerApplication>>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runners/downloads"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerApplicationsForOrganization(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerApplicationsForOrganization(""));
}
}
public class TheListAllRunnerApplicationsForRepositoryMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.ListAllRunnerApplicationsForRepository("fake", "repo");
connection.Received().GetAll<IReadOnlyList<RunnerApplication>>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runners/downloads"), Args.ApiOptions);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerApplicationsForRepository(null, "repo"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListAllRunnerApplicationsForRepository("fake", null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerApplicationsForRepository("", "repo"));
await Assert.ThrowsAsync<ArgumentException>(() => client.ListAllRunnerApplicationsForRepository("fake", ""));
}
}
public class TheDeleteEnterpriseRunnerMethod
{
[Fact]
public async Task RequstsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.DeleteEnterpriseRunner("fake", 1);
connection.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runners/1"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteEnterpriseRunner(null, 1));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteEnterpriseRunner("", 1));
}
}
public class TheDeleteOrganizationRunnerMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.DeleteOrganizationRunner("fake", 1);
connection.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runners/1"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteOrganizationRunner(null, 1));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteOrganizationRunner("", 1));
}
}
public class TheDeleteRepositoryRunnerMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.DeleteRepositoryRunner("fake", "repo", 1);
connection.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runners/1"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRepositoryRunner(null, "repo", 1));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteRepositoryRunner("fake", null, 1));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRepositoryRunner("", "repo", 1));
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteRepositoryRunner("fake", "", 1));
}
}
public class TheCreateEnterpriseRegistrationTokenMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.CreateEnterpriseRegistrationToken("fake");
connection.Received().Post<AccessToken>(
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runners/registration-token"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateEnterpriseRegistrationToken(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateEnterpriseRegistrationToken(""));
}
}
public class TheCreateOrganizationRegistrationTokenMethod
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.CreateOrganizationRegistrationToken("fake");
connection.Received().Post<AccessToken>(
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runners/registration-token"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrganizationRegistrationToken(null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrganizationRegistrationToken(""));
}
}
public class TheCreateRepositoryRegistrationToken
{
[Fact]
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await client.CreateRepositoryRegistrationToken("fake", "repo");
connection.Received().Post<AccessToken>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runners/registration-token"),
ApiOptions.None);
}
[Fact]
public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateRepositoryRegistrationToken(null, "repo"));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateRepositoryRegistrationToken("fake", null));
}
[Fact]
public async Task EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new ActionsSelfHostedRunnersClient(connection);
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateRepositoryRegistrationToken("", "repo"));
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateRepositoryRegistrationToken("fake", ""));
}
}
}
}

View File

@@ -1,4 +1,8 @@
namespace Octokit
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Actions Self-hosted runner groups API.
@@ -15,5 +19,209 @@
public ActionsSelfHostedRunnerGroupsClient(IApiConnection apiConnection) : base(apiConnection)
{
}
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups")]
public Task<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise)
{
return ListAllRunnerGroupsForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups")]
public async Task<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
var results = await ApiConnection.GetAll<RunnerGroupResponse>(ApiUrls.ActionsListEnterpriseRunnerGroups(enterprise), options).ConfigureAwait(false);
return new RunnerGroupResponse(
results.Count > 0 ? results[0].TotalCount : 0,
results.SelectMany(x => x.RunnerGroups).ToList()
);
}
/// <summary>
/// List self-hosted runners groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups")]
public Task<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org)
{
return ListAllRunnerGroupsForOrganization(org, ApiOptions.None);
}
/// <summary>
/// List self-hosted runners groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups")]
public async Task<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
var results = await ApiConnection.GetAll<RunnerGroupResponse>(ApiUrls.ActionsListOrganizationRunnerGroups(org), options).ConfigureAwait(false);
return new RunnerGroupResponse(
results.Count > 0 ? results[0].TotalCount : 0,
results.SelectMany(x => x.RunnerGroups).ToList()
);
}
/// <summary>
/// List self-hosted runners in a group for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners")]
public Task<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId)
{
return ListAllRunnersForEnterpriseRunnerGroup(enterprise, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List self-hosted runners in a group for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners")]
public async Task<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
var results = await ApiConnection.GetAll<RunnerResponse>(ApiUrls.ActionsListSelfHostedRunnersForEnterpriseRunnerGroup(enterprise, runnerGroupId), options).ConfigureAwait(false);
return new RunnerResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Runners).ToList()
);
}
/// <summary>
/// List self-hosted runners in a group for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/runners")]
public Task<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId)
{
return ListAllRunnersForOrganizationRunnerGroup(organization, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List self-hosted runners in a group for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/runners")]
public async Task<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
var results = await ApiConnection.GetAll<RunnerResponse>(ApiUrls.ActionsListSelfHostedRunnersForOrganizationRunnerGroup(organization, runnerGroupId), options).ConfigureAwait(false);
return new RunnerResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Runners).ToList()
);
}
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")]
public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
{
return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")]
public Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
return ApiConnection.GetAll<Organization>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options);
}
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")]
public Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
{
return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None);
}
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")]
public Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
return ApiConnection.GetAll<Repository>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options);
}
}
}

View File

@@ -1,10 +1,14 @@
namespace Octokit
using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Actions Self-hosted runners API.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runners/">Actions Self-hosted runners API documentation</a> for more information.
/// See the <a href="https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#about-self-hosted-runners-in-github-actions">Actions Self-hosted runners API documentation</a> for more information.
/// </remarks>
public class ActionsSelfHostedRunnersClient : ApiClient, IActionsSelfHostedRunnersClient
{
@@ -15,5 +19,396 @@
public ActionsSelfHostedRunnersClient(IApiConnection apiConnection) : base(apiConnection)
{
}
/// <summary>
/// Lists all self-hosted runners for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runners")]
public Task<RunnerResponse> ListAllRunnersForEnterprise(string enterprise)
{
return ListAllRunnersForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// Lists all self-hosted runners for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runners")]
public async Task<RunnerResponse> ListAllRunnersForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
Ensure.ArgumentNotNull(options, nameof(options));
var results = await ApiConnection.GetAll<RunnerResponse>(ApiUrls.ActionsListSelfHostedRunnersForEnterprise(enterprise), options).ConfigureAwait(false);
return new RunnerResponse(
results.Count > 0 ? results[0].TotalCount : 0,
results.SelectMany(x => x.Runners).ToList()
);
}
/// <summary>
/// Lists all self-hosted runners for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
[ManualRoute("GET", "/orgs/{org}/actions/runners")]
public Task<RunnerResponse> ListAllRunnersForOrganization(string organization)
{
return ListAllRunnersForOrganization(organization, ApiOptions.None);
}
/// <summary>
/// Lists all self-hosted runners for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runners")]
public async Task<RunnerResponse> ListAllRunnersForOrganization(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
var results = await ApiConnection.GetAll<RunnerResponse>(ApiUrls.ActionsListSelfHostedRunnersForOrganization(organization), options).ConfigureAwait(false);
return new RunnerResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Runners).ToList()
);
}
/// <summary>
/// Lists all self-hosted runners for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners")]
public Task<RunnerResponse> ListAllRunnersForRepository(string owner, string name)
{
return ListAllRunnersForRepository(owner, name, ApiOptions.None);
}
/// <summary>
/// Lists all self-hosted runners for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners")]
public async Task<RunnerResponse> ListAllRunnersForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
var results = await ApiConnection.GetAll<RunnerResponse>(ApiUrls.ActionsListSelfHostedRunnersForRepository(owner, name), options).ConfigureAwait(false);
return new RunnerResponse(
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
results.SelectMany(x => x.Runners).ToList()
);
}
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runners/downloads")]
public Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForEnterprise(string enterprise)
{
return ListAllRunnerApplicationsForEnterprise(enterprise, ApiOptions.None);
}
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runners/downloads")]
public async Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
var results = await ApiConnection.GetAll<IReadOnlyList<RunnerApplication>>(ApiUrls.ActionsListRunnerApplicationsForEnterprise(enterprise), options).ConfigureAwait(false);
return results.SelectMany(x => x).ToList();
}
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
[ManualRoute("GET", "/orgs/{org}/actions/runners/downloads")]
public Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForOrganization(string organization)
{
return ListAllRunnerApplicationsForOrganization(organization, ApiOptions.None);
}
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/orgs/{org}/actions/runners/downloads")]
public async Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
var results = await ApiConnection.GetAll<IReadOnlyList<RunnerApplication>>(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization), options).ConfigureAwait(false);
return results.SelectMany(x => x).ToList();
}
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners/downloads")]
public Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForRepository(string owner, string repo)
{
return ListAllRunnerApplicationsForRepository(owner, repo, ApiOptions.None);
}
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners/downloads")]
public async Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForRepository(string owner, string repo, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
var results = await ApiConnection.GetAll<IReadOnlyList<RunnerApplication>>(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, repo), options).ConfigureAwait(false);
return results.SelectMany(x => x).ToList();
}
/// <summary>
/// Delete a self-hosted runner from an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner id.</param>
[ManualRoute("DELETE", "/enterprises/{enterprise}/actions/runners/{runner_id}")]
public Task DeleteEnterpriseRunner(string enterprise, long runnerId)
{
return DeleteEnterpriseRunner(enterprise, runnerId, ApiOptions.None);
}
/// <summary>
/// Delete a self-hosted runner from an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("DELETE", "/enterprises/{enterprise}/actions/runners/{runner_id}")]
public Task DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
return ApiConnection.Delete(ApiUrls.ActionsDeleteEnterpriseRunner(enterprise, runnerId), options);
}
/// <summary>
/// Delete a self-hosted runner from an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner id.</param>
[ManualRoute("DELETE", "/orgs/{org}/actions/runners/{runner_id}")]
public Task DeleteOrganizationRunner(string organization, long runnerId)
{
return DeleteOrganizationRunner(organization, runnerId, ApiOptions.None);
}
/// <summary>
/// Delete a self-hosted runner from an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("DELETE", "/orgs/{org}/actions/runners/{runner_id}")]
public Task DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
return ApiConnection.Delete(ApiUrls.ActionsDeleteOrganizationRunner(organization, runnerId), options);
}
/// <summary>
/// Delete a self-hosted runner from a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
/// <param name="runnerId">The runner id.</param>
[ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/runners/{runner_id}")]
public Task DeleteRepositoryRunner(string owner, string repo, long runnerId)
{
return DeleteRepositoryRunner(owner, repo, runnerId, ApiOptions.None);
}
/// <summary>
/// Delete a self-hosted runner from a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
/// <param name="runnerId">The runner id.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/runners/{runner_id}")]
public Task DeleteRepositoryRunner(string owner, string repo, long runnerId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return ApiConnection.Delete(ApiUrls.ActionsDeleteRepositoryRunner(owner, repo, runnerId), options);
}
/// <summary>
/// Create a self-hosted runner registration token for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
[ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")]
public Task<AccessToken> CreateEnterpriseRegistrationToken(string enterprise)
{
return CreateEnterpriseRegistrationToken(enterprise, ApiOptions.None);
}
/// <summary>
/// Create a self-hosted runner registration token for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")]
public Task<AccessToken> CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
return ApiConnection.Post<AccessToken>(ApiUrls.ActionsCreateEnterpriseRegistrationToken(enterprise), options);
}
/// <summary>
/// Create a self-hosted runner registration token for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
[ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")]
public Task<AccessToken> CreateOrganizationRegistrationToken(string organization)
{
return CreateOrganizationRegistrationToken(organization, ApiOptions.None);
}
/// <summary>
/// Create a self-hosted runner registration token for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")]
public Task<AccessToken> CreateOrganizationRegistrationToken(string organization, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
return ApiConnection.Post<AccessToken>(ApiUrls.ActionsCreateOrganizationRegistrationToken(organization), options);
}
/// <summary>
/// Create a self-hosted runner registration token for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")]
public Task<AccessToken> CreateRepositoryRegistrationToken(string owner, string repo)
{
return CreateRepositoryRegistrationToken(owner, repo, ApiOptions.None);
}
/// <summary>
/// Create a self-hosted runner registration token for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-self-hosted-runner-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner.</param>
/// <param name="repo">The repo.</param>
/// <param name="options">Options for changing the API response</param>
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")]
public Task<AccessToken> CreateRepositoryRegistrationToken(string owner, string repo, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo));
return ApiConnection.Post<AccessToken>(ApiUrls.ActionsCreateRepositoryRegistrationToken(owner, repo), options);
}
}
}

View File

@@ -11,5 +11,127 @@ namespace Octokit
/// </remarks>
public interface IActionsSelfHostedRunnerGroupsClient
{
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
Task<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise);
/// <summary>
/// List self-hosted runner groups for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="options">Options for changing the API response</param>
Task<RunnerGroupResponse> ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// List self-hosted runners groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
Task<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org);
/// <summary>
/// List self-hosted runners groups for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runner-groups-for-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="options">Options for changing the API response</param>
Task<RunnerGroupResponse> ListAllRunnerGroupsForOrganization(string org, ApiOptions options);
/// <summary>
/// List self-hosted runners in a group for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
Task<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId);
/// <summary>
/// List self-hosted runners in a group for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options to change the API response.</param>
Task<RunnerResponse> ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options);
/// <summary>
/// List self-hosted runners in a group for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
Task<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId);
/// <summary>
/// List self-hosted runners in a group for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-self-hosted-runners-in-a-group-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerGroupId">The runner group ID.</param>
/// <param name="options">Options to change the API response.</param>
Task<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options);
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);
/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-organization-access-to-a-self-hosted-runner-group-in-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
Task<IReadOnlyList<Organization>> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);
/// <summary>
/// List repository access to a self-hosted runner group in an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
Task<IReadOnlyList<Repository>> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
}
}

View File

@@ -11,5 +11,247 @@ namespace Octokit
/// </remarks>
public interface IActionsSelfHostedRunnersClient
{
/// <summary>
/// List self-hosted runners for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
Task<RunnerResponse> ListAllRunnersForEnterprise(string enterprise);
/// <summary>
/// List self-hosted runners for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
Task<RunnerResponse> ListAllRunnersForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// List self-hosted runners for an organization
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
Task<RunnerResponse> ListAllRunnersForOrganization(string organization);
/// <summary>
/// List self-hosted runners for an organization
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
Task<RunnerResponse> ListAllRunnersForOrganization(string organization, ApiOptions options);
/// <summary>
/// List self-hosted runners for a repository
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
Task<RunnerResponse> ListAllRunnersForRepository(string owner, string name);
/// <summary>
/// List self-hosted runners for a repository
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
Task<RunnerResponse> ListAllRunnersForRepository(string owner, string name, ApiOptions options);
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForEnterprise(string enterprise);
/// <summary>
/// List runner applications for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options);
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForOrganization(string organization);
/// <summary>
/// List runner applications for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options);
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForRepository(string owner, string name);
/// <summary>
/// List runner applications for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
Task<IReadOnlyList<RunnerApplication>> ListAllRunnerApplicationsForRepository(string owner, string name, ApiOptions options);
/// <summary>
/// Delete a self-hosted runner from an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner ID.</param>
Task DeleteEnterpriseRunner(string enterprise, long runnerId);
/// <summary>
/// Delete a self-hosted runner from an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
Task DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions options);
/// <summary>
/// Delete a self-hosted runner from an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner ID.</param>
Task DeleteOrganizationRunner(string organization, long runnerId);
/// <summary>
/// Delete a self-hosted runner from an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
Task DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options);
/// <summary>
/// Delete a self-hosted runner from a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner ID.</param>
Task DeleteRepositoryRunner(string owner, string name, long runnerId);
/// <summary>
/// Delete a self-hosted runner from a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="runnerId">The runner ID.</param>
/// <param name="options">Options to change the API response.</param>
Task DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options);
/// <summary>
/// Create a registration token for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
Task<AccessToken> CreateEnterpriseRegistrationToken(string enterprise);
/// <summary>
/// Create a registration token for an enterprise
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise
/// </remarks>
/// <param name="enterprise">The enterprise.</param>
/// <param name="options">Options to change the API response.</param>
Task<AccessToken> CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options);
/// <summary>
/// Create a registration token for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
Task<AccessToken> CreateOrganizationRegistrationToken(string organization);
/// <summary>
/// Create a registration token for an organization
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization
/// </remarks>
/// <param name="organization">The organization.</param>
/// <param name="options">Options to change the API response.</param>
Task<AccessToken> CreateOrganizationRegistrationToken(string organization, ApiOptions options);
/// <summary>
/// Create a registration token for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
Task<AccessToken> CreateRepositoryRegistrationToken(string owner, string name);
/// <summary>
/// Create a registration token for a repository
/// </summary>
/// <remarks>
/// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
Task<AccessToken> CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options);
}
}

View File

@@ -5216,5 +5216,209 @@ namespace Octokit
{
return "repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowFileName.UriEncode());
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runners for an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runners for an enterprise.</returns>
public static Uri ActionsListSelfHostedRunnersForEnterprise(string enterprise)
{
return "enterprises/{0}/actions/runners".FormatUri(enterprise);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runners for an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runners for an organization.</returns>
public static Uri ActionsListSelfHostedRunnersForOrganization(string org)
{
return "orgs/{0}/actions/runners".FormatUri(org);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runners for a repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runners for a repository.</returns>
public static Uri ActionsListSelfHostedRunnersForRepository(string owner, string repo)
{
return "repos/{0}/{1}/actions/runners".FormatUri(owner, repo);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <param name="runnerGroupId">The Id of the runner group.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in an enterprise.</returns>
public static Uri ActionsListSelfHostedRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId)
{
return "enterprises/{0}/actions/runner-groups/{1}/runners".FormatUri(enterprise, runnerGroupId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <param name="runnerGroupId">The Id of the runner group.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in an organization.</returns>
public static Uri ActionsListSelfHostedRunnersForOrganizationRunnerGroup(string org, long runnerGroupId)
{
return "orgs/{0}/actions/runner-groups/{1}/runners".FormatUri(org, runnerGroupId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in a repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <param name="runnerGroupId">The Id of the runner group.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner for a runner group in a repository.</returns>
public static Uri ActionsListSelfHostedRunnersForRepositoryRunnerGroup(string owner, string repo, long runnerGroupId)
{
return "repos/{0}/{1}/actions/runner-groups/{2}/runners".FormatUri(owner, repo, runnerGroupId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner applications for an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner applications for an enterprise.</returns>
public static Uri ActionsListRunnerApplicationsForEnterprise(string enterprise)
{
return "enterprises/{0}/actions/runners/downloads".FormatUri(enterprise);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner applications for an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner applications for an organization.</returns>
public static Uri ActionsListRunnerApplicationsForOrganization(string org)
{
return "orgs/{0}/actions/runners/downloads".FormatUri(org);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner applications for a repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner applications for a repository.</returns>
public static Uri ActionsListRunnerApplicationsForRepository(string owner, string repo)
{
return "repos/{0}/{1}/actions/runners/downloads".FormatUri(owner, repo);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner delete from an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <param name="runnerId">The Id of the runner.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner delete from an enterprise.</returns>
public static Uri ActionsDeleteEnterpriseRunner(string enterprise, long runnerId)
{
return "enterprises/{0}/actions/runners/{1}".FormatUri(enterprise, runnerId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner delete from an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <param name="runnerId">The Id of the runner.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner delete from an organization.</returns>
public static Uri ActionsDeleteOrganizationRunner(string org, long runnerId)
{
return "orgs/{0}/actions/runners/{1}".FormatUri(org, runnerId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner delete from a repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <param name="runnerId">The Id of the runner.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner delete from a repository.</returns>
public static Uri ActionsDeleteRepositoryRunner(string owner, string repo, long runnerId)
{
return "repos/{0}/{1}/actions/runners/{2}".FormatUri(owner, repo, runnerId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner registration token for an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner registration token for an enterprise.</returns>
public static Uri ActionsCreateEnterpriseRegistrationToken(string enterprise)
{
return "enterprises/{0}/actions/runners/registration-token".FormatUri(enterprise);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner registration token for an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner registration token for an organization.</returns>
public static Uri ActionsCreateOrganizationRegistrationToken(string org)
{
return "orgs/{0}/actions/runners/registration-token".FormatUri(org);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner registration token for a repository.
/// </summary>
/// <param name="owner">The owner of repo</param>
/// <param name="repo">The name of repo</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner registration token for a repository.</returns>
public static Uri ActionsCreateRepositoryRegistrationToken(string owner, string repo)
{
return "repos/{0}/{1}/actions/runners/registration-token".FormatUri(owner, repo);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner groups for an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner groups for an enterprise.</returns>
public static Uri ActionsListEnterpriseRunnerGroups(string enterprise)
{
return "enterprises/{0}/actions/runner-groups".FormatUri(enterprise);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner groups for an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner groups for an organization.</returns>
public static Uri ActionsListOrganizationRunnerGroups(string org)
{
return "orgs/{0}/actions/runner-groups".FormatUri(org);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner group organizations that belong to an enterprise.
/// </summary>
/// <param name="enterprise">The name of the enterprise.</param>
/// <param name="runnerGroupId">The Id of the runner group.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner group organizations that belong to an enterprise.</returns>
public static Uri ActionsListEnterpriseRunnerGroupOrganizations(string enterprise, long runnerGroupId)
{
return "enterprises/{0}/actions/runner-groups/{1}/organizations".FormatUri(enterprise, runnerGroupId);
}
/// <summary>
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner group repositories that belong to an organization.
/// </summary>
/// <param name="org">The name of the organization.</param>
/// <param name="runnerGroupId">The Id of the runner group.</param>
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner group repositories that belong to an organization.</returns>
public static Uri ActionsListOrganizationRunnerGroupRepositories(string org, long runnerGroupId)
{
return "orgs/{0}/actions/runner-groups/{1}/repositories".FormatUri(org, runnerGroupId);
}
}
}

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Runner
{
public Runner() { }
public Runner(long id)
{
Id = id;
}
public Runner(long id, string name, string os, string status, bool busy, List<Label> labels)
{
Id = id;
Name = name;
Os = os;
Status = status;
Busy = busy;
Labels = labels;
}
public long Id { get; private set; }
public string Name { get; private set; }
public string Os { get; private set; }
public string Status { get; private set; }
public bool Busy { get; private set; }
public IReadOnlyList<Label> Labels { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture,
"Runner Id: {0}; Name: {1}; OS: {2}; Status: {3}; Busy: {4}; Labels: {5};",
Id, Name, Os, Status, Busy, string.Join(", ", Labels.Select(l => l.Name)));
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Diagnostics;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RunnerApplication
{
public RunnerApplication() { }
public RunnerApplication(string os, string architecture, string downloadUrl, string fileName)
{
Os = os;
Architecture = architecture;
DownloadUrl = downloadUrl;
FileName = fileName;
}
public string Os { get; private set; }
public string Architecture { get; private set; }
public string DownloadUrl { get; private set; }
public string FileName { get; private set; }
internal string DebuggerDisplay
{
get
{
return string.Format("Os: {0}; Architecture: {1}; DownloadUrl: {2}; FileName: {3};",
Os, Architecture, DownloadUrl, FileName);
}
}
}
}

View File

@@ -0,0 +1,44 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RunnerGroup
{
public RunnerGroup() { }
public RunnerGroup(long id)
{
Id = id;
}
public RunnerGroup(long id, string name, string visibility, bool Default, string runnersUrl, bool allowsPublicRepositories, bool restrictedToWorkflows, List<string> selectedWorkflows, bool workflowRestrictionsReadOnly)
{
Id = id;
Name = name;
Visibility = visibility;
this.Default = Default; // default is a reserved keyword
RunnersUrl = runnersUrl;
AllowsPublicRepositories = allowsPublicRepositories;
RestrictedToWorkflows = restrictedToWorkflows;
SelectedWorkflows = selectedWorkflows;
WorkflowRestrictionsReadOnly = workflowRestrictionsReadOnly;
}
public long Id { get; private set; }
public string Name { get; private set; }
public string Visibility { get; private set; }
public bool Default { get; private set; }
public string RunnersUrl { get; private set; }
public bool AllowsPublicRepositories { get; private set; }
public bool RestrictedToWorkflows { get; private set; }
public IReadOnlyList<string> SelectedWorkflows { get; private set; }
public bool WorkflowRestrictionsReadOnly { get; private set; }
internal string DebuggerDisplay => string.Format("Id: {0}, Name: {1}, Visibility: {2}, Default: {3}, RunnersUrl: {4}, AllowsPublicRepositories: {5}, RestrictedToWorkflows: {6}, SelectedWorkflows: {7}, WorkflowRestrictionsReadOnly: {8}",
Id, Name, Visibility, Default, RunnersUrl, AllowsPublicRepositories, RestrictedToWorkflows, string.Join(", ", SelectedWorkflows.Select(x => x.ToString())), WorkflowRestrictionsReadOnly);
}
}

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RunnerGroupResponse
{
public RunnerGroupResponse()
{
}
public RunnerGroupResponse(int totalCount, IReadOnlyList<RunnerGroup> runnerGroups)
{
TotalCount = totalCount;
RunnerGroups = runnerGroups;
}
/// <summary>
/// The total number of runner groups.
/// </summary>
public int TotalCount { get; private set; }
/// <summary>
/// The retrieved runner groups.
/// </summary>
public IReadOnlyList<RunnerGroup> RunnerGroups { get; private set; }
internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Runner Groups: {1}", TotalCount, RunnerGroups.Count);
}
}

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RunnerResponse
{
public RunnerResponse()
{
}
public RunnerResponse(int totalCount, IReadOnlyList<Runner> runners)
{
TotalCount = totalCount;
Runners = runners;
}
/// <summary>
/// The total number of runners.
/// </summary>
public int TotalCount { get; private set; }
/// <summary>
/// The retrieved runners.
/// </summary>
public IReadOnlyList<Runner> Runners { get; private set; }
internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Runners: {1}", TotalCount, Runners.Count);
}
}

View File

@@ -0,0 +1,49 @@
# Working with Self-hosted runner groups
## Create a client
```csharp
var client = new GitHubClient(....); // More on GitHubClient can be found in "Getting Started"
```
## List Runner Groups
### List self-hosted runner groups for an enterprise
```csharp
var runnerGroups = await client.Actions.SelfHostedRunnerGroups.ListAllRunnerGroupsForEnterprise("enterprise");
```
### List self-hosted runner groups for an organization
```csharp
var runnerGroups = await client.Actions.SelfHostedRunnerGroups.ListAllRunnerGroupsForOrganization("octokit");
```
## List Runners in a Runner Group
### List self-hosted runners in a runner group for an enterprise
```csharp
var runners = await client.Actions.SelfHostedRunners.ListAllRunnersForEnterpriseRunnerGroup("enterprise", groupId);
```
### List self-hosted runners in a runner group for an organization
```csharp
var runners = await client.Actions.SelfHostedRunners.ListAllRunnersForOrganizationRunnerGroup("octokit", groupId);
```
## List Runner Group Access
### List organization access to a self-hosted runner group in an enterprise
```csharp
var orgs = await client.Actions.SelfHostedRunnerGroups.ListAllRunnerGroupOrganizationsForEnterprise("enterprise", groupId);
```
### List repository access to a self-hosted runner group in an organization
```csharp
var repos = await client.Actions.SelfHostedRunnerGroups.ListAllRunnerGroupRepositoriesForOrganization("octokit", groupId);
```

View File

@@ -0,0 +1,87 @@
# Working with Self-hosted runners
## Create a client
```csharp
var client = new GitHubClient(....); // More on GitHubClient can be found in "Getting Started"
```
## List Runners
### List self-hosted runners for an enterprise
```csharp
var runners = await client.Actions.SelfHostedRunners.ListAllRunnersForEnterprise("enterprise");
```
### List self-hosted runners for an organization
```csharp
var runners = await client.Actions.SelfHostedRunners.ListAllRunnersForOrganization("octokit");
```
### List self-hosted runners for a repository
```csharp
var runners = await client.Actions.SelfHostedRunners.ListAllRunnersForRepository("octokit", "octokit.net");
```
## List Runner Applications
### List runner applications for an enterprise
```csharp
var runnerApplications = await client.Actions.SelfHostedRunners.ListAllRunnerApplicationsForEnterprise("enterprise");
```
### List runner applications for an organization
```csharp
var runnerApplications = await client.Actions.SelfHostedRunners.ListAllRunnerApplicationsForOrganization("octokit");
```
### List runner applications for a repository
```csharp
var runnerApplications = await client.Actions.SelfHostedRunners.ListAllRunnerApplicationsForRepository("octokit", "octokit.net");
```
## Create Registration Tokens
### Create a registration token for an enterprise
```csharp
var token = await client.Actions.SelfHostedRunners.CreateEnterpriseRegistrationToken("enterprise");
```
### Create a registration token for an organization
```csharp
var token = await client.Actions.SelfHostedRunners.CreateOrganizationRegistrationToken("octokit");
```
### Create a registration token for a repository
```csharp
var token = await client.Actions.SelfHostedRunners.CreateRepositoryRegistrationToken("octokit", "octokit.net");
```
## Delete
### Delete a self-hosted runner from an enterprise
```csharp
await client.Actions.SelfHostedRunners.DeleteEnterpriseRunner("enterprise", runnerId);
```
### Delete a self-hosted runner from an organization
```csharp
await client.Actions.SelfHostedRunners.DeleteOrganizationRunner("octokit", runnerId);
```
### Delete a self-hosted runner from a repository
```csharp
await client.Actions.SelfHostedRunners.DeleteRepositoryRunner("octokit", "octokit.net", runnerId);
```

View File

@@ -23,6 +23,8 @@ nav:
- 'Milestones' : 'milestones.md'
- 'Releases' : 'releases.md'
- 'Search' : 'search.md'
- 'Self-hosted runners': 'self-hosted-runners.md'
- 'Self-hosted runner groups': 'self-hosted-runner-groups.md'
- 'Git Database' : 'git-database.md'
- 'GitHub Apps' : 'github-apps.md'