Documentation
¶
Index ¶
Constants ¶
const ServiceName = "policy"
ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.
Variables ¶
var MethodNames = [3]string{"Evaluate", "Lock", "Unlock"}
MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.
Functions ¶
func NewEvaluateEndpoint ¶
NewEvaluateEndpoint returns an endpoint function that calls the method "Evaluate" of service "policy".
func NewLockEndpoint ¶
NewLockEndpoint returns an endpoint function that calls the method "Lock" of service "policy".
func NewUnlockEndpoint ¶
NewUnlockEndpoint returns an endpoint function that calls the method "Unlock" of service "policy".
Types ¶
type Client ¶
type Client struct { EvaluateEndpoint goa.Endpoint LockEndpoint goa.Endpoint UnlockEndpoint goa.Endpoint }
Client is the "policy" service client.
func (*Client) Evaluate ¶
func (c *Client) Evaluate(ctx context.Context, p *EvaluateRequest) (res *EvaluateResult, err error)
Evaluate calls the "Evaluate" endpoint of the "policy" service.
type Endpoints ¶
Endpoints wraps the "policy" service endpoints.
func NewEndpoints ¶
NewEndpoints wraps the methods of the "policy" service with endpoints.
type EvaluateRequest ¶
type EvaluateRequest struct { // Policy group. Group string // Policy name. PolicyName string // Policy version. Version string // Input data passed to the policy execution runtime. Input interface{} // Identifier created by external system and passed as parameter to overwrite // the randomly generated evaluationID. EvaluationID *string // Cache TTL for storing policy result in cache TTL *int }
EvaluateRequest is the payload type of the policy service Evaluate method.
type EvaluateResult ¶
type EvaluateResult struct { // Arbitrary JSON response. Result interface{} // ETag contains unique identifier of the policy evaluation and can be used to // later retrieve the results from Cache. ETag string }
EvaluateResult is the result type of the policy service Evaluate method.
type LockRequest ¶
type LockRequest struct { // Policy group. Group string // Policy name. PolicyName string // Policy version. Version string }
LockRequest is the payload type of the policy service Lock method.
type Service ¶
type Service interface { // Evaluate executes a policy with the given 'data' as input. Evaluate(context.Context, *EvaluateRequest) (res *EvaluateResult, err error) // Lock a policy so that it cannot be evaluated. Lock(context.Context, *LockRequest) (err error) // Unlock a policy so it can be evaluated again. Unlock(context.Context, *UnlockRequest) (err error) }
Policy Service provides evaluation of policies through Open Policy Agent.
type UnlockRequest ¶
type UnlockRequest struct { // Policy group. Group string // Policy name. PolicyName string // Policy version. Version string }
UnlockRequest is the payload type of the policy service Unlock method.