io.enterpriseai.resources.PoliciesClient
Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/resources/PoliciesClient.java. Back to the Java SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class PoliciesClient
Policies, evaluation (Policy Contract) and recorded decisions.
Constructor PoliciesClient
PoliciesClient(Transport transport)
Creates the client on the shared transport; EnterpriseAIClient builds it and exposes it through the accessor of the same name.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
transport | Transport | yes | Transport shared by the sub-clients of one client. |
PoliciesClient.create
JsonNode create(Object body)
Create a policy. Creates a policy of the tenant and appends its first revision. An opa policy needs rego (422 validation_error) and, unless OPA loads signed bundles, is pushed to OPA at once (503 policy_engine_unavailable when OPA cannot be reached). A name already used answers 409 conflict. Needs tenant_admin or security_officer. Writes the audit event policy.create.
Route: /v1/policies (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Name, engine, rules or Rego, priority and status of the policy. |
Returns: JsonNode. Decoded JSON answer of the operation "Create a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.create
JsonNode create(Object body, RequestOptions options)
Create a policy. Creates a policy of the tenant and appends its first revision. An opa policy needs rego (422 validation_error) and, unless OPA loads signed bundles, is pushed to OPA at once (503 policy_engine_unavailable when OPA cannot be reached). A name already used answers 409 conflict. Needs tenant_admin or security_officer. Writes the audit event policy.create.
Route: /v1/policies (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Name, engine, rules or Rego, priority and status of the policy. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Create a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.createBundle
JsonNode createBundle(Object body)
Publish an OPA bundle. Packs the opa policies of the tenant into a signed OPA bundle and stores it as the new current revision. Active policies are decided by OPA; draft ones ship as libraries; disabled ones are left out. No opa policy answers 409 policy_bundle_empty; no signing key in production 503 policy_bundle_signing_unavailable. Needs tenant_admin or security_officer. Writes the audit event policy.bundle_publish. Answers 201 with the bundle record.
Route: /v1/policies/bundles (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Optional revision name and data.json content. An empty body generates the revision. |
Returns: JsonNode. Decoded JSON answer of the operation "Publish an OPA bundle".
Raises: the typed errors of the transport (Errors).
PoliciesClient.createBundle
JsonNode createBundle(Object body, RequestOptions options)
Publish an OPA bundle. Packs the opa policies of the tenant into a signed OPA bundle and stores it as the new current revision. Active policies are decided by OPA; draft ones ship as libraries; disabled ones are left out. No opa policy answers 409 policy_bundle_empty; no signing key in production 503 policy_bundle_signing_unavailable. Needs tenant_admin or security_officer. Writes the audit event policy.bundle_publish. Answers 201 with the bundle record.
Route: /v1/policies/bundles (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Optional revision name and data.json content. An empty body generates the revision. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Publish an OPA bundle".
Raises: the typed errors of the transport (Errors).
PoliciesClient.decisions
Page<JsonNode> decisions()
List the policy decisions. Lists the decisions of the tenant, newest first, paginated: subject, action, resource, context, allow, policy and version, reasons, obligations, engine and date. Needs tenant_admin, security_officer or auditor.
Route: /v1/policies/decisions (GET).
This element takes no parameter.
Returns: Page<JsonNode>. A Page: One page of a cursor paginated collection ({"items": [...], "next_cursor": "..."|null}).
Raises: the typed errors of the transport (Errors).
PoliciesClient.decisions
Page<JsonNode> decisions(Map<String, ?> query)
List the policy decisions. Lists the decisions of the tenant, newest first, paginated: subject, action, resource, context, allow, policy and version, reasons, obligations, engine and date. Needs tenant_admin, security_officer or auditor.
Route: /v1/policies/decisions (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
query | Map<String, ?> | yes | Query string parameters of the route. |
Returns: Page<JsonNode>. A Page: One page of a cursor paginated collection ({"items": [...], "next_cursor": "..."|null}).
Raises: the typed errors of the transport (Errors).
PoliciesClient.delete
void delete(String id)
Delete a policy. Deletes the policy and appends a delete revision. An OPA policy pushed directly to OPA is removed from it too (503 policy_engine_unavailable when OPA cannot be reached). Needs tenant_admin or security_officer. Writes the audit event policy.delete. Answers 204, or 404 not_found.
Route: /v1/policies/{policy_id} (DELETE).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the policy. |
Returns: void.
Raises: the typed errors of the transport (Errors).
PoliciesClient.downloadBundle
byte[] downloadBundle(String revision)
Download an OPA bundle. Returns the bundle OPA polls, as application/gzip: Rego modules, optional data.json, .manifest and .signatures.json (RS256 JWT over the SHA-256 of every file). The ETag header is its SHA-256 and X-Bundle-Revision its revision. Needs tenant_admin, security_officer or auditor. Answers 404 not_found for an unknown revision.
Route: /v1/policies/bundles/{revision}/bundle.tar.gz (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
revision | String | yes | Revision of the bundle, or current for the latest published one. |
Returns: byte[]. Decoded JSON answer of the operation "Download an OPA bundle".
Raises: the typed errors of the transport (Errors).
PoliciesClient.engines
JsonNode engines()
Get the policy engines status. Returns the policy services (builtin engine, OPA, OpenFGA) and the policy version or bundle revision each one really runs, read from the engine itself. Needs tenant_admin, security_officer or auditor.
Route: /v1/policies/engines (GET).
This element takes no parameter.
Returns: JsonNode. Decoded JSON answer of the operation "Get the policy engines status".
Raises: the typed errors of the transport (Errors).
PoliciesClient.evaluate
PolicyDecision evaluate(Object request)
Evaluate a policy request. Returns the decision for a Policy Contract request. The body is a Policy Contract ({schema_version, request}) or just its request object (subject, action, resource, context); it is validated against the policy-contract contract (422 validation_error).
Route: /v1/policies/evaluate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
request | Object | yes | Policy Contract document, or its request object alone. |
Returns: PolicyDecision. A PolicyDecision: Decision part of the Policy Contract v1, returned by POST /v1/policies/evaluate.
Raises: the typed errors of the transport (Errors).
PoliciesClient.evaluateRaw
JsonNode evaluateRaw(Object body)
Evaluate a policy request. Returns the decision for a Policy Contract request. The body is a Policy Contract ({schema_version, request}) or just its request object (subject, action, resource, context); it is validated against the policy-contract contract (422 validation_error).
Route: /v1/policies/evaluate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Policy Contract document, or its request object alone. |
Returns: JsonNode. Decoded JSON answer of the operation "Evaluate a policy request".
Raises: the typed errors of the transport (Errors).
PoliciesClient.evaluateRaw
JsonNode evaluateRaw(Object body, RequestOptions options)
Evaluate a policy request. Returns the decision for a Policy Contract request. The body is a Policy Contract ({schema_version, request}) or just its request object (subject, action, resource, context); it is validated against the policy-contract contract (422 validation_error).
Route: /v1/policies/evaluate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Policy Contract document, or its request object alone. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Evaluate a policy request".
Raises: the typed errors of the transport (Errors).
PoliciesClient.get
JsonNode get(String id)
Get a policy. Returns one policy. Open to any member of the tenant. Answers 404 not_found.
Route: /v1/policies/{policy_id} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the policy. |
Returns: JsonNode. Decoded JSON answer of the operation "Get a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.list
Page<JsonNode> list()
List the policies. Lists the policies of the tenant in evaluation order (priority, then name), with their rules or Rego. Open to any member of the tenant. next_cursor is always null.
Route: /v1/policies (GET).
This element takes no parameter.
Returns: Page<JsonNode>. A Page: One page of a cursor paginated collection ({"items": [...], "next_cursor": "..."|null}).
Raises: the typed errors of the transport (Errors).
PoliciesClient.listBundles
JsonNode listBundles()
List the OPA bundles. Lists the OPA bundles published for the tenant: revision, SHA-256, signature state, policies included and date. Needs tenant_admin, security_officer or auditor.
Route: /v1/policies/bundles (GET).
This element takes no parameter.
Returns: JsonNode. Decoded JSON answer of the operation "List the OPA bundles".
Raises: the typed errors of the transport (Errors).
PoliciesClient.replace
JsonNode replace(String id, Object body)
Replace a policy. Replaces every field of the policy and appends an update revision. Same validation as at creation (rego for opa, unique name). An opa policy is pushed to OPA unless OPA loads bundles. Needs tenant_admin or security_officer. Writes the audit event policy.update. Answers 404 not_found for an unknown policy.
Route: /v1/policies/{policy_id} (PUT).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the policy. | |
body | Object | yes | Full new content of the policy. |
Returns: JsonNode. Decoded JSON answer of the operation "Replace a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.replace
JsonNode replace(String id, Object body, RequestOptions options)
Replace a policy. Replaces every field of the policy and appends an update revision. Same validation as at creation (rego for opa, unique name). An opa policy is pushed to OPA unless OPA loads bundles. Needs tenant_admin or security_officer. Writes the audit event policy.update. Answers 404 not_found for an unknown policy.
Route: /v1/policies/{policy_id} (PUT).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier (UUID) of the policy. | |
body | Object | yes | Full new content of the policy. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Replace a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.revisionDiff
JsonNode revisionDiff(String policyId)
Compare two revisions of a policy. Returns the differences between two revisions of the policy. Defaults: the previous revision against the latest one. The policy is looked up first (404 not_found), then the revisions (404 not_found). Needs tenant_admin, security_officer, auditor or developer.
Route: /v1/policies/{policy_id}/revisions/diff (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
policyId | String | yes | Identifier (UUID) of the policy. |
Returns: JsonNode. Decoded JSON answer of the operation "Compare two revisions of a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.revisionDiff
JsonNode revisionDiff(String policyId, Map<String, ?> query)
Compare two revisions of a policy. Returns the differences between two revisions of the policy. Defaults: the previous revision against the latest one. The policy is looked up first (404 not_found), then the revisions (404 not_found). Needs tenant_admin, security_officer, auditor or developer.
Route: /v1/policies/{policy_id}/revisions/diff (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
policyId | String | yes | Identifier (UUID) of the policy. | |
query | Map<String, ?> | yes | Query string parameters of the route. |
Returns: JsonNode. Decoded JSON answer of the operation "Compare two revisions of a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.revisions
JsonNode revisions(String policyId)
List the revisions of a policy. Lists the immutable revisions of the policy (one per create, update and delete, written in the same transaction), with their number, operation, author, date and content. Needs tenant_admin, security_officer, auditor or developer. Answers 404 not_found.
Route: /v1/policies/{policy_id}/revisions (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
policyId | String | yes | Identifier (UUID) of the policy. |
Returns: JsonNode. Decoded JSON answer of the operation "List the revisions of a policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.simulate
JsonNode simulate(Object body)
Simulate a candidate policy. Compares, input by input, the decisions of the active policies with those of the same set where the candidate replaces policy_id (or is added). Nothing is changed.
Route: /v1/policies/simulate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Candidate policy, policy replaced, inputs and number of recorded decisions to replay. |
Returns: JsonNode. Decoded JSON answer of the operation "Simulate a candidate policy".
Raises: the typed errors of the transport (Errors).
PoliciesClient.simulate
JsonNode simulate(Object body, RequestOptions options)
Simulate a candidate policy. Compares, input by input, the decisions of the active policies with those of the same set where the candidate replaces policy_id (or is added). Nothing is changed.
Route: /v1/policies/simulate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Candidate policy, policy replaced, inputs and number of recorded decisions to replay. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Simulate a candidate policy".
Raises: the typed errors of the transport (Errors).