Interface SecretManagerOperations

All Known Implementing Classes:
SecretManagerTemplate

public interface SecretManagerOperations
Describes supported operations that one can perform on the Secret Manager API.

For some methods you may specify the secret from GCP Secret Manager by URI string. The following secret URI syntax is supported:

1. Long form - specify the project ID, secret ID, and version sm://projects/{project-id}/secrets/{secret-id}/versions/{version-id}

2. Long form - specify project ID, secret ID, and use latest version sm://projects/{project-id}/secrets/{secret-id}

3. Short form - specify project ID, secret ID, and version sm://{project-id}/{secret-id}/{version-id}

4. Short form - specify secret and version, use default GCP project configured sm://{secret-id}/{version}

5. Shortest form - specify secret ID, use default project and latest version. sm://{secret-id}

Since:
1.2.2
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    createSecret(String secretId, byte[] payload)
    Creates a new secret or a new version of existing secret with the provided payload.
    void
    createSecret(String secretId, byte[] payload, String projectId)
    Creates a new secret or a new version of existing secret with the provided payload for a specific projectId.
    void
    createSecret(String secretId, String payload)
    Creates a new secret or a new version of existing secret with the provided payload.
    void
    deleteSecret(String secretId)
    Deletes the specified secret under the default-configured project.
    void
    deleteSecret(String secretId, String projectId)
    Deletes the specified secret.
    void
    deleteSecretVersion(String secretId, String version, String projectId)
    Deletes the specified secret version.
    void
    disableSecretVersion(String secretId, String version)
    Disables the specified secret version under the default-configured project.
    void
    disableSecretVersion(String secretId, String version, String projectId)
    Disables the secret version under the specified project.
    void
    enableSecretVersion(String secretId, String version)
    Enables the specified secret version under the default-configured project.
    void
    enableSecretVersion(String secretId, String version, String projectId)
    Enables the secret version under the specified project.
    byte[]
    getSecretBytes(String secretIdentifier)
    Gets the secret payload of the specified secretIdentifier secret.
    getSecretString(String secretIdentifier)
    Gets the secret payload of the specified secretIdentifier secret.
    boolean
    secretExists(String secretId)
    Returns true if there already exists a secret under the GCP project with the secretId.
    boolean
    secretExists(String secretId, String projectId)
    Returns true if there already exists a secret under the GCP projectId with the secretId.
  • Method Details

    • createSecret

      void createSecret(String secretId, String payload)
      Creates a new secret or a new version of existing secret with the provided payload.

      If there is already a secret saved in SecretManager with the specified secretId, then it simply creates a new version under the secret with the secret payload.

      Parameters:
      secretId - the secret ID of the secret to create.
      payload - the secret payload string.
    • createSecret

      void createSecret(String secretId, byte[] payload)
      Creates a new secret or a new version of existing secret with the provided payload.

      If there is already a secret saved in SecretManager with the specified secretId, then it simply creates a new version under the secret with the secret payload.

      Parameters:
      secretId - the secret ID of the secret to create.
      payload - the secret payload as a byte array.
    • createSecret

      void createSecret(String secretId, byte[] payload, String projectId)
      Creates a new secret or a new version of existing secret with the provided payload for a specific projectId.

      If there is already a secret saved in SecretManager with the specified secretId, then it simply creates a new version under the secret with the secret payload.

      Parameters:
      secretId - the secret ID of the secret to create.
      payload - the secret payload as a byte array.
      projectId - unique identifier of your project.
    • enableSecretVersion

      void enableSecretVersion(String secretId, String version)
      Enables the specified secret version under the default-configured project.
      Parameters:
      secretId - the secret ID of the secret to enable.
      version - the version to enable
    • enableSecretVersion

      void enableSecretVersion(String secretId, String version, String projectId)
      Enables the secret version under the specified project.
      Parameters:
      secretId - the secret ID of the secret to enable.
      version - the version to enable
      projectId - unique identifier of your project.
    • disableSecretVersion

      void disableSecretVersion(String secretId, String version)
      Disables the specified secret version under the default-configured project.
      Parameters:
      secretId - the secret ID of the secret to disable.
      version - the version to disable
    • disableSecretVersion

      void disableSecretVersion(String secretId, String version, String projectId)
      Disables the secret version under the specified project.
      Parameters:
      secretId - the secret ID of the secret to disable.
      version - the version to disable
      projectId - unique identifier of your project.
    • deleteSecret

      void deleteSecret(String secretId)
      Deletes the specified secret under the default-configured project.
      Parameters:
      secretId - the secret ID of the secret to delete.
    • deleteSecret

      void deleteSecret(String secretId, String projectId)
      Deletes the specified secret.
      Parameters:
      secretId - the secret ID of the secret to delete.
      projectId - the GCP project containing the secret to delete.
    • deleteSecretVersion

      void deleteSecretVersion(String secretId, String version, String projectId)
      Deletes the specified secret version.
      Parameters:
      secretId - the secret ID of the secret to delete.
      version - the version to delete
      projectId - the GCP project containing the secret to delete.
    • getSecretString

      String getSecretString(String secretIdentifier)
      Gets the secret payload of the specified secretIdentifier secret.

      The secretIdentifier must either be a secret ID or a fully qualified `sm://` protocol string which specifies the secret (see javadocs of SecretManagerOperations for the protocol format).

      If the secret ID string is passed in, then this will return the payload of the secret for the default project at the latest version.

      Parameters:
      secretIdentifier - the GCP secret ID of the secret or a sm:// formatted string specifying the secret.
      Returns:
      The secret payload as String
    • getSecretBytes

      byte[] getSecretBytes(String secretIdentifier)
      Gets the secret payload of the specified secretIdentifier secret.

      The secretIdentifier must either be a secret ID or a fully qualified `sm://` protocol string which specifies the secret (see javadocs of SecretManagerOperations for the protocol format).

      If the secret ID string is passed in, then this will return the payload of the secret for the default project at the latest version.

      Parameters:
      secretIdentifier - the GCP secret ID of the secret or a sm:// formatted string specifying the secret.
      Returns:
      The secret payload as byte array
    • secretExists

      boolean secretExists(String secretId)
      Returns true if there already exists a secret under the GCP project with the secretId.
      Parameters:
      secretId - unique identifier of your secret in Secret Manager.
      Returns:
      true if the secret exists in Secret Manager; false otherwise
    • secretExists

      boolean secretExists(String secretId, String projectId)
      Returns true if there already exists a secret under the GCP projectId with the secretId.
      Parameters:
      secretId - unique identifier of your secret in Secret Manager.
      projectId - unique identifier of your project.
      Returns:
      true if the secret exists in Secret Manager; false otherwise