diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs index 485507e8..4e6aaa29 100644 --- a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs @@ -10,6 +10,25 @@ namespace Octokit.Reactive /// public interface IObservableActionsSelfHostedRunnerGroupsClient { + /// + /// Get a self-hosted runner group for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-enterprise + /// + /// The enterprise name. + /// Unique identifier of the self-hosted runner group. + IObservable GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId); + + /// + /// Get a self-hosted runner group for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-organization + /// + /// The organization name. + /// Unique identifier of the self-hosted runner group. + IObservable GetRunnerGroupForOrganization(string org, long runnerGroupId); /// /// List self-hosted runner groups for an enterprise diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs index bf1a5026..7f7c0ec5 100644 --- a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs @@ -21,6 +21,36 @@ namespace Octokit.Reactive _connection = client.Connection; } + /// + /// Get a self-hosted runner group for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-enterprise + /// + /// The enterprise name. + /// Unique identifier of the self-hosted runner group. + public IObservable GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + return _client.GetRunnerGroupForEnterprise(enterprise, runnerGroupId).ToObservable(); + } + + /// + /// Get a self-hosted runner group for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-organization + /// + /// The organization name. + /// Unique identifier of the self-hosted runner group. + public IObservable GetRunnerGroupForOrganization(string org, long runnerGroupId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return _client.GetRunnerGroupForOrganization(org, runnerGroupId).ToObservable(); + } + /// /// List self-hosted runner groups for an enterprise /// diff --git a/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs b/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs index 7909e259..a1886ad8 100644 --- a/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs +++ b/Octokit.Tests/Clients/ActionsSelfHostedRunnerGroupsClientTests.cs @@ -16,6 +16,68 @@ namespace Octokit.Tests.Clients } } + public class TheGetRunnerGroupForEnterpriseMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.GetRunnerGroupForEnterprise("fake", 1); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "enterprises/fake/actions/runner-groups/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetRunnerGroupForEnterprise(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetRunnerGroupForEnterprise("", 1)); + } + } + + public class TheGetRunnerGroupForOrganizationMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ActionsSelfHostedRunnerGroupsClient(connection); + + await client.GetRunnerGroupForOrganization("fake", 1); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "orgs/fake/actions/runner-groups/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetRunnerGroupForOrganization(null, 1)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetRunnerGroupForOrganization("", 1)); + } + } + public class TheListAllRunnerGroupsForEnterpriseMethod { [Fact] diff --git a/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs index 1f61da09..5520af6e 100644 --- a/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs @@ -20,6 +20,38 @@ namespace Octokit { } + /// + /// Get a self-hosted runner group for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-enterprise + /// + /// The enterprise name. + /// Unique identifier of the self-hosted runner group. + [ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}")] + public async Task GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId) + { + Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise)); + + return await ApiConnection.Get(ApiUrls.ActionsGetEnterpriseRunnerGroup(enterprise, runnerGroupId)).ConfigureAwait(false); + } + + /// + /// Get a self-hosted runner group for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-organization + /// + /// The organization name. + /// Unique identifier of the self-hosted runner group. + [ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}")] + public async Task GetRunnerGroupForOrganization(string org, long runnerGroupId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return await ApiConnection.Get(ApiUrls.ActionsGetOrganizationRunnerGroup(org, runnerGroupId)).ConfigureAwait(false); + } + /// /// List self-hosted runner groups for an enterprise /// diff --git a/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs index 648aa1eb..6e419407 100644 --- a/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs +++ b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs @@ -11,6 +11,25 @@ namespace Octokit /// public interface IActionsSelfHostedRunnerGroupsClient { + /// + /// Get a self-hosted runner group for an enterprise + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-enterprise + /// + /// The enterprise name. + /// Unique identifier of the self-hosted runner group. + Task GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId); + + /// + /// Get a self-hosted runner group for an organization + /// + /// + /// https://docs.github.com/en/enterprise-cloud@latest/rest/actions/self-hosted-runner-groups?apiVersion=2022-11-28#get-a-self-hosted-runner-group-for-an-organization + /// + /// The organization name. + /// Unique identifier of the self-hosted runner group. + Task GetRunnerGroupForOrganization(string org, long runnerGroupId); /// /// List self-hosted runner groups for an enterprise diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 4f533390..eb699627 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -5378,6 +5378,28 @@ namespace Octokit 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. + /// Unique identifier of the self-hosted runner group. + /// The that handles the Actions self-hosted runner groups for an enterprise. + public static Uri ActionsGetEnterpriseRunnerGroup(string enterprise, long runnerGroupId) + { + return "enterprises/{0}/actions/runner-groups/{1}".FormatUri(enterprise, runnerGroupId); + } + + /// + /// Returns the that handles the Actions self-hosted runner groups for an organization. + /// + /// The name of the organization. + /// Unique identifier of the self-hosted runner group. + /// The that handles the Actions self-hosted runner groups for an organization. + public static Uri ActionsGetOrganizationRunnerGroup(string org, long runnerGroupId) + { + return "orgs/{0}/actions/runner-groups/{1}".FormatUri(org, runnerGroupId); + } + /// /// Returns the that handles the Actions self-hosted runner groups for an enterprise. /// diff --git a/Octokit/Models/Response/RunnerGroup.cs b/Octokit/Models/Response/RunnerGroup.cs index ba9c1968..71f19392 100644 --- a/Octokit/Models/Response/RunnerGroup.cs +++ b/Octokit/Models/Response/RunnerGroup.cs @@ -15,13 +15,14 @@ namespace Octokit Id = id; } - public RunnerGroup(long id, string name, string visibility, bool Default, string runnersUrl, bool allowsPublicRepositories, bool restrictedToWorkflows, List selectedWorkflows, bool workflowRestrictionsReadOnly) + public RunnerGroup(long id, string name, string visibility, bool @default, string runnersUrl, bool inherited, bool allowsPublicRepositories, bool restrictedToWorkflows, List selectedWorkflows, bool workflowRestrictionsReadOnly) { Id = id; Name = name; Visibility = visibility; - this.Default = Default; // default is a reserved keyword + Default = @default; RunnersUrl = runnersUrl; + Inherited = inherited; AllowsPublicRepositories = allowsPublicRepositories; RestrictedToWorkflows = restrictedToWorkflows; SelectedWorkflows = selectedWorkflows; @@ -33,12 +34,13 @@ namespace Octokit public string Visibility { get; private set; } public bool Default { get; private set; } public string RunnersUrl { get; private set; } + public bool Inherited { get; private set; } public bool AllowsPublicRepositories { get; private set; } public bool RestrictedToWorkflows { get; private set; } public IReadOnlyList SelectedWorkflows { get; private set; } public bool WorkflowRestrictionsReadOnly { get; private set; } - internal string DebuggerDisplay => string.Format("Id: {0}, Name: {1}, Visibility: {2}, Default: {3}, RunnersUrl: {4}, AllowsPublicRepositories: {5}, RestrictedToWorkflows: {6}, SelectedWorkflows: {7}, WorkflowRestrictionsReadOnly: {8}", - Id, Name, Visibility, Default, RunnersUrl, AllowsPublicRepositories, RestrictedToWorkflows, string.Join(", ", SelectedWorkflows.Select(x => x.ToString())), WorkflowRestrictionsReadOnly); + internal string DebuggerDisplay => string.Format("Id: {0}, Name: {1}, Visibility: {2}, Default: {3}, RunnersUrl: {4}, Inherited: {5}, AllowsPublicRepositories: {6}, RestrictedToWorkflows: {7}, SelectedWorkflows: {8}, WorkflowRestrictionsReadOnly: {9}", + Id, Name, Visibility, Default, RunnersUrl, Inherited, AllowsPublicRepositories, RestrictedToWorkflows, string.Join(", ", SelectedWorkflows.Select(x => x.ToString())), WorkflowRestrictionsReadOnly); } }