policy

package
v0.1.19293 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the CircleCI policy-service to ask questions about policies. It satisfies policy.ClientInterface.

func NewClient

func NewClient(baseURL string, config *settings.Config) *Client

NewClient returns a new policy client that will use the provided settings.Config to automatically inject appropriate Circle-Token authentication and other relevant CLI headers.

func (Client) CreatePolicy

func (c Client) CreatePolicy(ownerID string, policy CreationRequest) (interface{}, error)

CreatePolicy call the Create Policy API in the Policy-Service. It creates a policy for the specified owner and returns the created policy response as an interface{}.

func (Client) DeletePolicy

func (c Client) DeletePolicy(ownerID string, policyID string) error

DeletePolicy calls the DELETE Policy API in the policy-service. It attempts to delete the policy matching the given policy-id and belonging to the given ownerID. It returns an error if the call fails or the policy could not be deleted.

func (Client) GetDecisionLogs added in v0.1.18980

func (c Client) GetDecisionLogs(ownerID string, request DecisionQueryRequest) ([]interface{}, error)

GetDecisionLogs calls the GET decision query API of policy-service. The endpoint accepts multiple filter values as path query parameters (start-time, end-time, branch-name, project-id and offset).

func (Client) GetPolicy

func (c Client) GetPolicy(ownerID string, policyID string) (interface{}, error)

GetPolicy calls the GET policy API in the policy-service.It fetches the policy from policy-service matching the given owner-id and policy-id. It returns an error if the call fails or the policy could not be found.

func (Client) ListPolicies

func (c Client) ListPolicies(ownerID string, activeFilter *bool) (interface{}, error)

ListPolicies calls the view policy-service list policy API. If the active filter is nil, all policies are returned. If activeFilter is not nil it will only return active or inactive policies based on the value of *activeFilter.

func (Client) MakeDecision added in v0.1.19183

func (c Client) MakeDecision(ownerID string, req DecisionRequest) (interface{}, error)

MakeDecision sends a requests to Policy-Service public decision endpoint and returns the decision response

func (Client) UpdatePolicy

func (c Client) UpdatePolicy(ownerID string, policyID string, policy UpdateRequest) (interface{}, error)

UpdatePolicy calls the UPDATE policy API in the policy-service. It updates a policy in the policy-service matching the given owner-id and policy-id.

type CreationRequest

type CreationRequest struct {
	Name    string `json:"name"`
	Context string `json:"context"`
	Content string `json:"content"`
}

CreationRequest represents the json payload to create a Policy in the Policy-Service

type DecisionQueryRequest added in v0.1.18980

type DecisionQueryRequest struct {
	After     *time.Time
	Before    *time.Time
	Branch    string
	ProjectID string
	Offset    int
}

type DecisionRequest added in v0.1.19183

type DecisionRequest struct {
	Input   string `json:"input"`
	Context string `json:"context"`
}

DecisionRequest represents a request to Policy-Service to evaluate a given input against an organization's policies. The context determines which policies to apply.

type UpdateRequest

type UpdateRequest struct {
	Name    *string `json:"name,omitempty"`
	Context *string `json:"context,omitempty"`
	Content *string `json:"content,omitempty"`
	Active  *bool   `json:"active,omitempty"`
}

Jump to

Keyboard shortcuts

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