diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs index f8e82dc707..485507e8bc 100644 --- a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs @@ -1,4 +1,6 @@ -namespace Octokit.Reactive +using System; + +namespace Octokit.Reactive { /// /// A client for GitHub's Actions Self-hosted runner groups API. @@ -8,5 +10,127 @@ /// public interface IObservableActionsSelfHostedRunnerGroupsClient { + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + IObservable ListAllRunnerGroupsForEnterprise(string enterprise); + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// Options for changing the API response + IObservable ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options); + + /// + /// List self-hosted runner groups for an organization + /// + /// + /// 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 + /// + /// The organization name + IObservable ListAllRunnerGroupsForOrganization(string org); + + /// + /// List self-hosted runner groups for an organization + /// + /// + /// 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 + /// + /// The organization name + /// Options for changing the API response + IObservable ListAllRunnerGroupsForOrganization(string org, ApiOptions options); + /// + /// Gets a list of all self-hosted runners in a group for an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + IObservable ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId); + + /// + /// Gets a list of all self-hosted runners in a group for an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + /// Options to change the API response. + IObservable ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options); + + /// + /// Gets a list of all self-hosted runners in a group for an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + IObservable ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId); + + /// + /// Gets a list of all self-hosted runners in a group for an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + /// Options to change the API response. + IObservable ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options); + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + IObservable ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId); + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + /// Options for changing the API response + IObservable ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options); + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + IObservable ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId); + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + /// Options for changing the API response + IObservable ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options); + } } diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs index 52ef545712..29ad795b3a 100644 --- a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs @@ -1,4 +1,8 @@ -namespace Octokit.Reactive +using System; +using System.Collections.Generic; +using System.Reactive; + +namespace Octokit.Reactive { /// /// A client for GitHub's Actions Self-hosted runners API. @@ -8,5 +12,247 @@ /// public interface IObservableActionsSelfHostedRunnersClient { + /// + /// Gets a list of all self-hosted runners for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + IObservable ListAllRunnersForEnterprise(string enterprise); + + /// + /// Gets a list of all self-hosted runners for an enterprise. + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + IObservable ListAllRunnersForEnterprise(string enterprise, ApiOptions options); + + /// + /// Gets a list of all self-hosted runners for an organization. + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization + /// + /// The organization. + IObservable ListAllRunnersForOrganization(string organization); + + /// + /// Gets a list of all self-hosted runners for an organization. + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization + /// + /// The organization. + /// Options to change the API response. + IObservable ListAllRunnersForOrganization(string organization, ApiOptions options); + + /// + /// Gets a list of all self-hosted runners for a repository. + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + IObservable ListAllRunnersForRepository(string owner, string name); + + /// + /// Gets a list of all self-hosted runners for a repository. + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + IObservable ListAllRunnersForRepository(string owner, string name, ApiOptions options); + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + IObservable ListAllRunnerApplicationsForEnterprise(string enterprise); + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + IObservable ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options); + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + IObservable ListAllRunnerApplicationsForOrganization(string organization); + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + /// Options to change the API response. + IObservable ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options); + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + IObservable ListAllRunnerApplicationsForRepository(string owner, string name); + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + IObservable ListAllRunnerApplicationsForRepository(string owner, string name, ApiOptions options); + + /// + /// Deletes a self-hosted runner from an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner ID. + IObservable DeleteEnterpriseRunner(string enterprise, long runnerId); + + /// + /// Deletes a self-hosted runner from an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner ID. + /// Options to change the API response. + IObservable DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions options); + + /// + /// Deletes a self-hosted runner from an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner ID. + IObservable DeleteOrganizationRunner(string organization, long runnerId); + + /// + /// Deletes a self-hosted runner from an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner ID. + /// Options to change the API response. + IObservable DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options); + + /// + /// Deletes a self-hosted runner from a repository. + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner ID. + IObservable DeleteRepositoryRunner(string owner, string name, long runnerId); + + /// + /// Deletes a self-hosted runner from a repository. + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner ID. + /// Options to change the API response. + IObservable DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options); + + /// + /// Create a registration token for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + IObservable CreateEnterpriseRegistrationToken(string enterprise); + + /// + /// Create a registration token for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + IObservable CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options); + + /// + /// Create a registration token for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + IObservable CreateOrganizationRegistrationToken(string organization); + + /// + /// Create a registration token for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + /// Options to change the API response. + IObservable CreateOrganizationRegistrationToken(string organization, ApiOptions options); + + /// + /// Create a registration token for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + IObservable CreateRepositoryRegistrationToken(string owner, string name); + + /// + /// Create a registration token for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + IObservable CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options); + } } diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs index e94e6a38b7..bf1a502605 100644 --- a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs @@ -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; /// /// Instantiate a new GitHub Actions Self-hosted runner groups API client. @@ -13,6 +18,184 @@ public ObservableActionsSelfHostedRunnerGroupsClient(IGitHubClient client) Ensure.ArgumentNotNull(client, nameof(client)); _client = client.Actions.SelfHostedRunnerGroups; + _connection = client.Connection; + } + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + public IObservable ListAllRunnerGroupsForEnterprise(string enterprise) + { + return ListAllRunnerGroupsForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// Options for changing the API response + public IObservable ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnerGroupsForEnterprise(enterprise, options).ToObservable(); } + + /// + /// List self-hosted runner groups for an organization + /// + /// + /// 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 + /// + /// The organization name + public IObservable ListAllRunnerGroupsForOrganization(string org) + { + return ListAllRunnerGroupsForOrganization(org, ApiOptions.None); + } + + /// + /// List self-hosted runner groups for an organization + /// + /// + /// 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 + /// + /// The organization name + /// Options for changing the API response + public IObservable ListAllRunnerGroupsForOrganization(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnerGroupsForOrganization(org, options).ToObservable(); + } + + /// + /// Lists all self-hosted runners in a self-hosted runner group configured in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group ID + public IObservable ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long groupId) + { + return ListAllRunnersForEnterpriseRunnerGroup(enterprise, groupId, ApiOptions.None); + } + + /// + /// Lists all self-hosted runners in a self-hosted runner group configured in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group ID + /// Options for changing the API response + public IObservable ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long groupId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnersForEnterpriseRunnerGroup(enterprise, groupId, options).ToObservable(); + } + + /// + /// Lists all self-hosted runners in a self-hosted runner group configured in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group ID + public IObservable ListAllRunnersForOrganizationRunnerGroup(string organization, long groupId) + { + return ListAllRunnersForOrganizationRunnerGroup(organization, groupId, ApiOptions.None); + } + + /// + /// Lists all self-hosted runners in a self-hosted runner group configured in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group ID + /// Options for changing the API response + public IObservable ListAllRunnersForOrganizationRunnerGroup(string organization, long groupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnersForOrganizationRunnerGroup(organization, groupId, options).ToObservable(); + } + + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group ID + public IObservable ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId) + { + return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None); + } + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group ID + /// Options for changing the API response + public IObservable ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options); + } + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group ID + public IObservable ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId) + { + return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None); + } + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group ID + /// Options for changing the API response + public IObservable ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options); + } + } } diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs index 052b6f90cb..e9028df642 100644 --- a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs @@ -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; /// /// Instantiate a new GitHub Actions Self-hosted runners API client. @@ -13,6 +20,352 @@ public ObservableActionsSelfHostedRunnersClient(IGitHubClient client) Ensure.ArgumentNotNull(client, nameof(client)); _client = client.Actions.SelfHostedRunners; + _connection = client.Connection; + } + + /// + /// Lists self-hosted runners for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + public IObservable ListAllRunnersForEnterprise(string enterprise) + { + return ListAllRunnersForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// Lists self-hosted runners for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + /// Options for changing the API response + public IObservable ListAllRunnersForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnersForEnterprise(enterprise, options).ToObservable(); + } + + /// + /// Lists self-hosted runners for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization + /// + /// The organization. + public IObservable ListAllRunnersForOrganization(string organization) + { + return ListAllRunnersForOrganization(organization, ApiOptions.None); + } + + /// + /// Lists self-hosted runners for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization + /// + /// The organization. + /// Options for changing the API response + public IObservable ListAllRunnersForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.ListAllRunnersForOrganization(organization, options).ToObservable(); + } + + /// + /// Lists self-hosted runners for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + public IObservable ListAllRunnersForRepository(string owner, string name) + { + return ListAllRunnersForRepository(owner, name, ApiOptions.None); + } + + /// + /// Lists self-hosted runners for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options for changing the API response + public IObservable 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(); + } + + /// + /// Lists all runner applications for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + public IObservable ListAllRunnerApplicationsForEnterprise(string enterprise) + { + return ListAllRunnerApplicationsForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// Lists all runner applications for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + /// Options for changing the API response + public IObservable ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForEnterprise(enterprise)); + } + + /// + /// Lists all runner applications for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + public IObservable ListAllRunnerApplicationsForOrganization(string organization) + { + return ListAllRunnerApplicationsForOrganization(organization, ApiOptions.None); + } + + /// + /// Lists all runner applications for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + /// Options for changing the API response + public IObservable ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization)); + } + + /// + /// Lists all runner applications for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + public IObservable ListAllRunnerApplicationsForRepository(string owner, string name) + { + return ListAllRunnerApplicationsForRepository(owner, name, ApiOptions.None); + } + + /// + /// Lists all runner applications for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options for changing the API response + public IObservable 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(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, name)); + } + + /// + /// Deletes a self-hosted runner from an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner id. + public IObservable DeleteEnterpriseRunner(string enterprise, long runnerId) + { + return DeleteEnterpriseRunner(enterprise, runnerId, ApiOptions.None); + } + + /// + /// Deletes a self-hosted runner from an enterprise. + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner id. + /// Options for changing the API response + public IObservable DeleteEnterpriseRunner(string enterprise, long groupId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.DeleteEnterpriseRunner(enterprise, groupId, options).ToObservable(); + } + + /// + /// Deletes a self-hosted runner from an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner id. + public IObservable DeleteOrganizationRunner(string organization, long runnerId) + { + return DeleteOrganizationRunner(organization, runnerId, ApiOptions.None); + } + + /// + /// Deletes a self-hosted runner from an organization. + /// + /// + /// 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 + /// + /// The organization. + /// The runner id. + /// Options for changing the API response + public IObservable DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.DeleteOrganizationRunner(organization, runnerId, options).ToObservable(); + } + + /// + /// Deletes a self-hosted runner from a repository. + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner id. + public IObservable DeleteRepositoryRunner(string owner, string name, long runnerId) + { + return DeleteRepositoryRunner(owner, name, runnerId, ApiOptions.None); + } + + /// + /// Deletes a self-hosted runner from a repository. + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner id. + /// Options for changing the API response + public IObservable DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.DeleteRepositoryRunner(owner, name, runnerId, options).ToObservable(); + } + + /// + /// Creates a registration token for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + + public IObservable CreateEnterpriseRegistrationToken(string enterprise) + { + return CreateEnterpriseRegistrationToken(enterprise, ApiOptions.None); + } + + /// + /// Creates a registration token for an enterprise. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + /// Options for changing the API response + public IObservable CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.CreateEnterpriseRegistrationToken(enterprise, options).ToObservable(); + } + + /// + /// Creates a registration token for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + public IObservable CreateOrganizationRegistrationToken(string organization) + { + return CreateOrganizationRegistrationToken(organization, ApiOptions.None); + } + + /// + /// Creates a registration token for an organization. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + /// Options for changing the API response + public IObservable CreateOrganizationRegistrationToken(string organization, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.CreateOrganizationRegistrationToken(organization, options).ToObservable(); + } + + /// + /// Creates a registration token for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + public IObservable CreateRepositoryRegistrationToken(string owner, string name) + { + return CreateRepositoryRegistrationToken(owner, name, ApiOptions.None); + } + + /// + /// Creates a registration token for a repository. + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options for changing the API response + public IObservable CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _client.CreateRepositoryRegistrationToken(owner, name, options).ToObservable(); } } } diff --git a/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs b/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs new file mode 100644 index 0000000000..7909e25920 --- /dev/null +++ b/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs @@ -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(() => new ActionsSelfHostedRunnerGroupsClient(null)); + } + } + + public class TheListAllRunnerGroupsForEnterpriseMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnerGroupsForEnterprise("fake"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runner-groups"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupsForEnterprise(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupsForEnterprise("")); + } + } + + public class TheListAllRunnerGroupsForOrganizationMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnerGroupsForOrganization("fake"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runner-groups"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupsForOrganization(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupsForOrganization("")); + } + } + + public class TheListAllRunnersForEnterpriseRunnerGroupMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnersForEnterpriseRunnerGroup("fake", 1); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runner-groups/1/runners"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForEnterpriseRunnerGroup(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForEnterpriseRunnerGroup("", 1)); + } + } + + public class TheListAllRunnersForOrganizationRunnerGroupMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnersForOrganizationRunnerGroup("fake", 1); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runner-groups/1/runners"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForOrganizationRunnerGroup(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForOrganizationRunnerGroup("", 1)); + } + } + + public class TheListAllRunnerGroupOrganizationsForEnterpriseMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnerGroupOrganizationsForEnterprise("fake", 1); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runner-groups/1/organizations"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupOrganizationsForEnterprise(null, 1, ApiOptions.None)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupOrganizationsForEnterprise("", 1, ApiOptions.None)); + } + } + + public class TheListAllRunnerGroupRepositoriesForOrganizationMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.ListAllRunnerGroupRepositoriesForOrganization("fake", 1, ApiOptions.None); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runner-groups/1/repositories"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupRepositoriesForOrganization(null, 1, ApiOptions.None)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.ListAllRunnerGroupRepositoriesForOrganization("", 1, ApiOptions.None)); + } + } + } +} diff --git a/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs b/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs new file mode 100644 index 0000000000..50bbb0a9fe --- /dev/null +++ b/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs @@ -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(() => new ActionsSelfHostedRunnersClient(null)); + } + } + + public class TheListAllRunnersForEnterproseMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnersForEnterprise("fake"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForEnterprise(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForEnterprise("")); + } + } + + public class TheListAllRunnersForOrganizationMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnersForOrganization("fake"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForOrganization(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForOrganization("")); + } + } + + public class TheListAllRunnersForRepositoryMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnersForRepository("fake", "repo"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForRepository(null, "repo")); + await Assert.ThrowsAsync(() => client.ListAllRunnersForRepository("fake", null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnersForRepository("", "repo")); + await Assert.ThrowsAsync(() => client.ListAllRunnersForRepository("fake", "")); + } + } + + + public class TheListAllRunnerApplicationsForEnterpriseMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnerApplicationsForEnterprise("fake"); + + connection.Received().GetAll>( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/downloads"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForEnterprise(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForEnterprise("")); + } + } + + public class TheListAllRunnerApplicationsForOrganizationMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnerApplicationsForOrganization("fake"); + + connection.Received().GetAll>( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/downloads"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForOrganization(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForOrganization("")); + } + } + + public class TheListAllRunnerApplicationsForRepositoryMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.ListAllRunnerApplicationsForRepository("fake", "repo"); + + connection.Received().GetAll>( + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/downloads"), Args.ApiOptions); + + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForRepository(null, "repo")); + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForRepository("fake", null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForRepository("", "repo")); + await Assert.ThrowsAsync(() => client.ListAllRunnerApplicationsForRepository("fake", "")); + } + } + + public class TheDeleteEnterpriseRunnerMethod + { + [Fact] + public async Task RequstsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.DeleteEnterpriseRunner("fake", 1); + + connection.Received().Delete( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/1"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteEnterpriseRunner(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteEnterpriseRunner("", 1)); + } + } + + public class TheDeleteOrganizationRunnerMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.DeleteOrganizationRunner("fake", 1); + + connection.Received().Delete( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/1"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteOrganizationRunner(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteOrganizationRunner("", 1)); + } + } + + public class TheDeleteRepositoryRunnerMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.DeleteRepositoryRunner("fake", "repo", 1); + + connection.Received().Delete( + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/1"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteRepositoryRunner(null, "repo", 1)); + await Assert.ThrowsAsync(() => client.DeleteRepositoryRunner("fake", null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.DeleteRepositoryRunner("", "repo", 1)); + await Assert.ThrowsAsync(() => client.DeleteRepositoryRunner("fake", "", 1)); + } + } + + public class TheCreateEnterpriseRegistrationTokenMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.CreateEnterpriseRegistrationToken("fake"); + + connection.Received().Post( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/registration-token"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateEnterpriseRegistrationToken(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateEnterpriseRegistrationToken("")); + } + } + + public class TheCreateOrganizationRegistrationTokenMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.CreateOrganizationRegistrationToken("fake"); + + connection.Received().Post( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/registration-token"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateOrganizationRegistrationToken(null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateOrganizationRegistrationToken("")); + } + } + + public class TheCreateRepositoryRegistrationToken + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await client.CreateRepositoryRegistrationToken("fake", "repo"); + + connection.Received().Post( + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/registration-token"), + ApiOptions.None); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateRepositoryRegistrationToken(null, "repo")); + await Assert.ThrowsAsync(() => client.CreateRepositoryRegistrationToken("fake", null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnersClient(connection); + + await Assert.ThrowsAsync(() => client.CreateRepositoryRegistrationToken("", "repo")); + await Assert.ThrowsAsync(() => client.CreateRepositoryRegistrationToken("fake", "")); + } + } + } +} diff --git a/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs index d960541894..1f61da0938 100644 --- a/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs @@ -1,4 +1,8 @@ -namespace Octokit +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Octokit { /// /// A client for GitHub's Actions Self-hosted runner groups API. @@ -15,5 +19,209 @@ public class ActionsSelfHostedRunnerGroupsClient : ApiClient, IActionsSelfHosted public ActionsSelfHostedRunnerGroupsClient(IApiConnection apiConnection) : base(apiConnection) { } - } + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups")] + public Task ListAllRunnerGroupsForEnterprise(string enterprise) + { + return ListAllRunnerGroupsForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// Options for changing the API response + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups")] + public async Task ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + var results = await ApiConnection.GetAll(ApiUrls.ActionsListEnterpriseRunnerGroups(enterprise), options).ConfigureAwait(false); + + return new RunnerGroupResponse( + results.Count > 0 ? results[0].TotalCount : 0, + results.SelectMany(x => x.RunnerGroups).ToList() + ); + } + + /// + /// List self-hosted runners groups for an organization + /// + /// + /// 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 + /// + /// The organization name + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups")] + public Task ListAllRunnerGroupsForOrganization(string org) + { + return ListAllRunnerGroupsForOrganization(org, ApiOptions.None); + } + + /// + /// List self-hosted runners groups for an organization + /// + /// + /// 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 + /// + /// The organization name + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups")] + public async Task ListAllRunnerGroupsForOrganization(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + var results = await ApiConnection.GetAll(ApiUrls.ActionsListOrganizationRunnerGroups(org), options).ConfigureAwait(false); + + return new RunnerGroupResponse( + results.Count > 0 ? results[0].TotalCount : 0, + results.SelectMany(x => x.RunnerGroups).ToList() + ); + } + + + /// + /// List self-hosted runners in a group for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners")] + public Task ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId) + { + return ListAllRunnersForEnterpriseRunnerGroup(enterprise, runnerGroupId, ApiOptions.None); + } + + /// + /// List self-hosted runners in a group for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + /// Options for changing the API response + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners")] + public async Task ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + var results = await ApiConnection.GetAll(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() + ); + } + + /// + /// List self-hosted runners in a group for an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/runners")] + public Task ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId) + { + return ListAllRunnersForOrganizationRunnerGroup(organization, runnerGroupId, ApiOptions.None); + } + + /// + /// List self-hosted runners in a group for an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/runners")] + public async Task ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + + var results = await ApiConnection.GetAll(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() + ); + } + + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")] + public Task> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId) + { + return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None); + } + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + /// Options for changing the API response + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations")] + public Task> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + return ApiConnection.GetAll(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options); + } + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")] + public Task> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId) + { + return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None); + } + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}/repositories")] + public Task> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return ApiConnection.GetAll(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options); + } + } } diff --git a/Octokit/Clients/ActionsSelfHostedRunnersClient.cs b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs index 38c86149dd..53fb040bb9 100644 --- a/Octokit/Clients/ActionsSelfHostedRunnersClient.cs +++ b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs @@ -1,10 +1,14 @@ -namespace Octokit +using System.Threading.Tasks; +using System.Linq; +using System.Collections.Generic; + +namespace Octokit { /// /// A client for GitHub's Actions Self-hosted runners API. /// /// - /// See the Actions Self-hosted runners API documentation for more information. + /// See the Actions Self-hosted runners API documentation for more information. /// public class ActionsSelfHostedRunnersClient : ApiClient, IActionsSelfHostedRunnersClient { @@ -15,5 +19,396 @@ public class ActionsSelfHostedRunnersClient : ApiClient, IActionsSelfHostedRunne public ActionsSelfHostedRunnersClient(IApiConnection apiConnection) : base(apiConnection) { } + + /// + /// Lists all self-hosted runners for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runners")] + public Task ListAllRunnersForEnterprise(string enterprise) + { + return ListAllRunnersForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// Lists all self-hosted runners for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + /// Options for changing the API response + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runners")] + public async Task ListAllRunnersForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var results = await ApiConnection.GetAll(ApiUrls.ActionsListSelfHostedRunnersForEnterprise(enterprise), options).ConfigureAwait(false); + + return new RunnerResponse( + results.Count > 0 ? results[0].TotalCount : 0, + results.SelectMany(x => x.Runners).ToList() + ); + } + + /// + /// Lists all self-hosted runners for an organization + /// + /// + /// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization + /// + /// The organization. + [ManualRoute("GET", "/orgs/{org}/actions/runners")] + public Task ListAllRunnersForOrganization(string organization) + { + return ListAllRunnersForOrganization(organization, ApiOptions.None); + } + + /// + /// Lists all self-hosted runners for an organization + /// + /// + /// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization + /// + /// The organization. + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/actions/runners")] + public async Task ListAllRunnersForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + + var results = await ApiConnection.GetAll(ApiUrls.ActionsListSelfHostedRunnersForOrganization(organization), options).ConfigureAwait(false); + + return new RunnerResponse( + results.Count > 0 ? results.Max(x => x.TotalCount) : 0, + results.SelectMany(x => x.Runners).ToList() + ); + } + + + /// + /// Lists all self-hosted runners for a repository + /// + /// + /// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners")] + public Task ListAllRunnersForRepository(string owner, string name) + { + return ListAllRunnersForRepository(owner, name, ApiOptions.None); + } + + /// + /// Lists all self-hosted runners for a repository + /// + /// + /// https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options for changing the API response + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners")] + public async Task ListAllRunnersForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + var results = await ApiConnection.GetAll(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() + ); + } + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runners/downloads")] + public Task> ListAllRunnerApplicationsForEnterprise(string enterprise) + { + return ListAllRunnerApplicationsForEnterprise(enterprise, ApiOptions.None); + } + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + /// Options for changing the API response + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runners/downloads")] + public async Task> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + var results = await ApiConnection.GetAll>(ApiUrls.ActionsListRunnerApplicationsForEnterprise(enterprise), options).ConfigureAwait(false); + + return results.SelectMany(x => x).ToList(); + } + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + [ManualRoute("GET", "/orgs/{org}/actions/runners/downloads")] + public Task> ListAllRunnerApplicationsForOrganization(string organization) + { + return ListAllRunnerApplicationsForOrganization(organization, ApiOptions.None); + } + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + /// Options for changing the API response + [ManualRoute("GET", "/orgs/{org}/actions/runners/downloads")] + public async Task> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + + var results = await ApiConnection.GetAll>(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization), options).ConfigureAwait(false); + + return results.SelectMany(x => x).ToList(); + } + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner. + /// The repo. + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners/downloads")] + public Task> ListAllRunnerApplicationsForRepository(string owner, string repo) + { + return ListAllRunnerApplicationsForRepository(owner, repo, ApiOptions.None); + } + + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner. + /// The repo. + /// Options for changing the API response + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/runners/downloads")] + public async Task> ListAllRunnerApplicationsForRepository(string owner, string repo, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + var results = await ApiConnection.GetAll>(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, repo), options).ConfigureAwait(false); + + return results.SelectMany(x => x).ToList(); + } + + /// + /// Delete a self-hosted runner from an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner id. + [ManualRoute("DELETE", "/enterprises/{enterprise}/actions/runners/{runner_id}")] + public Task DeleteEnterpriseRunner(string enterprise, long runnerId) + { + return DeleteEnterpriseRunner(enterprise, runnerId, ApiOptions.None); + } + + /// + /// Delete a self-hosted runner from an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner id. + /// Options for changing the API response + [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); + } + + /// + /// Delete a self-hosted runner from an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner id. + [ManualRoute("DELETE", "/orgs/{org}/actions/runners/{runner_id}")] + public Task DeleteOrganizationRunner(string organization, long runnerId) + { + return DeleteOrganizationRunner(organization, runnerId, ApiOptions.None); + } + + /// + /// Delete a self-hosted runner from an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner id. + /// Options for changing the API response + [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); + } + + + /// + /// Delete a self-hosted runner from a repository + /// + /// + /// 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 + /// + /// The owner. + /// The repo. + /// The runner id. + [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); + } + + /// + /// Delete a self-hosted runner from a repository + /// + /// + /// 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 + /// + /// The owner. + /// The repo. + /// The runner id. + /// Options for changing the API response + [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); + } + + /// + /// Create a self-hosted runner registration token for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + [ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")] + public Task CreateEnterpriseRegistrationToken(string enterprise) + { + return CreateEnterpriseRegistrationToken(enterprise, ApiOptions.None); + } + + /// + /// Create a self-hosted runner registration token for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// Options for changing the API response + [ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")] + public Task CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + return ApiConnection.Post(ApiUrls.ActionsCreateEnterpriseRegistrationToken(enterprise), options); + } + + /// + /// Create a self-hosted runner registration token for an organization + /// + /// + /// 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 + /// + /// The organization. + [ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")] + public Task CreateOrganizationRegistrationToken(string organization) + { + return CreateOrganizationRegistrationToken(organization, ApiOptions.None); + } + + /// + /// Create a self-hosted runner registration token for an organization + /// + /// + /// 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 + /// + /// The organization. + /// Options for changing the API response + [ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")] + public Task CreateOrganizationRegistrationToken(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + + return ApiConnection.Post(ApiUrls.ActionsCreateOrganizationRegistrationToken(organization), options); + } + + /// + /// Create a self-hosted runner registration token for a repository + /// + /// + /// 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 + /// + /// The owner. + /// The repo. + [ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")] + public Task CreateRepositoryRegistrationToken(string owner, string repo) + { + return CreateRepositoryRegistrationToken(owner, repo, ApiOptions.None); + } + + /// + /// Create a self-hosted runner registration token for a repository + /// + /// + /// 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 + /// + /// The owner. + /// The repo. + /// Options for changing the API response + [ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")] + public Task CreateRepositoryRegistrationToken(string owner, string repo, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + return ApiConnection.Post(ApiUrls.ActionsCreateRepositoryRegistrationToken(owner, repo), options); + } } } diff --git a/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs index f76ffc4a4e..648aa1eb19 100644 --- a/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs @@ -11,5 +11,127 @@ namespace Octokit /// public interface IActionsSelfHostedRunnerGroupsClient { + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + Task ListAllRunnerGroupsForEnterprise(string enterprise); + + /// + /// List self-hosted runner groups for an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// Options for changing the API response + Task ListAllRunnerGroupsForEnterprise(string enterprise, ApiOptions options); + + /// + /// List self-hosted runners groups for an organization + /// + /// + /// 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 + /// + /// The organization name + Task ListAllRunnerGroupsForOrganization(string org); + + /// + /// List self-hosted runners groups for an organization + /// + /// + /// 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 + /// + /// The organization name + /// Options for changing the API response + Task ListAllRunnerGroupsForOrganization(string org, ApiOptions options); + + /// + /// List self-hosted runners in a group for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + Task ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId); + + /// + /// List self-hosted runners in a group for an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner group ID. + /// Options to change the API response. + Task ListAllRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId, ApiOptions options); + + /// + /// List self-hosted runners in a group for an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + Task ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId); + + /// + /// List self-hosted runners in a group for an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner group ID. + /// Options to change the API response. + Task ListAllRunnersForOrganizationRunnerGroup(string organization, long runnerGroupId, ApiOptions options); + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + Task> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId); + + /// + /// List organization access to a self-hosted runner group in an enterprise + /// + /// + /// 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 + /// + /// The enterprise name + /// The runner group id + /// Options for changing the API response + Task> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options); + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + Task> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId); + + /// + /// List repository access to a self-hosted runner group in an organization + /// + /// + /// 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 + /// + /// The organization name + /// The runner group id + /// Options for changing the API response + Task> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options); } } diff --git a/Octokit/Clients/IActionsSelfHostedRunnersClient.cs b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs index 3c429615a0..efb409e5e7 100644 --- a/Octokit/Clients/IActionsSelfHostedRunnersClient.cs +++ b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs @@ -11,5 +11,247 @@ namespace Octokit /// public interface IActionsSelfHostedRunnersClient { + /// + /// List self-hosted runners for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + Task ListAllRunnersForEnterprise(string enterprise); + + /// + /// List self-hosted runners for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + Task ListAllRunnersForEnterprise(string enterprise, ApiOptions options); + + /// + /// List self-hosted runners for an organization + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization + /// + /// The organization. + Task ListAllRunnersForOrganization(string organization); + + /// + /// List self-hosted runners for an organization + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-an-organization + /// + /// The organization. + /// Options to change the API response. + Task ListAllRunnersForOrganization(string organization, ApiOptions options); + + /// + /// List self-hosted runners for a repository + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + Task ListAllRunnersForRepository(string owner, string name); + + /// + /// List self-hosted runners for a repository + /// + /// + /// https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + Task ListAllRunnersForRepository(string owner, string name, ApiOptions options); + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + Task> ListAllRunnerApplicationsForEnterprise(string enterprise); + + /// + /// List runner applications for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + Task> ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options); + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + Task> ListAllRunnerApplicationsForOrganization(string organization); + + /// + /// List runner applications for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization + /// + /// The organization. + /// Options to change the API response. + Task> ListAllRunnerApplicationsForOrganization(string organization, ApiOptions options); + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + Task> ListAllRunnerApplicationsForRepository(string owner, string name); + + /// + /// List runner applications for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + Task> ListAllRunnerApplicationsForRepository(string owner, string name, ApiOptions options); + + /// + /// Delete a self-hosted runner from an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner ID. + Task DeleteEnterpriseRunner(string enterprise, long runnerId); + + /// + /// Delete a self-hosted runner from an enterprise + /// + /// + /// 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 + /// + /// The enterprise. + /// The runner ID. + /// Options to change the API response. + Task DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions options); + + /// + /// Delete a self-hosted runner from an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner ID. + Task DeleteOrganizationRunner(string organization, long runnerId); + + /// + /// Delete a self-hosted runner from an organization + /// + /// + /// 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 + /// + /// The organization. + /// The runner ID. + /// Options to change the API response. + Task DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options); + + /// + /// Delete a self-hosted runner from a repository + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner ID. + Task DeleteRepositoryRunner(string owner, string name, long runnerId); + + /// + /// Delete a self-hosted runner from a repository + /// + /// + /// 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 + /// + /// The owner of the repository. + /// The name of the repository. + /// The runner ID. + /// Options to change the API response. + Task DeleteRepositoryRunner(string owner, string name, long runnerId, ApiOptions options); + + /// + /// Create a registration token for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + Task CreateEnterpriseRegistrationToken(string enterprise); + + /// + /// Create a registration token for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-enterprise + /// + /// The enterprise. + /// Options to change the API response. + Task CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options); + + /// + /// Create a registration token for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + Task CreateOrganizationRegistrationToken(string organization); + + /// + /// Create a registration token for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-an-organization + /// + /// The organization. + /// Options to change the API response. + Task CreateOrganizationRegistrationToken(string organization, ApiOptions options); + + /// + /// Create a registration token for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + Task CreateRepositoryRegistrationToken(string owner, string name); + + /// + /// Create a registration token for a repository + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#create-a-registration-token-for-a-repository + /// + /// The owner of the repository. + /// The name of the repository. + /// Options to change the API response. + Task CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options); + } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 9b1a072791..4f533390c2 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -97,7 +97,7 @@ public static Uri OrganizationRepositorySecrets(string organization) /// public static Uri OrganizationRepositorySecret(string organization, string secret) { - return "orgs/{0}/actions/secrets/{1}".FormatUri(organization,secret); + return "orgs/{0}/actions/secrets/{1}".FormatUri(organization, secret); } /// @@ -143,7 +143,7 @@ public static Uri UserOrganizations() { return "user/orgs".FormatUri(); } - + /// /// Returns the that returns all of the organization memberships for the currently logged in user. /// @@ -1940,7 +1940,7 @@ public static Uri Teams(int id) /// public static Uri TeamsByOrganizationAndSlug(string org, string teamSlug) { - return "orgs/{0}/teams/{1}".FormatUri(org,teamSlug); + return "orgs/{0}/teams/{1}".FormatUri(org, teamSlug); } /// @@ -4693,7 +4693,7 @@ public static Uri AllOrganizationCredentials(string org, string login) { return "orgs/{0}/credential-authorizations?login={1}".FormatUri(org, login); } - + /// /// Returns the for the Packages request /// @@ -5216,5 +5216,209 @@ public static Uri ActionsListWorkflowRuns(string owner, string repo, string work { return "repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowFileName.UriEncode()); } + + /// + /// Returns the that handles the Actions self-hosted runners for an enterprise. + /// + /// The name of the enterprise. + /// The that handles the Actions self-hosted runners for an enterprise. + public static Uri ActionsListSelfHostedRunnersForEnterprise(string enterprise) + { + return "enterprises/{0}/actions/runners".FormatUri(enterprise); + } + + /// + /// Returns the that handles the Actions self-hosted runners for an organization. + /// + /// The name of the organization. + /// The that handles the Actions self-hosted runners for an organization. + public static Uri ActionsListSelfHostedRunnersForOrganization(string org) + { + return "orgs/{0}/actions/runners".FormatUri(org); + } + + /// + /// Returns the that handles the Actions self-hosted runners for a repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the Actions self-hosted runners for a repository. + public static Uri ActionsListSelfHostedRunnersForRepository(string owner, string repo) + { + return "repos/{0}/{1}/actions/runners".FormatUri(owner, repo); + } + + /// + /// Returns the that handles the Actions self-hosted runner for a runner group in an enterprise. + /// + /// The name of the enterprise. + /// The Id of the runner group. + /// The that handles the Actions self-hosted runner for a runner group in an enterprise. + public static Uri ActionsListSelfHostedRunnersForEnterpriseRunnerGroup(string enterprise, long runnerGroupId) + { + return "enterprises/{0}/actions/runner-groups/{1}/runners".FormatUri(enterprise, runnerGroupId); + } + + /// + /// Returns the that handles the Actions self-hosted runner for a runner group in an organization. + /// + /// The name of the organization. + /// The Id of the runner group. + /// The that handles the Actions self-hosted runner for a runner group in an organization. + public static Uri ActionsListSelfHostedRunnersForOrganizationRunnerGroup(string org, long runnerGroupId) + { + return "orgs/{0}/actions/runner-groups/{1}/runners".FormatUri(org, runnerGroupId); + } + + /// + /// Returns the that handles the Actions self-hosted runner for a runner group in a repository. + /// + /// The owner of repo + /// The name of repo + /// The Id of the runner group. + /// The that handles the Actions self-hosted runner for a runner group in a repository. + public static Uri ActionsListSelfHostedRunnersForRepositoryRunnerGroup(string owner, string repo, long runnerGroupId) + { + return "repos/{0}/{1}/actions/runner-groups/{2}/runners".FormatUri(owner, repo, runnerGroupId); + } + + /// + /// Returns the that handles the Actions self-hosted runner applications for an enterprise. + /// + /// The name of the enterprise. + /// The that handles the Actions self-hosted runner applications for an enterprise. + public static Uri ActionsListRunnerApplicationsForEnterprise(string enterprise) + { + return "enterprises/{0}/actions/runners/downloads".FormatUri(enterprise); + } + + /// + /// Returns the that handles the Actions self-hosted runner applications for an organization. + /// + /// The name of the organization. + /// The that handles the Actions self-hosted runner applications for an organization. + public static Uri ActionsListRunnerApplicationsForOrganization(string org) + { + return "orgs/{0}/actions/runners/downloads".FormatUri(org); + } + + /// + /// Returns the that handles the Actions self-hosted runner applications for a repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the Actions self-hosted runner applications for a repository. + public static Uri ActionsListRunnerApplicationsForRepository(string owner, string repo) + { + return "repos/{0}/{1}/actions/runners/downloads".FormatUri(owner, repo); + } + + /// + /// Returns the that handles the Actions self-hosted runner delete from an enterprise. + /// + /// The name of the enterprise. + /// The Id of the runner. + /// The that handles the Actions self-hosted runner delete from an enterprise. + public static Uri ActionsDeleteEnterpriseRunner(string enterprise, long runnerId) + { + return "enterprises/{0}/actions/runners/{1}".FormatUri(enterprise, runnerId); + } + + /// + /// Returns the that handles the Actions self-hosted runner delete from an organization. + /// + /// The name of the organization. + /// The Id of the runner. + /// The that handles the Actions self-hosted runner delete from an organization. + public static Uri ActionsDeleteOrganizationRunner(string org, long runnerId) + { + return "orgs/{0}/actions/runners/{1}".FormatUri(org, runnerId); + } + + /// + /// Returns the that handles the Actions self-hosted runner delete from a repository. + /// + /// The owner of repo + /// The name of repo + /// The Id of the runner. + /// The that handles the Actions self-hosted runner delete from a repository. + public static Uri ActionsDeleteRepositoryRunner(string owner, string repo, long runnerId) + { + return "repos/{0}/{1}/actions/runners/{2}".FormatUri(owner, repo, runnerId); + } + + /// + /// Returns the that handles the Actions self-hosted runner registration token for an enterprise. + /// + /// The name of the enterprise. + /// The that handles the Actions self-hosted runner registration token for an enterprise. + public static Uri ActionsCreateEnterpriseRegistrationToken(string enterprise) + { + return "enterprises/{0}/actions/runners/registration-token".FormatUri(enterprise); + } + + /// + /// Returns the that handles the Actions self-hosted runner registration token for an organization. + /// + /// The name of the organization. + /// The that handles the Actions self-hosted runner registration token for an organization. + public static Uri ActionsCreateOrganizationRegistrationToken(string org) + { + return "orgs/{0}/actions/runners/registration-token".FormatUri(org); + } + + /// + /// Returns the that handles the Actions self-hosted runner registration token for a repository. + /// + /// The owner of repo + /// The name of repo + /// The that handles the Actions self-hosted runner registration token for a repository. + public static Uri ActionsCreateRepositoryRegistrationToken(string owner, string repo) + { + return "repos/{0}/{1}/actions/runners/registration-token".FormatUri(owner, repo); + } + + /// + /// Returns the that handles the Actions self-hosted runner groups for an enterprise. + /// + /// The name of the enterprise. + /// The that handles the Actions self-hosted runner groups for an enterprise. + public static Uri ActionsListEnterpriseRunnerGroups(string enterprise) + { + return "enterprises/{0}/actions/runner-groups".FormatUri(enterprise); + } + + /// + /// Returns the that handles the Actions self-hosted runner groups for an organization. + /// + /// The name of the organization. + /// The that handles the Actions self-hosted runner groups for an organization. + public static Uri ActionsListOrganizationRunnerGroups(string org) + { + return "orgs/{0}/actions/runner-groups".FormatUri(org); + } + + /// + /// Returns the that handles the Actions self-hosted runner group organizations that belong to an enterprise. + /// + /// The name of the enterprise. + /// The Id of the runner group. + /// The that handles the Actions self-hosted runner group organizations that belong to an enterprise. + public static Uri ActionsListEnterpriseRunnerGroupOrganizations(string enterprise, long runnerGroupId) + { + return "enterprises/{0}/actions/runner-groups/{1}/organizations".FormatUri(enterprise, runnerGroupId); + } + + /// + /// Returns the that handles the Actions self-hosted runner group repositories that belong to an organization. + /// + /// The name of the organization. + /// The Id of the runner group. + /// The that handles the Actions self-hosted runner group repositories that belong to an organization. + public static Uri ActionsListOrganizationRunnerGroupRepositories(string org, long runnerGroupId) + { + return "orgs/{0}/actions/runner-groups/{1}/repositories".FormatUri(org, runnerGroupId); + } + } } diff --git a/Octokit/Models/Response/Runner.cs b/Octokit/Models/Response/Runner.cs new file mode 100644 index 0000000000..2911c76aec --- /dev/null +++ b/Octokit/Models/Response/Runner.cs @@ -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