Documentation
¶
Overview ¶
Package backup policies enables management and retrieval of backup servers periodically.
Example to List Backup Policies
listpolicies := policies.ListOpts{}
allpolicies, err := policies.List(client,listpolicies)
if err != nil {
panic(err)
}
fmt.Println(allpolicies)
Example to Create a Backup Policy
policy:=policies.CreateOpts{
Name : "c2c-policy",
Description : "My plan",
ProviderId : "fc4d5750-22e7-4798-8a46-f48f62c4c1da",
Parameters : policies.PolicyParam{
Common:map[string]interface{}{},
},
ScheduledOperations : []policies.ScheduledOperation{ {
Name: "my-backup",
Description: "My backup policy",
Enabled: true,
OperationDefinition: policies.OperationDefinition{
MaxBackups: 5,
},
Trigger: policies.Trigger{
Properties : policies.TriggerProperties{
Pattern : "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nRRULE:FREQ=WEEKLY;BYDAY=TH;BYHOUR=12;BYMINUTE=27\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
},
},
OperationType: "backup",
}},
Resources : []policies.Resource{{
Id: "9422f270-6fcf-4ba2-9319-a007f2f63a8e",
Type: "OS::Nova::Server",
Name: "resource4"
}},
}
out,err:=policies.Create(client,policy).Extract()
fmt.Println(out)
fmt.Println(err)
Example to Update a Backup Policy
updatepolicy:=policies.UpdateOpts{
Name:"my-plan-c2c-update",
Parameters : policies.PolicyParamUpdate{
Common:map[string]interface{}{},
},
ScheduledOperations:[]policies.ScheduledOperationToUpdate{{
Id:"b70c712d-f48b-43f7-9a0f-3bab86d59149",
Name:"my-backup-policy",
Description:"My backup policy",
Enabled:true,
OperationDefinition:policies.OperationDefinition{
RetentionDurationDays:-1,
MaxBackups:20,
},
Trigger:policies.Trigger{
Properties:policies.TriggerProperties{
Pattern:"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nRRULE:FREQ=WEEKLY;BYDAY=TH;BYHOUR=12;BYMINUTE=27\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"}}
}
}
}
}
out,err:=policies.Update(client,"5af626d2-19b9-4dc4-8e95-ddba008318b3",updatepolicy).Extract()
fmt.Println(out)
Example to Delete a Backup Policy
out:=policies.Delete(client,"16d4bf9e-85b2-41e2-a482-e48ace2ad726")
fmt.Println(out)
if err != nil {
panic(err)
}
Example to Get Backup Policy
result:=policies.Get(client,"5af626d2-19b9-4dc4-8e95-ddba008318b3") out,err:=result.Extract() fmt.Println(out)
Index ¶
- type BackupPolicy
- type BackupPolicyPage
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListResult
- type OperationDefinition
- type OperationDefinitionResp
- type PolicyParam
- type Resource
- type ResourceTag
- type ScheduledOperation
- type ScheduledOperationResp
- type ScheduledOperationToUpdate
- type Trigger
- type TriggerProperties
- type TriggerPropertiesResp
- type TriggerResp
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupPolicy ¶
type BackupPolicy struct {
CreatedAt time.Time `json:"-"`
Description string `json:"description"`
ID string `json:"id"`
Name string `json:"name"`
Parameters PolicyParam `json:"parameters"`
ProjectId string `json:"project_id"`
ProviderId string `json:"provider_id"`
Resources []Resource `json:"resources"`
ScheduledOperations []ScheduledOperationResp `json:"scheduled_operations"`
Status string `json:"status"`
Tags []ResourceTag `json:"tags"`
}
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 FilterPolicies ¶
func FilterPolicies(policies []BackupPolicy, opts ListOpts) ([]BackupPolicy, error)
func List ¶
func List(c *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 (*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 {
Description string `json:"description,omitempty"`
Name string `json:"name" required:"true"`
Parameters PolicyParam `json:"parameters" required:"true"`
ProviderId string `json:"provider_id" required:"true"`
Resources []Resource `json:"resources" required:"true"`
ScheduledOperations []ScheduledOperation `json:"scheduled_operations" required:"true"`
Tags []ResourceTag `json:"tags,omitempty"`
}
CreateOpts contains the options for create a Backup Policy. This object is passed to policies.Create().
func (CreateOpts) ToBackupPolicyCreateMap ¶
func (opts CreateOpts) ToBackupPolicyCreateMap() (map[string]interface{}, error)
ToBackupPolicyCreateMap assembles a request body based on the contents of a CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
func Create ¶
func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
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 (CreateResult) Extract ¶
func (r CreateResult) Extract() (*BackupPolicy, error)
Extract will get the backup policies object from the commonResult
type DeleteResult ¶
type DeleteResult struct {
// contains filtered or unexported fields
}
func Delete ¶
func Delete(client *golangsdk.ServiceClient, policy_id string) (r DeleteResult)
Delete will delete an existing backup policy.
func (DeleteResult) Extract ¶
func (r DeleteResult) Extract() (*BackupPolicy, error)
Extract will get the backup policies object from the commonResult
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
func Get ¶
func Get(client *golangsdk.ServiceClient, policy_id string) (r GetResult)
Get will get a single backup policy with specific ID. call the Extract method on the GetResult.
func (GetResult) Extract ¶
func (r GetResult) Extract() (*BackupPolicy, error)
Extract will get the backup policies object from the commonResult
type ListOpts ¶
type ListOpts struct {
// id and status are not supported in API, will filtered by FilterPolicies
ID string `json:"id"`
Status string `json:"status"`
Name string `q:"name"`
Sort string `q:"sort"`
Limit int `q:"limit"`
Marker string `q:"marker"`
Offset int `q:"offset"`
AllTenants string `q:"all_tenants"`
}
type ListResult ¶
type ListResult struct {
// contains filtered or unexported fields
}
func (ListResult) Extract ¶
func (r ListResult) Extract() (*BackupPolicy, error)
Extract will get the backup policies object from the commonResult
type OperationDefinition ¶
type OperationDefinitionResp ¶
type OperationDefinitionResp struct {
MaxBackups int `json:"-"`
RetentionDurationDays int `json:"-"`
Permanent bool `json:"-"`
PlanId string `json:"plan_id"`
ProviderId string `json:"provider_id"`
}
func (*OperationDefinitionResp) UnmarshalJSON ¶
func (r *OperationDefinitionResp) UnmarshalJSON(b []byte) error
UnmarshalJSON helps to unmarshal OperationDefinitionResp fields into needed values.
type PolicyParam ¶
type PolicyParam struct {
Common interface{} `json:"common,omitempty"`
}
type ResourceTag ¶
type ScheduledOperation ¶
type ScheduledOperation struct {
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Name string `json:"name,omitempty"`
OperationType string `json:"operation_type" required:"true"`
OperationDefinition OperationDefinition `json:"operation_definition" required:"true"`
Trigger Trigger `json:"trigger" required:"true"`
}
type ScheduledOperationResp ¶
type ScheduledOperationResp struct {
Description string `json:"description"`
Enabled bool `json:"enabled"`
Name string `json:"name"`
OperationType string `json:"operation_type"`
OperationDefinition OperationDefinitionResp `json:"operation_definition"`
Trigger TriggerResp `json:"trigger"`
ID string `json:"id"`
TriggerID string `json:"trigger_id"`
}
type ScheduledOperationToUpdate ¶
type ScheduledOperationToUpdate struct {
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
TriggerId string `json:"trigger_id,omitempty"`
Name string `json:"name,omitempty"`
OperationDefinition OperationDefinition `json:"operation_definition,omitempty"`
Trigger Trigger `json:"trigger,omitempty"`
Id string `json:"id" required:"true"`
}
type Trigger ¶
type Trigger struct {
Properties TriggerProperties `json:"properties" required:"true"`
}
type TriggerProperties ¶
type TriggerProperties struct {
Pattern string `json:"pattern" required:"true"`
}
type TriggerPropertiesResp ¶
type TriggerPropertiesResp struct {
Pattern string `json:"pattern"`
StartTime time.Time `json:"-"`
}
func (*TriggerPropertiesResp) UnmarshalJSON ¶
func (r *TriggerPropertiesResp) UnmarshalJSON(b []byte) error
UnmarshalJSON helps to unmarshal TriggerPropertiesResp fields into needed values.
type TriggerResp ¶
type TriggerResp struct {
Properties TriggerPropertiesResp `json:"properties"`
Name string `json:"name"`
ID string `json:"id"`
Type string `json:"type"`
}
type UpdateOpts ¶
type UpdateOpts struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
Parameters PolicyParam `json:"parameters,omitempty"`
Resources []Resource `json:"resources,omitempty"`
ScheduledOperations []ScheduledOperationToUpdate `json:"scheduled_operations,omitempty"`
}
UpdateOpts contains the values used when updating a backup policy.
func (UpdateOpts) ToPoliciesUpdateMap ¶
func (opts UpdateOpts) ToPoliciesUpdateMap() (map[string]interface{}, error)
ToPoliciesUpdateMap builds an update body based on UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
func Update ¶
func Update(c *golangsdk.ServiceClient, policy_id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows backup policies to be updated. call the Extract method on the UpdateResult.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (*BackupPolicy, error)
Extract will get the backup policies object from the commonResult