From 0c901dc6c59b95065af20ffd50b2e7cfad1d3c75 Mon Sep 17 00:00:00 2001 From: Liam Neville Date: Wed, 5 Jul 2023 13:06:32 -0700 Subject: [PATCH] [Bug] Fixes ActionsSelfHostedRunnersClient Delete Calls where no API options are passed would throw errors --- ...bservableActionsSelfHostedRunnersClient.cs | 397 +++++------- ...bservableActionsSelfHostedRunnersClient.cs | 579 ++++++++---------- .../ActionsSelfHostedRunnersClientTests.cs | 18 +- .../Clients/ActionsSelfHostedRunnersClient.cs | 78 +-- .../IActionsSelfHostedRunnersClient.cs | 397 +++++------- 5 files changed, 601 insertions(+), 868 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs index 29ad795b3a..57cee05569 100644 --- a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs @@ -1,258 +1,197 @@ using System; -using System.Collections.Generic; using System.Reactive; +using System.Threading; namespace Octokit.Reactive { + /// + /// A client for GitHub's Actions Self-hosted runners API. + /// + /// + /// See the Actions Self-hosted runners API documentation for more information. + /// + public interface IObservableActionsSelfHostedRunnersClient + { /// - /// A client for GitHub's Actions Self-hosted runners API. + /// Gets a list of all self-hosted runners for an enterprise. /// /// - /// See the Actions Self-hosted runners API documentation for more information. + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise /// - 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); + /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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 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. + /// A token used to cancel this potentially long running request + IObservable CreateEnterpriseRegistrationToken(string enterprise, CancellationToken cancellationToken = default); - /// - /// 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 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. + /// A token used to cancel this potentially long running request + IObservable CreateOrganizationRegistrationToken(string organization, CancellationToken cancellationToken = default); - /// - /// 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); + /// + /// 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. + /// A token used to cancel this potentially long running request + IObservable CreateRepositoryRegistrationToken(string owner, string name, CancellationToken cancellationToken = default); - } + } } diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs index e9028df642..a42741a4eb 100644 --- a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs @@ -1,371 +1,278 @@ using System; -using System.Collections.Generic; using System.Reactive; using System.Reactive.Threading.Tasks; +using System.Threading; using Octokit.Reactive.Internal; namespace Octokit.Reactive { - public class ObservableActionsSelfHostedRunnersClient : IObservableActionsSelfHostedRunnersClient + public class ObservableActionsSelfHostedRunnersClient : IObservableActionsSelfHostedRunnersClient + { + readonly IActionsSelfHostedRunnersClient _client; + readonly IConnection _connection; + + /// + /// Instantiate a new GitHub Actions Self-hosted runners API client. + /// + /// A GitHub client. + public ObservableActionsSelfHostedRunnersClient(IGitHubClient client) { - readonly IActionsSelfHostedRunnersClient _client; - readonly IConnection _connection; + Ensure.ArgumentNotNull(client, nameof(client)); - /// - /// Instantiate a new GitHub Actions Self-hosted runners API client. - /// - /// A GitHub client. - 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); - } + _client = client.Actions.SelfHostedRunners; + _connection = client.Connection; + } - /// - /// 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)); + /// + /// 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); + } - return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization)); - } + /// + /// 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)); - /// - /// 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); - } + return _client.ListAllRunnersForEnterprise(enterprise, options).ToObservable(); + } - /// - /// 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)); + /// + /// 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); + } - return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, name)); - } + /// + /// 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)); - /// - /// 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); - } + return _client.ListAllRunnersForOrganization(organization, options).ToObservable(); + } - /// - /// 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)); + /// + /// 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); + } - return _client.DeleteEnterpriseRunner(enterprise, groupId, 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. + /// 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)); - /// - /// 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); - } + return _client.ListAllRunnersForRepository(owner, name, 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. - /// Options for changing the API response - public IObservable DeleteOrganizationRunner(string organization, long runnerId, ApiOptions options) - { - Ensure.ArgumentNotNull(options, nameof(options)); + /// + /// 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); + } - return _client.DeleteOrganizationRunner(organization, runnerId, 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. + /// Options for changing the API response + public IObservable ListAllRunnerApplicationsForEnterprise(string enterprise, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(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. - public IObservable DeleteRepositoryRunner(string owner, string name, long runnerId) - { - return DeleteRepositoryRunner(owner, name, runnerId, ApiOptions.None); - } + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForEnterprise(enterprise)); + } - /// - /// 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)); + /// + /// 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); + } - return _client.DeleteRepositoryRunner(owner, name, runnerId, options).ToObservable(); - } + /// + /// 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)); - /// - /// 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. + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForOrganization(organization)); + } - public IObservable CreateEnterpriseRegistrationToken(string enterprise) - { - return CreateEnterpriseRegistrationToken(enterprise, 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. + public IObservable ListAllRunnerApplicationsForRepository(string owner, string name) + { + return ListAllRunnerApplicationsForRepository(owner, name, 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)); + /// + /// 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 _client.CreateEnterpriseRegistrationToken(enterprise, options).ToObservable(); - } + return _connection.GetAndFlattenAllPages(ApiUrls.ActionsListRunnerApplicationsForRepository(owner, name)); + } - /// - /// 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); - } + /// + /// 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 _client.DeleteEnterpriseRunner(enterprise, runnerId).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. - /// Options for changing the API response - public IObservable CreateOrganizationRegistrationToken(string organization, ApiOptions options) - { - Ensure.ArgumentNotNull(options, nameof(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. + public IObservable DeleteOrganizationRunner(string organization, long runnerId) + { + return _client.DeleteOrganizationRunner(organization, runnerId).ToObservable(); + } - return _client.CreateOrganizationRegistrationToken(organization, 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 _client.DeleteRepositoryRunner(owner, name, runnerId).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 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. + /// A token used to cancel this potentially long running request + public IObservable CreateEnterpriseRegistrationToken(string enterprise, CancellationToken cancellationToken = default) + { + return _client.CreateEnterpriseRegistrationToken(enterprise, cancellationToken).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. - /// Options for changing the API response - public IObservable CreateRepositoryRegistrationToken(string owner, string name, ApiOptions options) - { - Ensure.ArgumentNotNull(options, nameof(options)); + /// + /// 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. + /// A token used to cancel this potentially long running request + public IObservable CreateOrganizationRegistrationToken(string organization, CancellationToken cancellationToken = default) + { + return _client.CreateOrganizationRegistrationToken(organization, cancellationToken).ToObservable(); + } - return _client.CreateRepositoryRegistrationToken(owner, name, 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. + /// A token used to cancel this potentially long running request + public IObservable CreateRepositoryRegistrationToken(string owner, string name, CancellationToken cancellationToken = default) + { + return _client.CreateRepositoryRegistrationToken(owner, name, cancellationToken).ToObservable(); } + } } diff --git a/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs b/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs index e8c707c5f2..eba511ad9d 100644 --- a/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs +++ b/Octokit.Tests/Clients/ActionsSelfHostedRunnersClientTests.cs @@ -238,8 +238,7 @@ public async Task RequstsCorrectUrl() await client.DeleteEnterpriseRunner("fake", 1); connection.Received().Delete( - Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/1"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/1")); } [Fact] @@ -272,8 +271,7 @@ public async Task RequestsCorrectUrl() await client.DeleteOrganizationRunner("fake", 1); connection.Received().Delete( - Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/1"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/1")); } [Fact] @@ -306,8 +304,7 @@ public async Task RequestsCorrectUrl() await client.DeleteRepositoryRunner("fake", "repo", 1); connection.Received().Delete( - Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/1"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/1")); } [Fact] @@ -342,8 +339,7 @@ public async Task RequestsCorrectUrl() await client.CreateEnterpriseRegistrationToken("fake"); connection.Received().Post( - Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/registration-token"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runners/registration-token")); } [Fact] @@ -376,8 +372,7 @@ public async Task RequestsCorrectUrl() await client.CreateOrganizationRegistrationToken("fake"); connection.Received().Post( - Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/registration-token"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "orgs/fake/actions/runners/registration-token")); } [Fact] @@ -410,8 +405,7 @@ public async Task RequestsCorrectUrl() await client.CreateRepositoryRegistrationToken("fake", "repo"); connection.Received().Post( - Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/registration-token"), - ApiOptions.None); + Arg.Is(u => u.ToString() == "repos/fake/repo/actions/runners/registration-token")); } [Fact] diff --git a/Octokit/Clients/ActionsSelfHostedRunnersClient.cs b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs index 044a5834dc..cbed4bef29 100644 --- a/Octokit/Clients/ActionsSelfHostedRunnersClient.cs +++ b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using System.Linq; using System.Collections.Generic; +using System.Threading; namespace Octokit { @@ -228,25 +229,10 @@ public async Task> ListAllRunnerApplicationsFor /// 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); + return ApiConnection.Delete(ApiUrls.ActionsDeleteEnterpriseRunner(enterprise, runnerId)); } /// @@ -259,28 +245,12 @@ public Task DeleteEnterpriseRunner(string enterprise, long runnerId, ApiOptions /// 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); + return ApiConnection.Delete(ApiUrls.ActionsDeleteOrganizationRunner(organization, runnerId)); } - /// /// Delete a self-hosted runner from a repository /// @@ -292,27 +262,11 @@ public Task DeleteOrganizationRunner(string organization, long runnerId, ApiOpti /// 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); + return ApiConnection.Delete(ApiUrls.ActionsDeleteRepositoryRunner(owner, repo, runnerId)); } /// @@ -325,7 +279,7 @@ public Task DeleteRepositoryRunner(string owner, string repo, long runnerId, Api [ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")] public Task CreateEnterpriseRegistrationToken(string enterprise) { - return CreateEnterpriseRegistrationToken(enterprise, ApiOptions.None); + return CreateEnterpriseRegistrationToken(enterprise, CancellationToken.None); } /// @@ -335,13 +289,13 @@ public Task CreateEnterpriseRegistrationToken(string 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 + /// A token used to cancel this potentially long running request [ManualRoute("POST", "/enterprises/{enterprise}/actions/runners/registration-token")] - public Task CreateEnterpriseRegistrationToken(string enterprise, ApiOptions options) + public Task CreateEnterpriseRegistrationToken(string enterprise, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); - return ApiConnection.Post(ApiUrls.ActionsCreateEnterpriseRegistrationToken(enterprise), options); + return ApiConnection.Post(ApiUrls.ActionsCreateEnterpriseRegistrationToken(enterprise), cancellationToken); } /// @@ -354,7 +308,7 @@ public Task CreateEnterpriseRegistrationToken(string enterprise, Ap [ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")] public Task CreateOrganizationRegistrationToken(string organization) { - return CreateOrganizationRegistrationToken(organization, ApiOptions.None); + return CreateOrganizationRegistrationToken(organization, CancellationToken.None); } /// @@ -364,13 +318,13 @@ public Task CreateOrganizationRegistrationToken(string 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 + /// A token used to cancel this potentially long running request [ManualRoute("POST", "/orgs/{org}/actions/runners/registration-token")] - public Task CreateOrganizationRegistrationToken(string organization, ApiOptions options) + public Task CreateOrganizationRegistrationToken(string organization, CancellationToken cancellationToken) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); - return ApiConnection.Post(ApiUrls.ActionsCreateOrganizationRegistrationToken(organization), options); + return ApiConnection.Post(ApiUrls.ActionsCreateOrganizationRegistrationToken(organization), cancellationToken); } /// @@ -384,7 +338,7 @@ public Task CreateOrganizationRegistrationToken(string organization [ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")] public Task CreateRepositoryRegistrationToken(string owner, string repo) { - return CreateRepositoryRegistrationToken(owner, repo, ApiOptions.None); + return CreateRepositoryRegistrationToken(owner, repo, CancellationToken.None); } /// @@ -395,14 +349,14 @@ public Task CreateRepositoryRegistrationToken(string owner, string /// /// The owner. /// The repo. - /// Options for changing the API response + /// A token used to cancel this potentially long running request [ManualRoute("POST", "/repos/{owner}/{repo}/actions/runners/registration-token")] - public Task CreateRepositoryRegistrationToken(string owner, string repo, ApiOptions options) + public Task CreateRepositoryRegistrationToken(string owner, string repo, CancellationToken cancellationToken) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); - return ApiConnection.Post(ApiUrls.ActionsCreateRepositoryRegistrationToken(owner, repo), options); + return ApiConnection.Post(ApiUrls.ActionsCreateRepositoryRegistrationToken(owner, repo), cancellationToken); } } } diff --git a/Octokit/Clients/IActionsSelfHostedRunnersClient.cs b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs index efb409e5e7..d7074eb98f 100644 --- a/Octokit/Clients/IActionsSelfHostedRunnersClient.cs +++ b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs @@ -1,257 +1,196 @@ using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace Octokit { + /// + /// A client for GitHub's Actions Self-hosted runners API. + /// + /// + /// See the Actions Self-hosted runners API documentation for more information. + /// + public interface IActionsSelfHostedRunnersClient + { /// - /// A client for GitHub's Actions Self-hosted runners API. + /// List self-hosted runners for an enterprise /// /// - /// See the Actions Self-hosted runners API documentation for more information. + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-enterprise /// - 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); + /// 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 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 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 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 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 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 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 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 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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); + /// + /// 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); - /// - /// 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 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. + /// A token used to cancel this potentially long running request + Task CreateEnterpriseRegistrationToken(string enterprise, CancellationToken cancellationToken = default); - /// - /// 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 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. + /// A token used to cancel this potentially long running request + Task CreateOrganizationRegistrationToken(string organization, CancellationToken cancellationToken = default); - /// - /// 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); + /// + /// 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. + /// A token used to cancel this potentially long running request + Task CreateRepositoryRegistrationToken(string owner, string name, CancellationToken cancellationToken = default); - } + } }