Class Sys

java.lang.Object
codes.grow.packages.vault.Sys

public final class Sys extends Object
System backend: client.sys() (health, seal status, leader, capabilities, policies, mounts, auth methods, AppRole admin). Most write calls need a privileged (root or sudo) token.
  • Method Details

    • health

      public HealthResponse health()
      GET sys/health (unauthenticated). Sealed, standby and uninitialised nodes are no error.
      Returns:
      the health
    • healthAsync

      public CompletableFuture<HealthResponse> healthAsync()
      Asynchronous health().
      Returns:
      a future with the health
    • sealStatus

      public SealStatus sealStatus()
      GET sys/seal-status (unauthenticated).
      Returns:
      the seal status
    • sealStatusAsync

      public CompletableFuture<SealStatus> sealStatusAsync()
      Asynchronous sealStatus().
      Returns:
      a future with the seal status
    • leader

      public LeaderStatus leader()
      GET sys/leader (unauthenticated).
      Returns:
      the leader status
    • leaderAsync

      public CompletableFuture<LeaderStatus> leaderAsync()
      Asynchronous leader().
      Returns:
      a future with the leader status
    • version

      public String version()
      Server version from sys/health; UnsupportedException when none is reported.
      Returns:
      the version, e.g. 2.2.2
    • versionAsync

      public CompletableFuture<String> versionAsync()
      Asynchronous version().
      Returns:
      a future with the version
    • capabilitiesSelf

      public Capabilities capabilitiesSelf(String... paths)
      The client token's capabilities on each path (POST sys/capabilities-self), so callers can check a policy before acting. At least one path is required.
      Parameters:
      paths - one or more API paths, e.g. secret/data/app/db
      Returns:
      capabilities by path
    • capabilitiesSelf

      public Capabilities capabilitiesSelf(List<String> paths)
      The client token's capabilities on each path (POST sys/capabilities-self).
      Parameters:
      paths - one or more API paths
      Returns:
      capabilities by path
    • capabilitiesSelfAsync

      public CompletableFuture<Capabilities> capabilitiesSelfAsync(List<String> paths)
      Parameters:
      paths - one or more API paths
      Returns:
      a future with the capabilities by path
    • capabilities

      public Capabilities capabilities(String token, String... paths)
      Another token's capabilities on each path (POST sys/capabilities; the caller needs update on sys/capabilities, otherwise PermissionDeniedException).
      Parameters:
      token - the token to check
      paths - one or more API paths
      Returns:
      capabilities by path
    • capabilities

      public Capabilities capabilities(String token, List<String> paths)
      Another token's capabilities on each path (POST sys/capabilities).
      Parameters:
      token - the token to check
      paths - one or more API paths
      Returns:
      capabilities by path
    • capabilitiesAsync

      public CompletableFuture<Capabilities> capabilitiesAsync(String token, List<String> paths)
      Parameters:
      token - the token to check
      paths - one or more API paths
      Returns:
      a future with the capabilities by path
    • writePolicy

      public void writePolicy(String name, String policy)
      Creates or replaces an ACL policy: PUT sys/policies/acl/<name>. Invalid HCL raises ValidationException.
      Parameters:
      name - policy name
      policy - HCL text
    • writePolicyAsync

      public CompletableFuture<Void> writePolicyAsync(String name, String policy)
      Parameters:
      name - policy name
      policy - HCL text
      Returns:
      a future completed when done
    • readPolicy

      public Policy readPolicy(String name)
      Reads an ACL policy; NotFoundException when missing.
      Parameters:
      name - policy name
      Returns:
      the policy
    • readPolicyAsync

      public CompletableFuture<Policy> readPolicyAsync(String name)
      Asynchronous readPolicy(String).
      Parameters:
      name - policy name
      Returns:
      a future with the policy
    • listPolicies

      public List<String> listPolicies()
      ACL policy names (includes default and root).
      Returns:
      the names
    • listPoliciesAsync

      public CompletableFuture<List<String>> listPoliciesAsync()
      Asynchronous listPolicies().
      Returns:
      a future with the names
    • deletePolicy

      public void deletePolicy(String name)
      Deletes an ACL policy.
      Parameters:
      name - policy name
    • deletePolicyAsync

      public CompletableFuture<Void> deletePolicyAsync(String name)
      Asynchronous deletePolicy(String).
      Parameters:
      name - policy name
      Returns:
      a future completed when done
    • listMounts

      public Map<String,MountInfo> listMounts()
      Secrets engines by path ("secret/" to info).
      Returns:
      the mounts
    • listMountsAsync

      public CompletableFuture<Map<String,MountInfo>> listMountsAsync()
      Asynchronous listMounts().
      Returns:
      a future with the mounts
    • enableSecretsEngine

      public void enableSecretsEngine(String path, String type)
      Enables a secrets engine at path. A used path raises ValidationException.
      Parameters:
      path - mount path
      type - engine type, e.g. kv, transit
    • enableSecretsEngine

      public void enableSecretsEngine(String path, String type, EnableOptions options)
      Enables a secrets engine with options.
      Parameters:
      path - mount path
      type - engine type
      options - options (e.g. option("version", "2"))
    • enableSecretsEngineAsync

      public CompletableFuture<Void> enableSecretsEngineAsync(String path, String type, EnableOptions options)
      Parameters:
      path - mount path
      type - engine type
      options - options
      Returns:
      a future completed when done
    • disableSecretsEngine

      public void disableSecretsEngine(String path)
      Disables (unmounts) a secrets engine; its data is deleted.
      Parameters:
      path - mount path
    • disableSecretsEngineAsync

      public CompletableFuture<Void> disableSecretsEngineAsync(String path)
      Parameters:
      path - mount path
      Returns:
      a future completed when done
    • listAuthMethods

      public Map<String,MountInfo> listAuthMethods()
      Auth methods by path ("approle/" to info).
      Returns:
      the auth mounts
    • listAuthMethodsAsync

      public CompletableFuture<Map<String,MountInfo>> listAuthMethodsAsync()
      Asynchronous listAuthMethods().
      Returns:
      a future with the auth mounts
    • enableAuthMethod

      public void enableAuthMethod(String path, String type)
      Enables an auth method at path.
      Parameters:
      path - mount path
      type - method type, e.g. approle, userpass
    • enableAuthMethod

      public void enableAuthMethod(String path, String type, EnableOptions options)
      Enables an auth method with options.
      Parameters:
      path - mount path
      type - method type
      options - options
    • enableAuthMethodAsync

      public CompletableFuture<Void> enableAuthMethodAsync(String path, String type, EnableOptions options)
      Parameters:
      path - mount path
      type - method type
      options - options
      Returns:
      a future completed when done
    • disableAuthMethod

      public void disableAuthMethod(String path)
      Disables an auth method; its tokens are revoked.
      Parameters:
      path - mount path
    • disableAuthMethodAsync

      public CompletableFuture<Void> disableAuthMethodAsync(String path)
      Parameters:
      path - mount path
      Returns:
      a future completed when done
    • createAppRole

      public void createAppRole(String name, AppRoleOptions options)
      Creates or updates an AppRole role.
      Parameters:
      name - role name
      options - role settings and mount
    • createAppRoleAsync

      public CompletableFuture<Void> createAppRoleAsync(String name, AppRoleOptions o)
      Parameters:
      name - role name
      o - options
      Returns:
      a future completed when done
    • listAppRoles

      public List<String> listAppRoles()
      AppRole role names on mount approle; empty when there is none.
      Returns:
      the names
    • listAppRoles

      public List<String> listAppRoles(String mount)
      AppRole role names on a mount.
      Parameters:
      mount - AppRole mount
      Returns:
      the names
    • listAppRolesAsync

      public CompletableFuture<List<String>> listAppRolesAsync(String mount)
      Asynchronous listAppRoles(String).
      Parameters:
      mount - AppRole mount
      Returns:
      a future with the names
    • deleteAppRole

      public void deleteAppRole(String name)
      Deletes an AppRole role on mount approle.
      Parameters:
      name - role name
    • deleteAppRole

      public void deleteAppRole(String name, String mount)
      Deletes an AppRole role.
      Parameters:
      name - role name
      mount - AppRole mount
    • deleteAppRoleAsync

      public CompletableFuture<Void> deleteAppRoleAsync(String name, String mount)
      Parameters:
      name - role name
      mount - AppRole mount
      Returns:
      a future completed when done
    • readRoleId

      public String readRoleId(String name)
      The role id of an AppRole role on mount approle; NotFoundException for unknown roles.
      Parameters:
      name - role name
      Returns:
      the role id
    • readRoleId

      public String readRoleId(String name, String mount)
      The role id of an AppRole role.
      Parameters:
      name - role name
      mount - AppRole mount
      Returns:
      the role id
    • readRoleIdAsync

      public CompletableFuture<String> readRoleIdAsync(String name, String mount)
      Parameters:
      name - role name
      mount - AppRole mount
      Returns:
      a future with the role id
    • generateSecretId

      public SecretIdInfo generateSecretId(String name)
      Generates a new secret id for an AppRole role on mount approle.
      Parameters:
      name - role name
      Returns:
      the secret id
    • generateSecretId

      public SecretIdInfo generateSecretId(String name, SecretIdOptions options)
      Generates a new secret id with options.
      Parameters:
      name - role name
      options - metadata, CIDRs, TTL, uses, mount
      Returns:
      the secret id
    • generateSecretIdAsync

      public CompletableFuture<SecretIdInfo> generateSecretIdAsync(String name, SecretIdOptions o)
      Parameters:
      name - role name
      o - options
      Returns:
      a future with the secret id