Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Expand OpenAPI Specification for Managing Self-Hosted Runner Groups #48

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

#nullable enable

namespace GitHub
{
public partial class ActionsClient
{
partial void PrepareActionsAddRepoAccessToSelfHostedRunnerGroupInOrgArguments(
global::System.Net.Http.HttpClient httpClient,
ref string org,
ref int runnerGroupId,
ref int repositoryId);
partial void PrepareActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string org,
int runnerGroupId,
int repositoryId);
partial void ProcessActionsAddRepoAccessToSelfHostedRunnerGroupInOrgResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

/// <summary>
/// Add repository access to a self-hosted runner group in an organization<br/>
/// Adds a repository to the list of repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)."<br/>
/// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
/// </summary>
/// <param name="org"></param>
/// <param name="runnerGroupId"></param>
/// <param name="repositoryId"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgAsync(
string org,
int runnerGroupId,
int repositoryId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareActionsAddRepoAccessToSelfHostedRunnerGroupInOrgArguments(
httpClient: _httpClient,
org: ref org,
runnerGroupId: ref runnerGroupId,
repositoryId: ref repositoryId);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Put,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/orgs/{org}/actions/runner-groups/{runnerGroupId}/repositories/{repositoryId}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareActionsAddRepoAccessToSelfHostedRunnerGroupInOrgRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
org: org,
runnerGroupId: runnerGroupId,
repositoryId: repositoryId);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessActionsAddRepoAccessToSelfHostedRunnerGroupInOrgResponse(
httpClient: _httpClient,
httpResponseMessage: response);
response.EnsureSuccessStatusCode();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

#nullable enable

namespace GitHub
{
public partial class ActionsClient
{
partial void PrepareActionsAddSelfHostedRunnerToGroupForOrgArguments(
global::System.Net.Http.HttpClient httpClient,
ref string org,
ref int runnerGroupId,
ref int runnerId);
partial void PrepareActionsAddSelfHostedRunnerToGroupForOrgRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string org,
int runnerGroupId,
int runnerId);
partial void ProcessActionsAddSelfHostedRunnerToGroupForOrgResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

/// <summary>
/// Add a self-hosted runner to a group for an organization<br/>
/// Adds a self-hosted runner to a runner group configured in an organization.<br/>
/// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
/// </summary>
/// <param name="org"></param>
/// <param name="runnerGroupId"></param>
/// <param name="runnerId"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task ActionsAddSelfHostedRunnerToGroupForOrgAsync(
string org,
int runnerGroupId,
int runnerId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareActionsAddSelfHostedRunnerToGroupForOrgArguments(
httpClient: _httpClient,
org: ref org,
runnerGroupId: ref runnerGroupId,
runnerId: ref runnerId);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Put,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/orgs/{org}/actions/runner-groups/{runnerGroupId}/runners/{runnerId}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareActionsAddSelfHostedRunnerToGroupForOrgRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
org: org,
runnerGroupId: runnerGroupId,
runnerId: runnerId);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessActionsAddSelfHostedRunnerToGroupForOrgResponse(
httpClient: _httpClient,
httpResponseMessage: response);
response.EnsureSuccessStatusCode();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@

#nullable enable

namespace GitHub
{
public partial class ActionsClient
{
partial void PrepareActionsCreateSelfHostedRunnerGroupForOrgArguments(
global::System.Net.Http.HttpClient httpClient,
ref string org,
global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequest request);
partial void PrepareActionsCreateSelfHostedRunnerGroupForOrgRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string org,
global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequest request);
partial void ProcessActionsCreateSelfHostedRunnerGroupForOrgResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessActionsCreateSelfHostedRunnerGroupForOrgResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
/// Create a self-hosted runner group for an organization<br/>
/// Creates a new self-hosted runner group for an organization.<br/>
/// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
/// </summary>
/// <param name="org"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::GitHub.RunnerGroupsOrg> ActionsCreateSelfHostedRunnerGroupForOrgAsync(
string org,
global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequest request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: _httpClient);
PrepareActionsCreateSelfHostedRunnerGroupForOrgArguments(
httpClient: _httpClient,
org: ref org,
request: request);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/orgs/{org}/actions/runner-groups", global::System.UriKind.RelativeOrAbsolute));
var __httpRequestContentBody = global::System.Text.Json.JsonSerializer.Serialize(request, global::GitHub.SourceGenerationContext.Default.ActionsCreateSelfHostedRunnerGroupForOrgRequest);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareActionsCreateSelfHostedRunnerGroupForOrgRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
org: org,
request: request);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessActionsCreateSelfHostedRunnerGroupForOrgResponse(
httpClient: _httpClient,
httpResponseMessage: response);

