Interface SecretManagerClient

  • All Known Implementing Classes:
    SecretManagerClientImpl

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

      • getProject

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

        void createSecret​(java.lang.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​(java.lang.String secretId)
        Checks if a secret with the given secretId already exists.
      • listSecrets

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

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

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

        java.lang.String addSecretVersion​(java.lang.String secretId,
                                          java.lang.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

        java.lang.String getSecretData​(java.lang.String secretId,
                                       java.util.Optional<java.lang.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​(java.lang.String secretId,
                                 java.lang.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​(java.lang.String secretId,
                                  java.lang.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​(java.lang.String secretId,
                                  java.lang.String version)
        Destroys a secret version.
        Parameters:
        secretId - The ID of the secret
        version - The version of the secret to destroy
      • deleteSecret

        void deleteSecret​(java.lang.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