lifecyclepolicy

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScheduleTypeCron           ScheduleType = "cron"
	ScheduleTypeInterval       ScheduleType = "interval"
	PolicyStatusActive         PolicyStatus = "active"
	PolicyStatusPaused         PolicyStatus = "paused"
	PolicyActionVolumeSnapshot PolicyAction = "volume_snapshot"
)

Variables

This section is empty.

Functions

func Delete

func Delete(c *gcorecloud.ServiceClient, id int) (err error)

Delete deletes a lifecycle policy with specified unique id.

func ValidateAndBuildRequestBody

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

Types

type AddSchedulesOpts

type AddSchedulesOpts struct {
	Schedules []CreateScheduleOpts `json:"schedules" validate:"required,dive"`
}

AddSchedulesOpts represents options for AddSchedules.

type AddSchedulesResult

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

AddSchedulesResult represents the result of a AddSchedules operation. Call its Extract method to interpret it as a LifecyclePolicy.

func AddSchedules

func AddSchedules(c *gcorecloud.ServiceClient, id int, opts AddSchedulesOpts) (r AddSchedulesResult)

AddSchedules adds schedules to lifecycle policy with specified unique id. opts are used to construct request body.

func (AddSchedulesResult) Extract

func (r AddSchedulesResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type AddVolumesOpts

type AddVolumesOpts struct {
	VolumeIds []string `json:"volume_ids" validate:"required"`
}

AddVolumesOpts represents options for AddVolumes. Volumes already managed by policy are ignored.

type AddVolumesResult

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

AddVolumesResult represents the result of a AddVolumes operation. Call its Extract method to interpret it as a LifecyclePolicy.

func AddVolumes

func AddVolumes(c *gcorecloud.ServiceClient, id int, opts AddVolumesOpts) (r AddVolumesResult)

AddVolumes adds volumes to a lifecycle policy with specified unique id. opts are used to construct request body.

func (AddVolumesResult) Extract

func (r AddVolumesResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type CommonCreateScheduleOpts

type CommonCreateScheduleOpts struct {
	Type                 ScheduleType    `json:"type" validate:"required,enum"`
	ResourceNameTemplate string          `json:"resource_name_template,omitempty"`
	MaxQuantity          int             `json:"max_quantity" validate:"required,gt=0,lt=10001"`
	RetentionTime        *RetentionTimer `json:"retention_time,omitempty"`
}

type CommonSchedule

type CommonSchedule struct {
	Type                 ScheduleType    `json:"type"`
	ID                   string          `json:"id"`
	Owner                string          `json:"owner"`
	OwnerID              int             `json:"owner_id"`
	MaxQuantity          int             `json:"max_quantity"`
	UserID               int             `json:"user_id"`
	ResourceNameTemplate string          `json:"resource_name_template"`
	RetentionTime        *RetentionTimer `json:"retention_time"`
}

type CreateCronScheduleOpts

type CreateCronScheduleOpts struct {
	CommonCreateScheduleOpts
	Timezone  string `json:"timezone,omitempty"`
	Week      string `json:"week,omitempty"`
	DayOfWeek string `json:"day_of_week,omitempty"`
	Month     string `json:"month,omitempty"`
	Day       string `json:"day,omitempty"`
	Hour      string `json:"hour,omitempty"`
	Minute    string `json:"minute,omitempty"`
}

CreateCronScheduleOpts represents options used to create a single cron schedule.

func (*CreateCronScheduleOpts) SetCommonCreateScheduleOpts

func (opts *CreateCronScheduleOpts) SetCommonCreateScheduleOpts(common CommonCreateScheduleOpts)

type CreateIntervalScheduleOpts

type CreateIntervalScheduleOpts struct {
	CommonCreateScheduleOpts
	Weeks   int `json:"weeks,omitempty" validate:"required_without_all=Days Hours Minutes"`
	Days    int `json:"days,omitempty" validate:"required_without_all=Weeks Hours Minutes"`
	Hours   int `json:"hours,omitempty" validate:"required_without_all=Weeks Days Minutes"`
	Minutes int `json:"minutes,omitempty" validate:"required_without_all=Weeks Days Hours"`
}

CreateIntervalScheduleOpts represents options used to create a single interval schedule.

func (*CreateIntervalScheduleOpts) SetCommonCreateScheduleOpts

func (opts *CreateIntervalScheduleOpts) SetCommonCreateScheduleOpts(common CommonCreateScheduleOpts)

type CreateOpts

type CreateOpts struct {
	Name      string               `json:"name" validate:"required,name"`
	Status    PolicyStatus         `json:"status,omitempty" validate:"omitempty,enum"`
	Action    PolicyAction         `json:"action" validate:"required,enum"`
	Schedules []CreateScheduleOpts `json:"schedules,omitempty" validate:"dive"`
	VolumeIds []string             `json:"volume_ids,omitempty"`
}

CreateOpts represents options for Create.

type CreateResult

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

CreateResult represents the result of a Create operation. Call its Extract method to interpret it as a LifecyclePolicy.

func Create

func Create(c *gcorecloud.ServiceClient, opts CreateOpts) (r CreateResult)

Create creates a lifecycle policy. opts are used to construct request body.

func (CreateResult) Extract

func (r CreateResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type CreateScheduleOpts

type CreateScheduleOpts interface {
	SetCommonCreateScheduleOpts(opts CommonCreateScheduleOpts)
}

CreateScheduleOpts represents options used to create a single schedule.

type CronSchedule

type CronSchedule struct {
	CommonSchedule
	Timezone  string `json:"timezone"`
	Week      string `json:"week"`
	DayOfWeek string `json:"day_of_week"`
	Month     string `json:"month"`
	Day       string `json:"day"`
	Hour      string `json:"hour"`
	Minute    string `json:"minute"`
}

func (CronSchedule) GetCommonSchedule

func (s CronSchedule) GetCommonSchedule() CommonSchedule

type EstimateCronOpts

type EstimateCronOpts struct {
	EstimateOpts
	Schedules []CreateCronScheduleOpts `json:"schedules"`
}

EstimateCronOpts represent options for EstimateCronMaxPolicyUsage

type EstimateIntervalOpts

type EstimateIntervalOpts struct {
	EstimateOpts
	Schedules []CreateIntervalScheduleOpts `json:"schedules"`
}

EstimateIntervalOpts represent options for EstimateIntervalMaxPolicyUsage

type EstimateOpts

type EstimateOpts struct {
	Name      string       `json:"name" required:"true" validate:"required"`
	VolumeIds []string     `json:"volume_ids"`
	Status    PolicyStatus `json:"status,omitempty" validate:"omitempty,enum"`
	Action    PolicyAction `json:"action" validate:"required,enum"`
}

type EstimateResult

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

EstimateResult represents the result of a estimate operation. Call its Extract method to interpret it as a EstimateMaxPolicyUsage.

func EstimateCronMaxPolicyUsage

func EstimateCronMaxPolicyUsage(c *gcorecloud.ServiceClient, opts EstimateCronOpts) (r EstimateResult)

EstimateCronMaxPolicyUsage Get maximum usage quota of resources if all snapshots create by the cron policy.

func EstimateIntervalMaxPolicyUsage

func EstimateIntervalMaxPolicyUsage(c *gcorecloud.ServiceClient, opts EstimateIntervalOpts) (r EstimateResult)

EstimateIntervalMaxPolicyUsage Get maximum usage quota of resources if all snapshots create by the interval policy.

func (EstimateResult) Extract

func (r EstimateResult) Extract() (*MaxPolicyUsage, error)

Extract is a function that accepts a result and extracts an estimation of max lifecycle policy resources usage.

type GetOpts

type GetOpts struct {
	NeedVolumes bool `q:"need_volumes"`
}

GetOpts represents options for Get.

type GetResult

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

GetResult represents the result of a Get operation. Call its Extract method to interpret it as a LifecyclePolicy.

func Get

func Get(c *gcorecloud.ServiceClient, id int, opts GetOpts) (r GetResult)

Get retrieves a lifecycle policy with specified unique id. If present, opts are used to construct query parameters.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type IntervalSchedule

type IntervalSchedule struct {
	CommonSchedule
	Weeks   int `json:"weeks"`
	Days    int `json:"days"`
	Hours   int `json:"hours"`
	Minutes int `json:"minutes"`
}

func (IntervalSchedule) GetCommonSchedule

func (s IntervalSchedule) GetCommonSchedule() CommonSchedule

type LifecyclePolicy

type LifecyclePolicy struct {
	Name      string       `json:"name"`
	ID        int          `json:"id"`
	Action    PolicyAction `json:"action"`
	ProjectID int          `json:"project_id"`
	Status    PolicyStatus `json:"status"`
	UserID    int          `json:"user_id"`
	RegionID  int          `json:"region_id"`
	Volumes   []Volume     `json:"volumes"`
	Schedules []Schedule   `json:"schedules"`
}

LifecyclePolicy represents a lifecycle policy resource.

type ListOpts

type ListOpts GetOpts

ListOpts represents options for ListAll.

type ListResult

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

ListResult represents the result of a ListAll operation. Call its Extract method to interpret it as a list of LifecyclePolicy.

func ListAll

func ListAll(c *gcorecloud.ServiceClient, opts ListOpts) (r ListResult)

ListAll returns all lifecycle policies. If present, opts are used to construct query parameters.

func (ListResult) Extract

func (r ListResult) Extract() ([]LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a slice of lifecycle policy resources.

type MaxPolicyUsage

type MaxPolicyUsage struct {
	CountUsage     int             `json:"max_volume_snapshot_count_usage"`
	SizeUsage      int             `json:"max_volume_snapshot_size_usage"`
	SequenceLength int             `json:"max_volume_snapshot_sequence_length"`
	MaxCost        PolicyUsageCost `json:"max_cost"`
}

type PolicyAction

type PolicyAction string

func (PolicyAction) IsValid

func (a PolicyAction) IsValid() error

func (PolicyAction) List

func (a PolicyAction) List() []PolicyAction

func (PolicyAction) String

func (a PolicyAction) String() string

func (PolicyAction) StringList

func (a PolicyAction) StringList() []string

type PolicyStatus

type PolicyStatus string

func (PolicyStatus) IsValid

func (s PolicyStatus) IsValid() error

func (PolicyStatus) List

func (s PolicyStatus) List() []PolicyStatus

func (PolicyStatus) String

func (s PolicyStatus) String() string

func (PolicyStatus) StringList

func (s PolicyStatus) StringList() []string

type PolicyUsageCost

type PolicyUsageCost struct {
	CurrencyCode  gcorecloud.Currency `json:"currency_code"`
	PricePerHour  decimal.Decimal     `json:"price_per_hour"`
	PricePerMonth decimal.Decimal     `json:"price_per_month"`
	PriceStatus   string              `json:"price_status"`
}

type RawSchedule

type RawSchedule struct {
	json.RawMessage
}

RawSchedule is internal struct for unmarshalling into Schedule.

func (RawSchedule) Cook

func (r RawSchedule) Cook() (Schedule, error)

Cook is method for unmarshalling RawSchedule into Schedule

type RemoveSchedulesOpts

type RemoveSchedulesOpts struct {
	ScheduleIDs []string `json:"schedule_ids" validate:"required"`
}

RemoveSchedulesOpts represents options for RemoveSchedules.

type RemoveSchedulesResult

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

RemoveSchedulesResult represents the result of a RemoveSchedules operation. Call its Extract method to interpret it as a LifecyclePolicy.

func RemoveSchedules

func RemoveSchedules(c *gcorecloud.ServiceClient, id int, opts RemoveSchedulesOpts) (r RemoveSchedulesResult)

RemoveSchedules removes schedules from a lifecycle policy with specified unique id. opts are used to construct request body.

func (RemoveSchedulesResult) Extract

func (r RemoveSchedulesResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type RemoveVolumesOpts

type RemoveVolumesOpts struct {
	VolumeIds []string `json:"volume_ids" validate:"required"`
}

RemoveVolumesOpts represents options for RemoveVolumes.

type RemoveVolumesResult

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

RemoveVolumesResult represents the result of a RemoveVolumes operation. Call its Extract method to interpret it as a LifecyclePolicy.

func RemoveVolumes

func RemoveVolumes(c *gcorecloud.ServiceClient, id int, opts RemoveVolumesOpts) (r RemoveVolumesResult)

RemoveVolumes removes volumes from a lifecycle policy with specified unique id. opts are used to construct request body.

func (RemoveVolumesResult) Extract

func (r RemoveVolumesResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type RetentionTimer

type RetentionTimer struct {
	Weeks   int `json:"weeks,omitempty"`
	Days    int `json:"days,omitempty"`
	Hours   int `json:"hours,omitempty"`
	Minutes int `json:"minutes,omitempty"`
}

type Schedule

type Schedule interface {
	GetCommonSchedule() CommonSchedule
}

Schedule represents a schedule resource.

type ScheduleType

type ScheduleType string

func (ScheduleType) IsValid

func (t ScheduleType) IsValid() error

func (ScheduleType) List

func (t ScheduleType) List() []ScheduleType

func (ScheduleType) String

func (t ScheduleType) String() string

func (ScheduleType) StringList

func (t ScheduleType) StringList() []string

type UpdateOpts

type UpdateOpts struct {
	Name   string       `json:"name,omitempty" validate:"omitempty,name"`
	Status PolicyStatus `json:"status,omitempty" validate:"omitempty,enum"`
}

UpdateOpts represents options for Update.

type UpdateResult

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

UpdateResult represents the result of a Update operation. Call its Extract method to interpret it as a LifecyclePolicy.

func Update

func Update(c *gcorecloud.ServiceClient, id int, opts UpdateOpts) (r UpdateResult)

Update updates a lifecycle policy with specified unique id. opts are used to construct request body.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*LifecyclePolicy, error)

Extract is a function that accepts a result and extracts a lifecycle policy resource.

type Volume

type Volume struct {
	ID   string `json:"volume_id"`
	Name string `json:"volume_name"`
}

Volume represents a volume resource.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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