var __content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

ProcessResponseContent(
client: _httpClient,
response: response,
content: ref __content);
ProcessActionsCreateSelfHostedRunnerGroupForOrgResponseContent(
httpClient: _httpClient,
httpResponseMessage: response,
content: ref __content);

try
{
response.EnsureSuccessStatusCode();
}
catch (global::System.Net.Http.HttpRequestException ex)
{
throw new global::System.InvalidOperationException(__content, ex);
}

return
global::System.Text.Json.JsonSerializer.Deserialize(__content, global::GitHub.SourceGenerationContext.Default.RunnerGroupsOrg) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}

/// <summary>
/// Create a self-hosted runner group for an organization<br/>
/// Creates a new self-hosted runner group for an organization.<br/>
/// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
/// </summary>
/// <param name="org"></param>
/// <param name="name">
/// Name of the runner group.
/// </param>
/// <param name="visibility">
/// Visibility of a runner group. You can select all repositories, select individual repositories, or limit access to private repositories.<br/>
/// Default Value: all
/// </param>
/// <param name="selectedRepositoryIds">
/// List of repository IDs that can access the runner group.
/// </param>
/// <param name="runners">
/// List of runner IDs to add to the runner group.
/// </param>
/// <param name="allowsPublicRepositories">
/// Whether the runner group can be used by `public` repositories.<br/>
/// Default Value: false
/// </param>
/// <param name="restrictedToWorkflows">
/// If `true`, the runner group will be restricted to running only the workflows specified in the `selected_workflows` array.<br/>
/// Default Value: false
/// </param>
/// <param name="selectedWorkflows">
/// List of workflows the runner group should be allowed to run. This setting will be ignored unless `restricted_to_workflows` is set to `true`.
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::GitHub.RunnerGroupsOrg> ActionsCreateSelfHostedRunnerGroupForOrgAsync(
string org,
string name,
global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequestVisibility? visibility = global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequestVisibility.All,
global::System.Collections.Generic.IList<int>? selectedRepositoryIds = default,
global::System.Collections.Generic.IList<int>? runners = default,
bool allowsPublicRepositories = false,
bool restrictedToWorkflows = false,
global::System.Collections.Generic.IList<string>? selectedWorkflows = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var request = new global::GitHub.ActionsCreateSelfHostedRunnerGroupForOrgRequest
{
Name = name,
Visibility = visibility,
SelectedRepositoryIds = selectedRepositoryIds,
Runners = runners,
AllowsPublicRepositories = allowsPublicRepositories,
RestrictedToWorkflows = restrictedToWorkflows,
SelectedWorkflows = selectedWorkflows,
};

return await ActionsCreateSelfHostedRunnerGroupForOrgAsync(
org: org,
request: request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

#nullable enable

namespace GitHub
{
public partial class ActionsClient
{
partial void PrepareActionsDeleteSelfHostedRunnerGroupFromOrgArguments(
global::System.Net.Http.HttpClient httpClient,
ref string org,
ref int runnerGroupId);
partial void PrepareActionsDeleteSelfHostedRunnerGroupFromOrgRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string org,
int runnerGroupId);
partial void ProcessActionsDeleteSelfHostedRunnerGroupFromOrgResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

/// <summary>
/// Delete a self-hosted runner group from an organization<br/>
/// Deletes a self-hosted runner group for an organization.<br/>
/// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint.
/// </summary>
/// <param name="org"></param>
/// <param name="runnerGroupId"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task ActionsDeleteSelfHostedRunnerGroupFromOrgAsync(
string org,
int runnerGroupId,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: _httpClient);
PrepareActionsDeleteSelfHostedRunnerGroupFromOrgArguments(
httpClient: _httpClient,
org: ref org,
runnerGroupId: ref runnerGroupId);

using var httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Delete,
requestUri: new global::System.Uri(_httpClient.BaseAddress?.AbsoluteUri.TrimEnd('/') + $"/orgs/{org}/actions/runner-groups/{runnerGroupId}", global::System.UriKind.RelativeOrAbsolute));

PrepareRequest(
client: _httpClient,
request: httpRequest);
PrepareActionsDeleteSelfHostedRunnerGroupFromOrgRequest(
httpClient: _httpClient,
httpRequestMessage: httpRequest,
org: org,
runnerGroupId: runnerGroupId);

using var response = await _httpClient.SendAsync(
request: httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: _httpClient,
response: response);
ProcessActionsDeleteSelfHostedRunnerGroupFromOrgResponse(
httpClient: _httpClient,
httpResponseMessage: response);
response.EnsureSuccessStatusCode();
}
}
}
Loading
Loading