policies

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(client *golangsdk.ServiceClient, policyId string) (err error)

Delete will delete an existing backup policy.

Types

type BackupPolicy

type BackupPolicy struct {
	// Creation time, for example, 2017-04-18T01:21:52.701973
	CreatedAt time.Time `json:"-"`
	// Backup policy description
	// The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
	Description string `json:"description"`
	// Backup policy ID
	ID string `json:"id"`
	// Backup policy name
	// The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
	Name string `json:"name"`
	// Parameters of a backup policy
	Parameters PolicyParam `json:"parameters"`
	// Project ID
	ProjectId string `json:"project_id"`
	// Backup provider ID, which specifies whether the backup object is a server or disk.
	// This parameter has a fixed value. For CSBS, the value is fc4d5750-22e7-4798-8a46-f48f62c4c1da.
	ProviderId string `json:"provider_id"`
	// Backup object list
	Resources []Resource `json:"resources"`
	// Scheduling period list
	ScheduledOperations []ScheduledOperation `json:"-"`
	// Backup policy status
	// disabled: indicates that the backup policy is unavailable.
	// enabled: indicates that the backup policy is available.
	Status string `json:"status"`
	// Tag list
	// Keys in the tag list must be unique.
	Tags []tags.ResourceTag `json:"tags"`
}

func Create

func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*BackupPolicy, error)

Create will create a new backup policy based on the values in CreateOpts. To extract the Backup object from the response, call the Extract method on the CreateResult.

func ExtractBackupPolicies

func ExtractBackupPolicies(r pagination.Page) ([]BackupPolicy, error)

ExtractBackupPolicies accepts a Page struct, specifically a BackupPolicyPage struct, and extracts the elements into a slice of Policy structs. In other words, a generic collection is mapped into a relevant slice.

func Get

func Get(client *golangsdk.ServiceClient, policyId string) (*BackupPolicy, error)

Get will get a single backup policy with specific ID. call the Extract method on the GetResult.

func List

func List(client *golangsdk.ServiceClient, opts ListOpts) ([]BackupPolicy, error)

List returns a Pager which allows you to iterate over a collection of backup policies. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.

func Update

func Update(c *golangsdk.ServiceClient, policyId string, opts UpdateOpts) (*BackupPolicy, error)

Update allows backup policies to be updated. call the Extract method on the UpdateResult.

func (*BackupPolicy) UnmarshalJSON

func (r *BackupPolicy) UnmarshalJSON(b []byte) error

UnmarshalJSON helps to unmarshal BackupPolicy fields into needed values.

type BackupPolicyPage

type BackupPolicyPage struct {
	pagination.LinkedPageBase
}

BackupPolicyPage is the page returned by a pager when traversing over a collection of backup policies.

func (BackupPolicyPage) IsEmpty

func (r BackupPolicyPage) IsEmpty() (bool, error)

IsEmpty checks whether a BackupPolicyPage struct is empty.

func (BackupPolicyPage) NextPageURL

