policy

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func NewEvaluateEndpoint(s Service) goa.Endpoint

NewEvaluateEndpoint returns an endpoint function that calls the method "Evaluate" of service "policy".

func NewLockEndpoint

func NewLockEndpoint(s Service) goa.Endpoint

NewLockEndpoint returns an endpoint function that calls the method "Lock" of service "policy".

func NewUnlockEndpoint

func NewUnlockEndpoint(s Service) goa.Endpoint

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 NewClient

func NewClient(evaluate, lock, unlock goa.Endpoint) *Client

NewClient initializes a "policy" service client given the endpoints.

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.

func (*Client) Lock

func (c *Client) Lock(ctx context.Context, p *LockRequest) (err error)

Lock calls the "Lock" endpoint of the "policy" service.

func (*Client) Unlock

func (c *Client) Unlock(ctx context.Context, p *UnlockRequest) (err error)

Unlock calls the "Unlock" endpoint of the "policy" service.

type Endpoints

type Endpoints struct {
	Evaluate goa.Endpoint
	Lock     goa.Endpoint
	Unlock   goa.Endpoint
}

Endpoints wraps the "policy" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "policy" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "policy" service 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL