Class CerbosBlockingAdminClient


  • public class CerbosBlockingAdminClient
    extends java.lang.Object
    • Method Detail

      • withHeaders

        public CerbosBlockingAdminClient withHeaders​(io.grpc.Metadata md)
        Add header metadata to Cerbos requests
        Parameters:
        md - Metadata
        Returns:
        CerbosBlockingAdminClient configured to attach headers to each request.
      • withHeaders

        public CerbosBlockingAdminClient withHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
        Attach the given headers to the Cerbos request.
        Parameters:
        headers - Map of key-value pairs
        Returns:
        new CerbosBlockingAdminClient configured to attach the given headers to the requests.
      • listActivePolicies

        public java.util.List<java.lang.String> listActivePolicies​(java.util.Optional<java.lang.String> nameRegex,
                                                                   java.util.Optional<java.lang.String> versionRegex,
                                                                   java.util.Optional<java.lang.String> scopeRegex)
        List the enabled policies in the policy repository.
        Parameters:
        nameRegex - Optional regex to filter to policy name by
        versionRegex - Optional regex to filter the policy version by
        scopeRegex - Optional regex to filter the policy scope by
        Returns:
        List of policy IDs
        Throws:
        CerbosException - if an RPC error occurrs
      • listAllPolicies

        public java.util.List<java.lang.String> listAllPolicies​(java.util.Optional<java.lang.String> nameRegex,
                                                                java.util.Optional<java.lang.String> versionRegex,
                                                                java.util.Optional<java.lang.String> scopeRegex)
        List all policies including disabled policies
        Parameters:
        nameRegex - Optional regex to filter the policy name by
        versionRegex - Optional regex to filter the policy version by
        scopeRegex - Optional regex to filter the policy scope by
        Returns:
        List of policy IDs
        Throws:
        CerbosException - if an RPC error occurrs
      • getPolicy

        public java.util.List<PolicyOuterClass.Policy> getPolicy​(java.lang.String... ids)
        Get the policy definitions for the given IDs
        Parameters:
        ids - IDs to retrieve
        Returns:
        List of policy definitions
        Throws:
        CerbosException - if an RPC error occurrs
      • enablePolicy

        public long enablePolicy​(java.lang.String... ids)
        Enable a policy by ID
        Parameters:
        ids - IDs of policies to enable
        Returns:
        Number of enabled policies
        Throws:
        CerbosException - if an RPC error occurrs
      • disablePolicy

        public long disablePolicy​(java.lang.String... ids)
        Disable a policy by ID
        Parameters:
        ids - IDs of policies to disable
        Returns:
        Number of disabled policies
        Throws:
        CerbosException - if an RPC error occurrs
      • listSchemas

        public java.util.List<java.lang.String> listSchemas()
        List the schemas in the policy repository
        Returns:
        List of schema IDs
        Throws:
        CerbosException - if an RPC error occurrs
      • getSchema

        public java.util.List<SchemaOuterClass.Schema> getSchema​(java.lang.String... ids)
        Get a schema definition by ID
        Parameters:
        ids - IDs of schemas to retrieve
        Returns:
        List of schemas
        Throws:
        CerbosException - if an RPC error occurrs
      • deleteSchema

        public long deleteSchema​(java.lang.String... ids)
        Delete schemas by ID
        Parameters:
        ids - IDs of schemas to delete
        Returns:
        Number of schemas deleted
        Throws:
        CerbosException - if an RPC error occurrs
      • storeReload

        public void storeReload​(boolean wait)
        Force Cerbos to refresh the policy store
        Parameters:
        wait - Block while the refresh is happening
        Throws:
        CerbosException - if an RPC error occurrs