policies

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStructNestedField

func GetStructNestedField(v *Policy, field string, structDriller []string) string

Types

type AssociateOpts

type AssociateOpts struct {
	// Backup policy ID, to which the resource is to be associated.
	PolicyID string `json:"backup_policy_id" required:"true"`
	// Details about the resources to associate with the policy.
	Resources []AssociateResource `json:"resources" required:"true"`
}

AssociateOpts contains the options to associate a resource to a Policy.

func (AssociateOpts) ToPolicyAssociateMap

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

ToPolicyAssociateMap assembles a request body based on the contents of a AssociateOpts.

type AssociateOptsBuilder

type AssociateOptsBuilder interface {
	ToPolicyAssociateMap() (map[string]interface{}, error)
}

AssociateOptsBuilder allows extensions to add additional parameters to the Associate request.

type AssociateResource

type AssociateResource struct {
	// The ID of the resource to associate with policy.
	ResourceID string `json:"resource_id" required:"true"`
	// Type of the resource , e.g. volume.
	ResourceType string `json:"resource_type" required:"true"`
}

type CreateOpts

type CreateOpts struct {
	// Backup policy name.It cannot start with default.
	Name string `json:"backup_policy_name" required:"true"`
	// Details about the scheduling policy
	ScheduledPolicy ScheduledPolicy `json:"scheduled_policy" required:"true"`
	// Tags to be configured for the backup policy
	Tags []Tag `json:"tags,omitempty"`
}

CreateOpts contains the options for create a Policy. This object is passed to Create(). For more information about these parameters, please refer to the Policy object, or the volume backup service API v2 documentation

func (CreateOpts) ToPolicyCreateMap

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

ToPolicyCreateMap assembles a request body based on the contents of a CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

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

CreateResult represents the result of a create operation.

func Create

func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

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

func (CreateResult) Extract

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

Extract will get the Policy object from the commonResult

type DeleteResult

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

DeleteResult represents the result of a delete operation.

func Delete

func Delete(c *golangsdk.ServiceClient, policyID string) (r DeleteResult)

Delete will delete the specified backup policy.

func (DeleteResult) Extract

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

Extract will get the Policy object from the commonResult

type DisassociateOpts

type DisassociateOpts struct {
	// Disassociate Resources
	Resources []DisassociateResource `json:"resources" required:"true"`
}

DisassociateOpts contains the options disassociate a resource from a Policy.

func (DisassociateOpts) ToPolicyDisassociateMap

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

ToPolicyDisassociateMap assembles a request body based on the contents of a DisassociateOpts.

type DisassociateOptsBuilder

type DisassociateOptsBuilder interface {
	ToPolicyDisassociateMap() (map[string]interface{}, error)
}

DisassociateOptsBuilder allows extensions to add additional parameters to the Disassociate request.

type DisassociateResource

type DisassociateResource struct {
	// ResourceID
	ResourceID string `json:"resource_id" required:"true"`
}

type FilterStruct

type FilterStruct struct {
	Value   string
	Driller []string
}

type ListOpts

type ListOpts struct {
	// Backup policy ID
	ID string
	// Backup policy name
	Name string
	// Backup policy status
	Status string
}

ListOpts allows filtering policies

type Policy

type Policy struct {
	// Backup policy ID
	ID string `json:"backup_policy_id"`
	// Backup policy name
	Name string `json:"backup_policy_name"`
	// Details about the scheduling policy
	ScheduledPolicy ScheduledPolicy `json:"scheduled_policy"`
	// Number of volumes associated with the backup policy
	ResourceCount int `json:"policy_resource_count"`
}

func ExtractPolicies

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

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

func FilterPolicies

func FilterPolicies(policies []Policy, opts ListOpts) ([]Policy, error)

func List

func List(c *golangsdk.ServiceClient, opts ListOpts) ([]Policy, error)

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

type PolicyPage

type PolicyPage struct {
	pagination.LinkedPageBase
}

func (PolicyPage) IsEmpty

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

IsEmpty returns true if a page contains no Policies results.

func (PolicyPage) NextPageURL

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

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type Resource

