policy

package
v0.1.18894 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 10 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 resonse 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) 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) 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 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