Interface SecretManagerClient

All Known Implementing Classes:
SecretManagerClientImpl

public interface SecretManagerClient
A Cloud Secret Manager client for Nomulus, bound to a specific GCP project.
  • Method Details

    • getProject

      String getProject()
      Returns the project name with which this client is associated.
    • createSecret

      void createSecret(String secretId)
      Creates a new secret in the Cloud Secret Manager with no data.

      Use addVersion to add data to this secret.

      Parameters:
      secretId - The ID of the secret, must be unique in a project
      Throws:
      SecretManagerClient.SecretAlreadyExistsException - A secret with this secretId already exists
    • secretExists

      boolean secretExists(String secretId)
      Checks if a secret with the given secretId already exists.
    • listSecrets

      Iterable<String> listSecrets()
      Returns all secret IDs in the Cloud Secret Manager.
    • listSecretVersions

      Returns the SecretManagerClient.SecretVersionState of all secrets with secretId.
    • createSecretIfAbsent

      default void createSecretIfAbsent(String secretId)
      Creates a secret if it does not already exists.
    • listSecretVersions

      default Iterable<String> listSecretVersions(String secretId, com.google.cloud.secretmanager.v1.SecretVersion.State state)
      Returns the version strings of all secrets in the given state with secretId.
    • addSecretVersion

      String addSecretVersion(String secretId, String data)
      Adds a new version of data to a secret.
      Parameters:
      secretId - The ID of the secret
      data - The secret data to be stored in Cloud Secret Manager, encoded in utf-8 charset
      Returns:
      The version string of the newly added secret data
    • getSecretData

      String getSecretData(String secretId, Optional<String> version)
      Returns the data of a secret at the given version.
      Parameters:
      secretId - The ID of the secret
      version - The version of the secret to fetch. If not provided, the latest version will be returned
    • enableSecretVersion

      void enableSecretVersion(String secretId, String version)
      Enables a secret version.
      Parameters:
      secretId - The ID of the secret
      version - The version of the secret to fetch. If not provided, the latest version will be returned
    • disableSecretVersion

      void disableSecretVersion(String secretId, String version)
      Disables a secret version.
      Parameters:
      secretId - The ID of the secret
      version - The version of the secret to fetch. If not provided, the latest version will be returned
    • destroySecretVersion

      void destroySecretVersion(String secretId, String version)
      Destroys a secret version.
      Parameters:
      secretId - The ID of the secret
      version - The version of the secret to destroy
    • deleteSecret

      void deleteSecret(String secretId)
      Deletes a secret from the Secret Manager. All versions of this secret will be destroyed.
      Parameters:
      secretId - The ID of the secret to be deleted