Enterprise OPA documentation
https://docs.styra.com/enterprise-opa
executeDefaultPolicyWithInput
Execute the default decision given an input
package hello .world ;
import com .styra .opa .openapi .OpaApiClient ;
import com .styra .opa .openapi .models .errors .ClientError ;
import com .styra .opa .openapi .models .errors .ServerError ;
import com .styra .opa .openapi .models .operations .ExecuteDefaultPolicyWithInputResponse ;
import com .styra .opa .openapi .models .shared .GzipAcceptEncoding ;
import com .styra .opa .openapi .models .shared .Input ;
import com .styra .opa .openapi .models .shared .Security ;
import java .lang .Exception ;
public class Application {
public static void main (String [] args ) throws ClientError , ServerError , Exception {
OpaApiClient sdk = OpaApiClient .builder ()
.security (Security .builder ()
.bearerAuth ("<YOUR_BEARER_TOKEN_HERE>" )
.build ())
.build ();
ExecuteDefaultPolicyWithInputResponse res = sdk .executeDefaultPolicyWithInput ()
.pretty (false )
.acceptEncoding (GzipAcceptEncoding .GZIP )
.input (Input .of (4963.69d ))
.call ();
if (res .result ().isPresent ()) {
// handle response
}
}
}
Parameter
Type
Required
Description
pretty
Optional
➖
If parameter is true
, response will formatted for humans.
acceptEncoding
Optional
➖
Indicates the server should respond with a gzip encoded body. The server will send the compressed response only if its length is above server.encoding.gzip.min_length
value. See the configuration section
input
Input
✔️
The input document
ExecuteDefaultPolicyWithInputResponse
Error Type
Status Code
Content Type
models/errors/ClientError
400, 404
application/json
models/errors/ServerError
500
application/json
models/errors/SDKError
4XX, 5XX
*/*
Execute a policy
package hello .world ;
import com .styra .opa .openapi .OpaApiClient ;
import com .styra .opa .openapi .models .errors .ClientError1 ;
import com .styra .opa .openapi .models .errors .ServerError ;
import com .styra .opa .openapi .models .operations .ExecutePolicyRequest ;
import com .styra .opa .openapi .models .operations .ExecutePolicyResponse ;
import com .styra .opa .openapi .models .shared .Security ;
import java .lang .Exception ;
public class Application {
public static void main (String [] args ) throws ClientError1 , ServerError , Exception {
OpaApiClient sdk = OpaApiClient .builder ()
.security (Security .builder ()
.bearerAuth ("<YOUR_BEARER_TOKEN_HERE>" )
.build ())
.build ();
ExecutePolicyRequest req = ExecutePolicyRequest .builder ()
.path ("app/rbac" )
.build ();
ExecutePolicyResponse res = sdk .executePolicy ()
.request (req )
.call ();
if (res .successfulPolicyResponse ().isPresent ()) {
// handle response
}
}
}
Parameter
Type
Required
Description
request
ExecutePolicyRequest
✔️
The request object to use for the request.
ExecutePolicyResponse
Error Type
Status Code
Content Type
models/errors/ClientError1
400
application/json
models/errors/ServerError
500
application/json
models/errors/SDKError
4XX, 5XX
*/*
Execute a policy given an input
package hello .world ;
import com .styra .opa .openapi .OpaApiClient ;
import com .styra .opa .openapi .models .errors .ClientError1 ;
import com .styra .opa .openapi .models .errors .ServerError ;
import com .styra .opa .openapi .models .operations .ExecutePolicyWithInputRequest ;
import com .styra .opa .openapi .models .operations .ExecutePolicyWithInputRequestBody ;
import com .styra .opa .openapi .models .operations .ExecutePolicyWithInputResponse ;
import com .styra .opa .openapi .models .shared .Input ;
import com .styra .opa .openapi .models .shared .Security ;
import java .lang .Exception ;
public class Application {
public static void main (String [] args ) throws ClientError1 , ServerError , Exception {
OpaApiClient sdk = OpaApiClient .builder ()
.security (Security .builder ()
.bearerAuth ("<YOUR_BEARER_TOKEN_HERE>" )
.build ())
.build ();
ExecutePolicyWithInputRequest req = ExecutePolicyWithInputRequest .builder ()
.path ("app/rbac" )
.requestBody (ExecutePolicyWithInputRequestBody .builder ()
.input (Input .of (false ))
.build ())
.build ();
ExecutePolicyWithInputResponse res = sdk .executePolicyWithInput ()
.request (req )
.call ();
if (res .successfulPolicyResponse ().isPresent ()) {
// handle response
}
}
}
ExecutePolicyWithInputResponse
Error Type
Status Code
Content Type
models/errors/ClientError1
400
application/json
models/errors/ServerError
500
application/json
models/errors/SDKError
4XX, 5XX
*/*
executeBatchPolicyWithInput
Execute a policy given a batch of inputs
package hello .world ;
import com .styra .opa .openapi .OpaApiClient ;
import com .styra .opa .openapi .models .errors .BatchServerError ;
import com .styra .opa .openapi .models .errors .ClientError1 ;
import com .styra .opa .openapi .models .operations .ExecuteBatchPolicyWithInputRequest ;
import com .styra .opa .openapi .models .operations .ExecuteBatchPolicyWithInputRequestBody ;
import com .styra .opa .openapi .models .operations .ExecuteBatchPolicyWithInputResponse ;
import com .styra .opa .openapi .models .shared .Input ;
import com .styra .opa .openapi .models .shared .Security ;
import java .lang .Exception ;
import java .util .Map ;
public class Application {
public static void main (String [] args ) throws ClientError1 , BatchServerError , Exception {
OpaApiClient sdk = OpaApiClient .builder ()
.security (Security .builder ()
.bearerAuth ("<YOUR_BEARER_TOKEN_HERE>" )
.build ())
.build ();
ExecuteBatchPolicyWithInputRequest req = ExecuteBatchPolicyWithInputRequest .builder ()
.path ("app/rbac" )
.requestBody (ExecuteBatchPolicyWithInputRequestBody .builder ()
.inputs (Map .ofEntries (
Map .entry ("key" , Input .of ("<value>" ))))
.build ())
.build ();
ExecuteBatchPolicyWithInputResponse res = sdk .executeBatchPolicyWithInput ()
.request (req )
.call ();
if (res .batchSuccessfulPolicyEvaluation ().isPresent ()) {
// handle response
}
}
}
ExecuteBatchPolicyWithInputResponse
Error Type
Status Code
Content Type
models/errors/ClientError1
400
application/json
models/errors/BatchServerError
500
application/json
models/errors/SDKError
4XX, 5XX
*/*
The health API endpoint executes a simple built-in policy query to verify that the server is operational. Optionally it can account for bundle activation as well (useful for “ready” checks at startup).
package hello .world ;
import com .styra .opa .openapi .OpaApiClient ;
import com .styra .opa .openapi .models .errors .UnhealthyServer ;
import com .styra .opa .openapi .models .operations .HealthResponse ;
import com .styra .opa .openapi .models .shared .Security ;
import java .lang .Exception ;
import java .util .List ;
public class Application {
public static void main (String [] args ) throws UnhealthyServer , Exception {
OpaApiClient sdk = OpaApiClient .builder ()
.security (Security .builder ()
.bearerAuth ("<YOUR_BEARER_TOKEN_HERE>" )
.build ())
.build ();
HealthResponse res = sdk .health ()
.bundles (false )
.plugins (false )
.excludePlugin (List .of (
"<value>" ))
.call ();
if (res .healthyServer ().isPresent ()) {
// handle response
}
}
}
Parameter
Type
Required
Description
bundles
Optional
➖
Boolean parameter to account for bundle activation status in response. This includes any discovery bundles or bundles defined in the loaded discovery configuration.
plugins
Optional
➖
Boolean parameter to account for plugin status in response.
excludePlugin
List<String >
➖
String parameter to exclude a plugin from status checks. Can be added multiple times. Does nothing if plugins is not true. This parameter is useful for special use cases where a plugin depends on the server being fully initialized before it can fully initialize itself.
HealthResponse
Error Type
Status Code
Content Type
models/errors/UnhealthyServer
500
application/json
models/errors/SDKError
4XX, 5XX
*/*