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 ¶
- Variables
- func List(client *gophercloud.ServiceClient, groupID string) pagination.Pager
- type AdjustmentType
- type At
- type CreateOpt
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type Cron
- type DeleteResult
- type ExecuteResult
- type GetResult
- type Policy
- type PolicyPage
- type ScheduleArgs
- type Type
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
At satisfies the ScheduleArgs interface and can be used to configure a policy to execute a particular time.
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 ¶
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.
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.
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 ¶
ScheduleArgs is implemented by types that can be converted into arguments for policies with type Schedule.
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 ¶
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.