Files
octokit.net/Octokit/Clients/IOrganizationSecretsClient.cs
Keegan Campbell 131ba87e3f Replay #2221: Implement GitHub Actions Secrets API for both Organization and Repository (#2598)
* 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>
2022-10-20 14:59:31 -07:00

119 lines
6.7 KiB
C#

using System.Threading.Tasks;
namespace Octokit
{
/// <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 IOrganizationSecretsClient
{
/// <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>
Task<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>
Task<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>
Task<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>
Task<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>
Task 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>
Task<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>
Task 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>
Task 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>
Task RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId);
}
}