policies

package
v0.0.0-...-2f2c61e Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package policies provides information and interaction with the policy API resource in the Rackspace Auto Scale service.

Auto Scale uses policies to define when and how scaling activity will take place. Scaling policies specify how to modify the scaling group and its behavior. You can specify multiple policies to manage a scaling group.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoName            = errors.New("Policy name cannot be empty.")
	ErrNoSchedule        = errors.New("Schedule cannot be nil for schedule policies.")
	ErrCooldownRange     = errors.New("Cooldown is out of range (0, 86400).")
	ErrUnknownType       = errors.New("Unknown policy type.")
	ErrUnknownAdjustment = errors.New("Unknown adjustment type.")
	ErrEmptyCron         = errors.New("Cron argument cannot be empty.")
)

Validation errors returned by create or update operations.

Functions

func List

func List(client *gophercloud.ServiceClient, groupID string) pagination.Pager

List returns all scaling policies for a group.

Types

type AdjustmentType

type AdjustmentType string

AdjustmentType represents the way in which a policy will change a group.

const (
	Change          AdjustmentType = "change"
	ChangePercent   AdjustmentType = "changePercent"
	DesiredCapacity AdjustmentType = "desiredCapacity"
)

Valid types of adjustments for a policy.

type At

type At time.Time

At satisfies the ScheduleArgs interface and can be used to configure a policy to execute a particular time.

func (At) ToPolicyArgs

func (at At) ToPolicyArgs() (map[string]string, error)

ToPolicyArgs returns a key and value for use in constructing arguments to schedule policies.

type CreateOpt

type CreateOpt struct {
	// Name [required] is a name for the policy.
	Name string

	// Type [required] of policy, i.e. either "webhook" or "schedule".
	Type Type

	// Cooldown [required] period in seconds.
	Cooldown int

	// AdjustmentType [requried] is the method used to change the capacity of
	// the group, i.e. one of: Change, ChangePercent, or DesiredCapacity.
	AdjustmentType AdjustmentType

	// AdjustmentValue [required] is the numeric value of the adjustment.  For
	// adjustments of type Change or DesiredCapacity, this will be converted to
	// an integer.
	AdjustmentValue float64

	// Value determining Schedule policy behavior, or nil for Webhook policies.
	// This should be an appropriately configured Cron or an At value.
	Schedule ScheduleArgs
}

CreateOpt represents the options to create a policy.

type CreateOpts

type CreateOpts []CreateOpt

CreateOpts is a slice of CreateOpt structs that allow the user to create multiple policies in a single operation.

func (CreateOpts) ToPolicyCreateMap

func (opts CreateOpts) ToPolicyCreateMap() ([]map[string]interface{}, error)

ToPolicyCreateMap converts a slice of CreateOpt structs into a map for use in the request body of a Create operation.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToPolicyCreateMap() ([]map[string]interface{}, error)
}

CreateOptsBuilder is the interface responsible for generating the map that will be marshalled to JSON for a Create operation.

type CreateResult

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

CreateResult represents the result of a create operation.

func Create

func Create(client *gophercloud.ServiceClient, groupID string, opts CreateOptsBuilder) CreateResult

Create requests a new policy be created and associated with the given group.

func (CreateResult) Extract

func (res CreateResult) Extract() ([]Policy, error)

Extract extracts a slice of Policies from a CreateResult. Multiple policies can be created in a single operation, so the result of a create is always a list of policies.

type Cron

type Cron string

Cron satisfies the ScheduleArgs interface and can be used to configure a policy that executes at regular intervals.

func (Cron) ToPolicyArgs

func (cron Cron) ToPolicyArgs() (map[string]string, error)

ToPolicyArgs returns a key and value for use in constructing arguments to schedule policies.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation.

func Delete

func Delete(client *gophercloud.ServiceClient, groupID, policyID string) DeleteResult

Delete requests the given policy be permanently deleted.

type ExecuteResult

type ExecuteResult struct {
	gophercloud.ErrResult
}

ExecuteResult represents the result of an execute operation.

func Execute

func Execute(client *gophercloud.ServiceClient, groupID, policyID string) ExecuteResult

Execute requests the given policy be executed immediately.

type GetResult

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

GetResult temporarily contains the response from a Get call.

func Get

func Get(client *gophercloud.ServiceClient, groupID, policyID string) GetResult

Get requests the details of a single policy with the given ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Policy, error)

Extract interprets any policyResult as a Policy, if possible.

type Policy

type Policy struct {
	// UUID for the policy.
	ID string

	// Name of the policy.
	Name string

	// Type of scaling policy.
	Type Type

	// Cooldown period, in seconds.
	Cooldown int

	// The type of adjustment in capacity to be made.
	AdjustmentType AdjustmentType

	// The numeric value of the adjustment in capacity.
	AdjustmentValue float64

	// Arguments determining Schedule policy behavior, or nil for Webhook
	// policies.
	Schedule ScheduleArgs
}

Policy represents a scaling policy.

func ExtractPolicies

func ExtractPolicies(page pagination.Page) ([]Policy, error)

ExtractPolicies interprets the results of a single page from a List() call, producing a slice of Policies.

type PolicyPage

type PolicyPage struct {
	pagination.SinglePageBase
}

PolicyPage is the page returned by a pager when traversing over a collection of scaling policies.

func (PolicyPage) IsEmpty

func (page PolicyPage) IsEmpty() (bool, error)

IsEmpty returns true if a page contains no Policy results.

type ScheduleArgs

type ScheduleArgs interface {
	ToPolicyArgs() (map[string]string, error)
}

ScheduleArgs is implemented by types that can be converted into arguments for policies with type Schedule.

type Type

type Type string

Type represents a type of scaling policy.

const (
	// Schedule policies run at given times.
	Schedule Type = "schedule"

	// Webhook policies are triggered by HTTP requests.
	Webhook Type = "webhook"
)

type UpdateOpts

type UpdateOpts struct {
	// Name [required] is a name for the policy.
	Name string

	// Type [required] of policy, i.e. either "webhook" or "schedule".
	Type Type

	// Cooldown [required] period in seconds.  If you don't specify a cooldown,
	// it will default to zero, and the policy will be configured as such.
	Cooldown int

	// AdjustmentType [requried] is the method used to change the capacity of
	// the group, i.e. one of: Change, ChangePercent, or DesiredCapacity.
	AdjustmentType AdjustmentType

	// AdjustmentValue [required] is the numeric value of the adjustment.  For
	// adjustments of type Change or DesiredCapacity, this will be converted to
	// an integer.
	AdjustmentValue float64

	// Value determining Schedule policy behavior, or nil for Webhook policies.
	// This should be an appropriately configured Cron or an At value.
	Schedule ScheduleArgs
}

UpdateOpts represents the options for updating an existing policy.

Update operations completely replace the configuration being updated. Empty values in the update are accepted and overwrite previously specified parameters.

func (UpdateOpts) ToPolicyUpdateMap

func (opts UpdateOpts) ToPolicyUpdateMap() (map[string]interface{}, error)

ToPolicyUpdateMap converts an UpdateOpts struct into a map for use as the request body in an Update request.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToPolicyUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder is the interface responsible for generating the map structure for producing JSON for an Update operation.

type UpdateResult

type UpdateResult struct {
	gophercloud.ErrResult
}

UpdateResult represents the result of an update operation.

func Update

func Update(client *gophercloud.ServiceClient, groupID, policyID string, opts UpdateOptsBuilder) UpdateResult

Update requests the configuration of the given policy be updated.

Jump to

Keyboard shortcuts

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