func (r BackupPolicyPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of backup policies has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type CreateOpts

type CreateOpts struct {
	// Backup policy description
	// The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
	Description string `json:"description,omitempty"`
	// Backup policy name
	// The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
	Name string `json:"name" required:"true"`
	// Backup parameters
	// For details, see Table 2-24.
	Parameters PolicyParam `json:"parameters" required:"true"`
	// Backup provider ID, which specifies whether the backup object is a server or disk.
	// This parameter has a fixed value. For CSBS, the value is fc4d5750-22e7-4798-8a46-f48f62c4c1da.
	ProviderId string `json:"provider_id" required:"true"`
	// Backup object list. The list can be blank.
	// For details, see Table 2-25.
	Resources []Resource `json:"resources" required:"true"`
	// Scheduling period
	ScheduledOperations []ScheduledOperation `json:"scheduled_operations" required:"true"`
	// Tag list
	// This list cannot be an empty list.
	// The list can contain up to 10 keys.
	// Keys in this list must be unique.
	Tags []tags.ResourceTag `json:"tags,omitempty"`
}

CreateOpts contains the options for create a Backup Policy. This object is passed to policies.Create().

type ListOpts

type ListOpts struct {
	// Exact matching based on field name
	Name string `q:"name"`
	// The value of sort is a group of properties separated by commas (,) and sorting directions.
	// The value format is <key1>[:<direction>],<key2>[:<direction>], where the value of direction is asc
	// (in ascending order) or desc (in descending order). If the parameter direction is not specified,
	// backup policies are sorted in descending order by time. The value of sort contains a maximum of 255 characters.
	Sort string `q:"sort"`
	// Number of resources displayed per page. The value must be a positive integer. The value defaults to 1000.
	Limit int `q:"limit"`
	// ID of the last record displayed on the previous page when pagination query is applied
	Marker string `q:"marker"`
	// Offset value, which is a positive integer.
	Offset int `q:"offset"`
	// Whether backup policies of all tenants can be queried
	// This parameter is only available for administrators.
	AllTenants string `q:"all_tenants"`
}

type OperationDefinition

type OperationDefinition struct {
	// Maximum number of backups that can be automatically created for a backup object.
	// The value can be -1 or ranges from 0 to 99999. If the value is set to -1,
	// the backups will not be cleared even though the configured retained backup quantity limit is exceeded.
	MaxBackups *int `json:"max_backups,omitempty"`
	// Duration of retaining a backup, in days. The value can be -1 or ranges from 0 to 99999.
	// If the value is set to -1, backups will not be cleared even though the configured retention duration is exceeded.
	RetentionDurationDays int `json:"retention_duration_days,omitempty"`
	// Whether backups are permanently retained. false: no. true: yes
	Permanent bool `json:"permanent" required:"true"`
	// Backup policy ID
	PlanId string `json:"plan_id,omitempty"`
	// Backup provider ID, which specifies whether the backup object is a server or disk.
	// This parameter has a fixed value. For CSBS, the value is fc4d5750-22e7-4798-8a46-f48f62c4c1da.
	ProviderId string `json:"provider_id,omitempty"`
	// Specifies the maximum number of retained daily backups. The latest backup of each day is saved in the long term.
	// This parameter can be effective together with the maximum number of retained backups specified by max_backups.
	// If this parameter is configured, timezone is mandatory.
	DayBackups int `json:"day_backups,omitempty"`
	// Specifies the maximum number of retained weekly backups. The latest backup of each week is saved in the long term.
	// This parameter can be effective together with the maximum number of retained backups specified by max_backups.
	// If this parameter is configured, timezone is mandatory.
	WeekBackups int `json:"week_backups,omitempty"`
	// Specifies the maximum number of retained monthly backups. The latest backup of each month is saved in the long term.
	// This parameter can be effective together with the maximum number of retained backups specified by max_backups.
	// If this parameter is configured, timezone is mandatory.
	MonthBackups int `json:"month_backups,omitempty"`
	// Specifies the maximum number of retained yearly backups. The latest backup of each year is saved in the long term.
	// This parameter can be effective together with the maximum number of retained backups specified by max_backups.
	// If this parameter is configured, timezone is mandatory.
	YearBackups int `json:"year_backups,omitempty"`
	// Time zone where the user is located, for example, UTC+08:00. Set this parameter only
	// after you have configured any of the parameters day_backups, week_backups, month_backups, and year_backups.
	TimeZone string `json:"timezone,omitempty"`
}

type PolicyParam

type PolicyParam struct {
	// General backup policy parameters, which are blank by default
	Common interface{} `json:"common,omitempty"`
}

type Resource

type Resource struct {
	// ID of the object to be backed up
	Id string `json:"id" required:"true"`
	// Entity object type of backup objects
	// The value is fixed at OS::Nova::Server (ECSs).
	Type string `json:"type" required:"true"`
	// Backup object name
	Name string `json:"name" required:"true"`
	// Additional information about the backup object
	ExtraInfo interface{} `json:"extra_info,omitempty"`
}

type ScheduledOperation

type ScheduledOperation struct {
	// Scheduling period description
	// The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
	Description string `json:"description,omitempty"`
	// Whether the backup policy is enabled
	// If it is set to true, automatic scheduling is enabled. If it is set to false, automatic scheduling is disabled but you can execute the policy manually.
	Enabled bool `json:"enabled"`
	// Whether the backup policy is enabled
	// If it is set to true, automatic scheduling is enabled. If it is set to false, automatic scheduling is disabled but you can execute the policy manually.
	Name string `json:"name,omitempty"`
	// Operation type, which can be backup
	// Enumeration values: backup
	OperationType string `json:"operation_type" required:"true"`
	// Scheduling period parameters
	OperationDefinition OperationDefinition `json:"operation_definition" required:"true"`
	// Scheduling policy
	Trigger Trigger `json:"trigger" required:"true"`
	// Response: Scheduling period ID
	ID string `json:"id,omitempty"`
	// Response: Scheduler ID
	TriggerID string `json:"trigger_id,omitempty"`
}

type ScheduledOperationToUpdate

type ScheduledOperationToUpdate struct {
	// Scheduling period description
	// The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
	Description string `json:"description,omitempty"`
	// Whether the backup policy is enabled
	// The default value is true. If it is set to false, automatic scheduling is disabled but manual scheduling is supported.
	Enabled bool `json:"enabled"`
	// Scheduling period name
	// The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
	Name string `json:"name,omitempty"`
	// Scheduling period parameter
	OperationDefinition OperationDefinition `json:"operation_definition,omitempty"`
	// Scheduling policy
	Trigger Trigger `json:"trigger,omitempty"`
	// Scheduling period ID
	Id string `json:"id" required:"true"`
}

type Trigger

type Trigger struct {
	// Scheduler properties
	Properties TriggerProperties `json:"properties" required:"true"`
	// Response: Scheduler name
	Name string `json:"name,omitempty"`
	// Response: Scheduler ID
	ID string `json:"id,omitempty"`
	// Response: Scheduling type. The value is fixed at time.
	Type string `json:"type,omitempty"`
}

type TriggerProperties

type TriggerProperties struct {
	// Scheduling policy of the scheduler. The value consists of a maximum of 10,240 characters.
	// The scheduling policy complies with iCalendar RFC 2445, but it supports only four parameters,
	// which are FREQ, BYDAY, BYHOUR, and BYMINUTE. FREQ can be set only to WEEKLY or DAILY.
	// BYDAY can be set to MO, TU, WE, TH, FR, SA, or SU (seven days of a week).
	// BYHOUR ranges from 0 to 23 hours. BYMINUTE ranges from 0 to 59 minutes.
	// The scheduling interval cannot be less than 1 hour. A maximum of 24 time points are allowed in a day.
	Pattern string `json:"pattern" required:"true"`
	// Response: Scheduler start time, for example, 2017-04-18T01:21:52
	StartTime string `json:"start_time,omitempty"`
	// Response: Scheduler type
	Format string `json:"format,omitempty"`
}

type UpdateOpts

type UpdateOpts struct {
	// Backup policy description
	// The value consists of 0 to 255 characters and must not contain a greater-than sign (>) or less-than sign (<).
	Description string `json:"description,omitempty"`
	// Backup policy name
	// The value consists of 1 to 255 characters and can contain only letters, digits, underscores (_), and hyphens (-).
	Name string `json:"name,omitempty"`
	// Backup objects
	Resources []Resource `json:"resources,omitempty"`
	// Scheduling period. A backup policy has only one backup period.
	ScheduledOperations []ScheduledOperationToUpdate `json:"scheduled_operations,omitempty"`
}

UpdateOpts contains the values used when updating a backup policy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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