Package dev.cerbos.sdk
Class CerbosBlockingAdminClient
- java.lang.Object
-
- dev.cerbos.sdk.CerbosBlockingAdminClient
-
public class CerbosBlockingAdminClient extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddOrUpdatePolicyRequestBuilderaddOrUpdatePolicy()Add or update policies to the Cerbos policy repository.AddOrUpdateSchemaRequestBuilderaddOrUpdateSchema()Add or update schemaslongdeleteSchema(java.lang.String... ids)Delete schemas by IDlongdisablePolicy(java.lang.String... ids)Disable a policy by IDlongenablePolicy(java.lang.String... ids)Enable a policy by IDjava.util.List<PolicyOuterClass.Policy>getPolicy(java.lang.String... ids)Get the policy definitions for the given IDsjava.util.List<SchemaOuterClass.Schema>getSchema(java.lang.String... ids)Get a schema definition by IDjava.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.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 policiesjava.util.List<java.lang.String>listSchemas()List the schemas in the policy repositoryvoidstoreReload(boolean wait)Force Cerbos to refresh the policy storeCerbosBlockingAdminClientwithHeaders(io.grpc.Metadata md)Add header metadata to Cerbos requestsCerbosBlockingAdminClientwithHeaders(java.util.Map<java.lang.String,java.lang.String> headers)Attach the given headers to the Cerbos request.
-
-
-
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.
-
addOrUpdatePolicy
public AddOrUpdatePolicyRequestBuilder addOrUpdatePolicy()
Add or update policies to the Cerbos policy repository.- Returns:
AddOrUpdatePolicyRequestBuilderbuilder- Throws:
CerbosException- if an RPC error occurrs
-
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 byversionRegex- Optional regex to filter the policy version byscopeRegex- 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 byversionRegex- Optional regex to filter the policy version byscopeRegex- 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
-
addOrUpdateSchema
public AddOrUpdateSchemaRequestBuilder addOrUpdateSchema()
Add or update schemas- Returns:
AddOrUpdateSchemaRequestBuilderbuilder
-
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
-
-