mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
* created the interface and models for the repository secrets client * created a repository actions client to sit between repository and secrets for future extensibility * created the repository secret client and supporting objects to enable data transfer * created object for create or update secret body and made fixes to pass unit tests * created repository action unit tests * created unit tests for RepositorySecretsClient * removed set from secrets interface * fixed docs and added observable actions client * added Actions to repository client * created IObservable repository secrets client * fixed property in wrong interface fixed wrong Ctor unit test * created repository decrets reactive tests and clients * created organization actions and scerets classes and made them available through the oprganizations client * fixed intellisense text * removed uneeded getall call after return type change * created organization secret client and classes to support it * created the observable org secrets client and fixed a typo in a method name * added more ensure checks * removed unused xml doc setting * created the unit tests for the organization secrets client fixed broken unit test for repository secrets client * created observable organization actions and secrets client unit tests * added sodium.core to the integration tests to test secret creation * fixed keyid type * added actions client integration test classes (empty since the class currently doesn't have any native methods) * fixed deserialization issue * changed property name for deserialization issues * added doc for repoid on orginzation secrets url generator * created integration tests for repository and organization secrets * changed how return occurs for setting list of repos for secret * fixed some names and removed reset org name * created integration tests for observable org secrets client * removed default org value * created the integration tests for the observable repository secrets client * removed default owner project value * fixed unit tests * Update links to new docs site * Update doc links to new docs site * Update docs links to new docs site * Fix doc link to point to new docs site * Update links to new docs site * Update doc links to new docs site * Update docs links * Update docs * Update docs * Update doc links * Update docs * Update doc links * Update doc links * Update doc links * updated documentation links in actions and secrets clients * Update Octokit/Models/Response/SecretsPublicKey.cs Removing line for consistency. Co-authored-by: Thomas Hughes <iamhughes@github.com> * Update Octokit/Models/Response/RepositorySecret.cs Removing line for consistency. Co-authored-by: Thomas Hughes <iamhughes@github.com> * set default owner and repo * switched to using the Helper.Organization from a ORG constant set at the top of the file * swapped out variable at top of file for the Helper.Organization property * switched to helper method to create new repositories * Protected setters --> private setters in response models * RepositorySecret needs protected setters Co-authored-by: Mike Tolly <mike.tolly@takeda.com> Co-authored-by: Thomas Hughes <iamhughes@github.com> Co-authored-by: mptolly-takeda <61791994+mptolly-takeda@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Org Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions"> Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableOrganizationActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization secrets.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets"> Secrets API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableOrganizationSecretsClient Secrets { get; }
|
||||
}
|
||||
}
|
||||
119
Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs
Normal file
119
Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Secrets API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets">Organization Secrets API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public interface IObservableOrganizationSecretsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the public signing key to encrypt secrets for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns>
|
||||
IObservable<SecretsPublicKey> GetPublicKey(string org);
|
||||
|
||||
/// <summary>
|
||||
/// List the secrets for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-organization-secrets">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns>
|
||||
IObservable<OrganizationSecretsCollection> GetAll(string org);
|
||||
|
||||
/// <summary>
|
||||
/// Get a secret from an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns>
|
||||
IObservable<OrganizationSecret> Get(string org, string secretName);
|
||||
|
||||
/// <summary>
|
||||
/// Create or update a secret in an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns>
|
||||
IObservable<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a secret in an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<Unit> Delete(string org, string secretName);
|
||||
|
||||
/// <summary>
|
||||
/// Get the list of selected sites that have access to a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName);
|
||||
|
||||
/// <summary>
|
||||
/// Set the list of selected sites that have access to a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repositories">The list of repositories that should have access to view and use the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<Unit> SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories);
|
||||
|
||||
/// <summary>
|
||||
/// Add a selected site to the visibility list of a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repoId">The id of the repo to add to the visibility list of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<Unit> AddRepoToOrganizationSecret(string org, string secretName, long repoId);
|
||||
|
||||
/// <summary>
|
||||
/// ARemoved a selected site from the visibility list of a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repoId">The id of the repo to add to the visibility list of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<Unit> RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
IObservableOrganizationOutsideCollaboratorsClient OutsideCollaborator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization actions.
|
||||
/// </summary>
|
||||
IObservableOrganizationActionsClient Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the specified organization.
|
||||
/// </summary>
|
||||
|
||||
@@ -195,6 +195,14 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
IObservable<Repository> GetAllForOrg(string organization, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Repository Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
IObservableRepositoryActionsClient Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing branches in a repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public interface IObservableRepositoryActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Actions API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
IObservableRepositorySecretsClient Secrets { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Secrets API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/actions/secrets/">Repository Secrets API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public interface IObservableRepositorySecretsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the public signing key to encrypt secrets for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns>
|
||||
IObservable<SecretsPublicKey> GetPublicKey(string owner, string repoName);
|
||||
|
||||
/// <summary>
|
||||
/// List the secrets for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-repository-secrets">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="IEnumerable{RepositorySecret}"/> instance for the list of repository secrets.</returns>
|
||||
IObservable<RepositorySecretsCollection> GetAll(string owner, string repoName);
|
||||
|
||||
/// <summary>
|
||||
/// Get a secret from a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns>
|
||||
IObservable<RepositorySecret> Get(string owner, string repoName, string secretName);
|
||||
|
||||
/// <summary>
|
||||
/// Create or update a secret in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="upsertSecret">The encrypted value and id of the encryption key</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns>
|
||||
IObservable<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret);
|
||||
|
||||
/// <summary>
|
||||
/// Delete a secret in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
IObservable<Unit> Delete(string owner, string repoName, string secretName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Org Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions"> Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableOrganizationActionsClient : IObservableOrganizationActionsClient
|
||||
{
|
||||
readonly IOrganizationActionsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Organization API client.
|
||||
/// </summary>
|
||||
/// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param>
|
||||
public ObservableOrganizationActionsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
Secrets = new ObservableOrganizationSecretsClient(client);
|
||||
|
||||
_client = client.Organization.Actions;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization secrets.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets"> Secrets API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableOrganizationSecretsClient Secrets { get; private set; }
|
||||
}
|
||||
}
|
||||
193
Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs
Normal file
193
Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Secrets API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets">Organization Secrets API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public class ObservableOrganizationSecretsClient : IObservableOrganizationSecretsClient
|
||||
{
|
||||
readonly IOrganizationSecretsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new Organization API client.
|
||||
/// </summary>
|
||||
/// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param>
|
||||
public ObservableOrganizationSecretsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Organization.Actions.Secrets;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the public signing key to encrypt secrets for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns>
|
||||
public IObservable<SecretsPublicKey> GetPublicKey(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return _client.GetPublicKey(org).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List the secrets for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-organization-secrets">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns>
|
||||
public IObservable<OrganizationSecretsCollection> GetAll(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return _client.GetAll(org).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a secret from an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns>
|
||||
public IObservable<OrganizationSecret> Get(string org, string secretName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
|
||||
return _client.Get(org, secretName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create or update a secret in an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns>
|
||||
public IObservable<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret));
|
||||
Ensure.ArgumentNotNull(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue));
|
||||
Ensure.ArgumentNotNull(upsertSecret.KeyId, nameof(upsertSecret.KeyId));
|
||||
|
||||
return _client.CreateOrUpdate(org, secretName, upsertSecret).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a secret in an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> Delete(string org, string secretName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
|
||||
return _client.Delete(org, secretName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the list of selected sites that have access to a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
|
||||
return _client.GetSelectedRepositoriesForSecret(org, secretName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the list of selected sites that have access to a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repositories">The list of repositories that should have access to view and use the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
Ensure.ArgumentNotNull(repositories, nameof(repositories));
|
||||
|
||||
return _client.SetSelectedRepositoriesForSecret(org, secretName, repositories).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a selected site to the visibility list of a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repoId">The id of the repo to add to the visibility list of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> AddRepoToOrganizationSecret(string org, string secretName, long repoId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
Ensure.ArgumentNotNull(repoId, nameof(repoId));
|
||||
|
||||
return _client.AddRepoToOrganizationSecret(org, secretName, repoId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ARemoved a selected site from the visibility list of a secret.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="repoId">The id of the repo to add to the visibility list of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
Ensure.ArgumentNotNull(repoId, nameof(repoId));
|
||||
|
||||
return _client.RemoveRepoFromOrganizationSecret(org, secretName, repoId).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
@@ -21,6 +22,7 @@ namespace Octokit.Reactive
|
||||
Team = new ObservableTeamsClient(client);
|
||||
Hook = new ObservableOrganizationHooksClient(client);
|
||||
OutsideCollaborator = new ObservableOrganizationOutsideCollaboratorsClient(client);
|
||||
Actions = new ObservableOrganizationActionsClient(client);
|
||||
|
||||
_client = client.Organization;
|
||||
_connection = client.Connection;
|
||||
@@ -47,6 +49,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
public IObservableOrganizationOutsideCollaboratorsClient OutsideCollaborator { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization actions.
|
||||
/// </summary>
|
||||
public IObservableOrganizationActionsClient Actions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the specified organization.
|
||||
/// </summary>
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Octokit.Reactive
|
||||
Invitation = new ObservableRepositoryInvitationsClient(client);
|
||||
Traffic = new ObservableRepositoryTrafficClient(client);
|
||||
Project = new ObservableProjectsClient(client);
|
||||
Actions = new ObservableRepositoryActionsClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -805,6 +806,14 @@ namespace Octokit.Reactive
|
||||
return _client.Commit.Compare(owner, name, @base, head).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Actions API documentation</a> for more details
|
||||
/// </remarks>
|
||||
public IObservableRepositoryActionsClient Actions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Branches API.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public class ObservableRepositoryActionsClient : IObservableRepositoryActionsClient
|
||||
{
|
||||
readonly IRepositoryActionsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableRepositoryActionsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Repository.Actions;
|
||||
_connection = client.Connection;
|
||||
|
||||
Secrets = new ObservableRepositorySecretsClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Actions API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||
/// </remarks>
|
||||
public IObservableRepositorySecretsClient Secrets { get; private set; }
|
||||
}
|
||||
}
|
||||
128
Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs
Normal file
128
Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using Octokit.Reactive.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Secrets API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Secrets API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public class ObservableRepositorySecretsClient : IObservableRepositorySecretsClient
|
||||
{
|
||||
readonly IRepositorySecretsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableRepositorySecretsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Repository.Actions.Secrets;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the public signing key to encrypt secrets for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns>
|
||||
public IObservable<SecretsPublicKey> GetPublicKey(string owner, string repoName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
|
||||
return _client.GetPublicKey(owner, repoName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List the secrets for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#list-repository-secrets">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="IEnumerable{RepositorySecret}"/> instance for the list of repository secrets.</returns>
|
||||
public IObservable<RepositorySecretsCollection> GetAll(string owner, string repoName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
|
||||
return _client.GetAll(owner, repoName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a secret from a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns>
|
||||
public IObservable<RepositorySecret> Get(string owner, string repoName, string secretName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
|
||||
return _client.Get(owner, repoName, secretName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create or update a secret in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <param name="upsertSecret">The encrypted value and id of the encryption key</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns>
|
||||
public IObservable<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret));
|
||||
Ensure.ArgumentNotNullOrEmptyString(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue));
|
||||
Ensure.ArgumentNotNullOrEmptyString(upsertSecret.KeyId, nameof(upsertSecret.KeyId));
|
||||
|
||||
return _client.CreateOrUpdate(owner, repoName, secretName, upsertSecret).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a secret in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="repoName">The owner of the repository</param>
|
||||
/// <param name="owner">The name of the repository</param>
|
||||
/// <param name="secretName">The name of the secret</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> Delete(string owner, string repoName, string secretName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName));
|
||||
|
||||
return _client.Delete(owner, repoName, secretName).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user