type Resource struct {
	// Resource ID
	ResourceID string `json:"resource_id"`
	// Resource type
	ResourceType string `json:"resource_type"`
	// Availability zone to which the resource belongs
	AvailabilityZone string `json:"availability_zone"`
	// POD to which the resource belongs
	Pod string `json:"os_vol_host_attr"`
}

type ResourceResult

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

ResourceResult represents the result of a associate/diassociate operation.

func Associate

func Associate(client *golangsdk.ServiceClient, opts AssociateOpts) (r ResourceResult)

Associate will associate a resource tp a backup policy based on the values in AssociateOpts. To extract the associated resources from the response, call the ExtractResource method on the ResourceResult.

func Disassociate

func Disassociate(client *golangsdk.ServiceClient, policyID string, opts DisassociateOpts) (r ResourceResult)

Disassociate will disassociate a resource from a backup policy based on the values in DisassociateOpts. To extract the disassociated resources from the response, call the ExtractResource method on the ResourceResult.

func (ResourceResult) Extract

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

Extract will get the Policy object from the commonResult

func (ResourceResult) ExtractResource

func (r ResourceResult) ExtractResource() (*ResultResources, error)

ExtractResource will get the Association/disassociation of resources from the ResourceResult

type ResultResources

type ResultResources struct {
	// List of successfully associated/disassociated resources
	SuccessResources []Resource `json:"success_resources"`
	// List of the resources that fail to be associated/disassociated
	FailResources []Resource `json:"fail_resources"`
}

type ScheduledPolicy

type ScheduledPolicy struct {
	// Start time of the backup job.
	StartTime string `json:"start_time" required:"true"`
	// Backup interval (1 to 14 days)
	Frequency int `json:"frequency,omitempty"`
	// Specifies on which days of each week backup jobs are ececuted.
	WeekFrequency []string `json:"week_frequency,omitempty"`
	// Number of retained backups, minimum 2.
	RententionNum int `json:"rentention_num,omitempty"`
	// Days of retained backups, minimum 2.
	RententionDay int `json:"rentention_day,omitempty"`
	// Whether to retain the first backup in the current month, possible values Y or N
	RemainFirstBackup string `json:"remain_first_backup_of_curMonth" required:"true"`
	// Backup policy status, ON or OFF
	Status string `json:"status" required:"true"`
}

ScheduledPolicy defines the details about scheduling policy for create

type Tag

type Tag struct {
	// Tag key. A tag key consists of up to 36 characters
	Key string `json:"key" required:"true"`
	// Tag value. A tag value consists of 0 to 43 characters
	Value string `json:"value" required:"true"`
}

type UpdateOpts

type UpdateOpts struct {
	// Backup policy name.It cannot start with default.
	Name string `json:"backup_policy_name,omitempty"`
	// Details about the scheduling policy
	ScheduledPolicy UpdateSchedule `json:"scheduled_policy,omitempty"`
}

UpdateOpts contains the options for Update a Policy.

func (UpdateOpts) ToPolicyUpdateMap

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

ToPolicyUpdateMap assembles a request body based on the contents of a UpdateOpts.

type UpdateOptsBuilder

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

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

UpdateResult represents the result of a update operation.

func Update

func Update(c *golangsdk.ServiceClient, policyID string, opts UpdateOptsBuilder) (r UpdateResult)

Update will Update an existing backup Policy based on the values in UpdateOpts.To extract the Policy object from the response, call the Extract method on the UpdateResult.

func (UpdateResult) Extract

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

Extract will get the Policy object from the commonResult

type UpdateSchedule

type UpdateSchedule struct {
	// Start time of the backup job.
	StartTime string `json:"start_time,omitempty"`
	// Backup interval (1 to 14 days)
	Frequency int `json:"frequency,omitempty"`
	// Specifies on which days of each week backup jobs are ececuted.
	WeekFrequency []string `json:"week_frequency,omitempty"`
	// Number of retained backups, minimum 2.
	RententionNum int `json:"rentention_num,omitempty"`
	// Days of retained backups, minimum 2.
	RententionDay int `json:"rentention_day,omitempty"`
	// Number of retained backups, minimum 2.
	RemainFirstBackup string `json:"remain_first_backup_of_curMonth,omitempty"`
	// Backup policy status, ON or OFF
	Status string `json:"status,omitempty"`
}

UpdateSchedule defiens the details about scheduling policy for update.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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