mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +00:00
Add method to get a single runner group (#2706)
* Add method to get a single runner group * Fix tests * Fix typo * Add observable methods
This commit is contained in:
@@ -10,6 +10,25 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
public interface IObservableActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an enterprise
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="enterprise">The enterprise name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
IObservable<RunnerGroup> GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an organization
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="org">The organization name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
IObservable<RunnerGroup> GetRunnerGroupForOrganization(string org, long runnerGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// List self-hosted runner groups for an enterprise
|
||||
|
||||
@@ -21,6 +21,36 @@ namespace Octokit.Reactive
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an enterprise
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="enterprise">The enterprise name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
public IObservable<RunnerGroup> GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
|
||||
|
||||
return _client.GetRunnerGroupForEnterprise(enterprise, runnerGroupId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an organization
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="org">The organization name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
public IObservable<RunnerGroup> GetRunnerGroupForOrganization(string org, long runnerGroupId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return _client.GetRunnerGroupForOrganization(org, runnerGroupId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List self-hosted runner groups for an enterprise
|
||||
/// </summary>
|
||||
|
||||
@@ -16,6 +16,68 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetRunnerGroupForEnterpriseMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
|
||||
|
||||
await client.GetRunnerGroupForEnterprise("fake", 1);
|
||||
|
||||
connection.Received().Get<RunnerGroup>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "enterprises/fake/actions/runner-groups/1"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRunnerGroupForEnterprise(null, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetRunnerGroupForEnterprise("", 1));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetRunnerGroupForOrganizationMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(connection);
|
||||
|
||||
await client.GetRunnerGroupForOrganization("fake", 1);
|
||||
|
||||
connection.Received().Get<RunnerGroup>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "orgs/fake/actions/runner-groups/1"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetRunnerGroupForOrganization(null, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var client = new ActionsSelfHostedRunnerGroupsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetRunnerGroupForOrganization("", 1));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListAllRunnerGroupsForEnterpriseMethod
|
||||
{
|
||||
[Fact]
|
||||
|
||||
@@ -20,6 +20,38 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an enterprise
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="enterprise">The enterprise name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
[ManualRoute("GET", "/enterprises/{enterprise}/actions/runner-groups/{runner_group_id}")]
|
||||
public async Task<RunnerGroup> GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
|
||||
|
||||
return await ApiConnection.Get<RunnerGroup>(ApiUrls.ActionsGetEnterpriseRunnerGroup(enterprise, runnerGroupId)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an organization
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="org">The organization name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
[ManualRoute("GET", "/orgs/{org}/actions/runner-groups/{runner_group_id}")]
|
||||
public async Task<RunnerGroup> GetRunnerGroupForOrganization(string org, long runnerGroupId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return await ApiConnection.Get<RunnerGroup>(ApiUrls.ActionsGetOrganizationRunnerGroup(org, runnerGroupId)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List self-hosted runner groups for an enterprise
|
||||
/// </summary>
|
||||
|
||||
@@ -11,6 +11,25 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
public interface IActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an enterprise
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="enterprise">The enterprise name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
Task<RunnerGroup> GetRunnerGroupForEnterprise(string enterprise, long runnerGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// Get a self-hosted runner group for an organization
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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
|
||||
/// </remarks>
|
||||
/// <param name="org">The organization name.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
Task<RunnerGroup> GetRunnerGroupForOrganization(string org, long runnerGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// List self-hosted runner groups for an enterprise
|
||||
|
||||
@@ -5378,6 +5378,28 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/actions/runners/registration-token".FormatUri(owner, repo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner groups for an enterprise.
|
||||
/// </summary>
|
||||
/// <param name="enterprise">The name of the enterprise.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner groups for an enterprise.</returns>
|
||||
public static Uri ActionsGetEnterpriseRunnerGroup(string enterprise, long runnerGroupId)
|
||||
{
|
||||
return "enterprises/{0}/actions/runner-groups/{1}".FormatUri(enterprise, runnerGroupId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner groups for an organization.
|
||||
/// </summary>
|
||||
/// <param name="org">The name of the organization.</param>
|
||||
/// <param name="runnerGroupId">Unique identifier of the self-hosted runner group.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions self-hosted runner groups for an organization.</returns>
|
||||
public static Uri ActionsGetOrganizationRunnerGroup(string org, long runnerGroupId)
|
||||
{
|
||||
return "orgs/{0}/actions/runner-groups/{1}".FormatUri(org, runnerGroupId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions self-hosted runner groups for an enterprise.
|
||||
/// </summary>
|
||||
|
||||
@@ -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<string> selectedWorkflows, bool workflowRestrictionsReadOnly)
|
||||
public RunnerGroup(long id, string name, string visibility, bool @default, string runnersUrl, bool inherited, bool allowsPublicRepositories, bool restrictedToWorkflows, List<string> 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<string> SelectedWorkflows { get; private set; }
|
||||
public bool WorkflowRestrictionsReadOnly { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay => string.Format("Id: {0}, Name: {1}, Visibility: {2}, Default: {3}, RunnersUrl: {4}, AllowsPublicRepositories: {5}, RestrictedToWorkflows: {6}, SelectedWorkflows: {7}, WorkflowRestrictionsReadOnly: {8}",
|
||||
Id, Name, Visibility, Default, RunnersUrl, AllowsPublicRepositories, RestrictedToWorkflows, string.Join(", ", SelectedWorkflows.Select(x => x.ToString())), WorkflowRestrictionsReadOnly);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user