Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/octokit#2870
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Jan 8, 2025
2 parents c12055a + 7c6c08f commit 7139ed5
Show file tree
Hide file tree
Showing 53 changed files with 989 additions and 93 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,7 @@ tools/*
coverage-results/*

# Rider
**/.idea/*
**/.idea/*

# macOS
.DS_Store
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
"files.insertFinalNewline": true,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.insertSpaces": true
"editor.insertSpaces": true,
"[csharp]": {
"editor.tabSize": 4
},
"explorer.fileNesting.patterns": {
"*.cs": "I${capture}.cs",
},
}
8 changes: 0 additions & 8 deletions Octokit.AsyncPaginationExtension/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@ public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsCl
public static IPaginatedList<Collaborator> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Collaborator>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IActionsSelfHostedRunnerGroupsClient.ListAllRunnerGroupOrganizationsForEnterprise(string, long, ApiOptions)"/>
public static IPaginatedList<Organization> ListAllRunnerGroupOrganizationsForEnterpriseAsync(this IActionsSelfHostedRunnerGroupsClient t, string enterprise, long runnerGroupId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Organization>(options => t.ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IActionsSelfHostedRunnerGroupsClient.ListAllRunnerGroupRepositoriesForOrganization(string, long, ApiOptions)"/>
public static IPaginatedList<Repository> ListAllRunnerGroupRepositoriesForOrganizationAsync(this IActionsSelfHostedRunnerGroupsClient t, string org, long runnerGroupId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<Repository>(options => t.ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");

/// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/>
public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE)
=> pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);
IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId);

/// <summary>
/// List organization access to a self-hosted runner group in an enterprise
Expand All @@ -128,7 +128,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);
IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -138,7 +138,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);
IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId);

/// <summary>
/// List repository access to a self-hosted runner group in an organization
Expand All @@ -149,7 +149,7 @@ public interface IObservableActionsSelfHostedRunnerGroupsClient
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group id</param>
/// <param name="options">Options for changing the API response</param>
IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);
IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options);

}
}
25 changes: 23 additions & 2 deletions Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Octokit.Reactive
public interface IObservableActionsWorkflowsClient
{
/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
Expand All @@ -24,7 +24,7 @@ public interface IObservableActionsWorkflowsClient
IObservable<Unit> CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch);

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
Expand All @@ -35,6 +35,27 @@ public interface IObservableActionsWorkflowsClient
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
IObservable<Unit> CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch);

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
IObservable<Unit> CreateDispatch(long repositoryId, string workflowFileName, CreateWorkflowDispatch createDispatch);

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
IObservable<Unit> CreateDispatch(long repositoryId, long workflowId, CreateWorkflowDispatch createDispatch);
/// <summary>
/// Disables a specific workflow in a repository by Id.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions Octokit.Reactive/Clients/IObservableMetaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace Octokit.Reactive
/// </remarks>
public interface IObservableMetaClient
{
/// <summary>
/// Returns a client to get public keys for validating request signatures.
/// </summary>
IObservablePublicKeysClient PublicKeys { get; }

/// <summary>
/// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation.
/// </summary>
Expand Down
19 changes: 12 additions & 7 deletions Octokit.Reactive/Clients/IObservableOauthClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Threading;

namespace Octokit.Reactive
{
Expand All @@ -22,8 +23,9 @@ public interface IObservableOauthClient
/// an access token using this method.
/// </remarks>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request);
IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Makes a request to initiate the device flow authentication.
Expand All @@ -33,25 +35,28 @@ public interface IObservableOauthClient
/// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication.
/// </remarks>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
IObservable<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request);
IObservable<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/>.
/// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest, CancellationToken)"/>.
/// </summary>
/// <remarks>
/// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code.
/// </remarks>
/// <param name="clientId">The client Id you received from GitHub when you registered the application.</param>
/// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/></param>
/// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest, CancellationToken)"/></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
IObservable<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse);
IObservable<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse, CancellationToken cancellationToken = default);

/// <summary>
/// Makes a request to get an access token using the refresh token returned in <see cref="CreateAccessToken(OauthTokenRequest)"/>.
/// Makes a request to get an access token using the refresh token returned in <see cref="CreateAccessToken(OauthTokenRequest, CancellationToken)"/>.
/// </summary>
/// <param name="request">Token renewal request.</param>
/// <param name="cancellationToken"></param>
/// <returns><see cref="OauthToken"/> with the new token set.</returns>
IObservable<OauthToken> CreateAccessTokenFromRenewalToken(OauthTokenRenewalRequest request);
IObservable<OauthToken> CreateAccessTokenFromRenewalToken(OauthTokenRenewalRequest request, CancellationToken cancellationToken = default);
}
}
20 changes: 20 additions & 0 deletions Octokit.Reactive/Clients/IObservablePublicKeysClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Octokit.Reactive
{
/// <summary>
/// A client for GitHub's meta public keys API.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/code-security/secret-scanning/secret-scanning-partner-program#implement-signature-verification-in-your-secret-alert-service">Secret scanning documentation</a> for more details.
/// </remarks>
public interface IObservablePublicKeysClient
{
/// <summary>
/// Retrieves public keys for validating request signatures.
/// </summary>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>An <see cref="MetaPublicKeys"/> containing public keys for validating request signatures.</returns>
IObservable<MetaPublicKeys> Get(PublicKeyType keysType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public IObservable<RunnerResponse> ListAllRunnersForOrganizationRunnerGroup(stri
/// </remarks>
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
public IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId)
{
return ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, ApiOptions.None);
}
Expand All @@ -189,12 +189,12 @@ public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(st
/// <param name="enterprise">The enterprise name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
public IObservable<OrganizationsResponse> ListAllRunnerGroupOrganizationsForEnterprise(string enterprise, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(enterprise, nameof(enterprise));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Organization>(ApiUrls.ActionsListEnterpriseRunnerGroupOrganizations(enterprise, runnerGroupId), options);
return _client.ListAllRunnerGroupOrganizationsForEnterprise(enterprise, runnerGroupId, options).ToObservable();
}

/// <summary>
Expand All @@ -205,7 +205,7 @@ public IObservable<Organization> ListAllRunnerGroupOrganizationsForEnterprise(st
/// </remarks>
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
public IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId)
{
return ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, ApiOptions.None);
}
Expand All @@ -219,12 +219,12 @@ public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(str
/// <param name="org">The organization name</param>
/// <param name="runnerGroupId">The runner group ID</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<Repository> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
public IObservable<RepositoriesResponse> ListAllRunnerGroupRepositoriesForOrganization(string org, long runnerGroupId, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.ActionsListOrganizationRunnerGroupRepositories(org, runnerGroupId), options);
return _client.ListAllRunnerGroupRepositoriesForOrganization(org, runnerGroupId, options).ToObservable();
}

}
Expand Down
37 changes: 35 additions & 2 deletions Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ObservableActionsWorkflowsClient(IGitHubClient client)
}

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
Expand All @@ -43,7 +43,7 @@ public IObservable<Unit> CreateDispatch(string owner, string name, string workfl
}

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
Expand All @@ -61,6 +61,39 @@ public IObservable<Unit> CreateDispatch(string owner, string name, long workflow
return _client.CreateDispatch(owner, name, workflowId, createDispatch).ToObservable();
}

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(long repositoryId, string workflowFileName, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));

return _client.CreateDispatch(repositoryId, workflowFileName, createDispatch).ToObservable();
}

/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(long repositoryId, long workflowId, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));

return _client.CreateDispatch(repositoryId, workflowId, createDispatch).ToObservable();
}

/// <summary>
/// Disables a specific workflow in a repository by Id.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Octokit.Reactive/Clients/ObservableMetaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ public ObservableMetaClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));

PublicKeys = new ObservablePublicKeysClient(client);

_client = client.Meta;
}

/// <summary>
/// Returns a client to manage get public keys for validating request signatures.
/// </summary>
public IObservablePublicKeysClient PublicKeys { get; private set; }

/// <summary>
/// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation.
/// </summary>
Expand Down
Loading

0 comments on commit 7139ed5

Please sign in to comment.