github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/csbs/v1/policies/doc.go (about)

     1  /*
     2  Package backup policies enables management and retrieval of
     3  backup servers periodically.
     4  
     5  Example to List Backup Policies
     6  	listpolicies := policies.ListOpts{}
     7  	allpolicies, err := policies.List(client,listpolicies)
     8  	if err != nil {
     9  		panic(err)
    10  	}
    11  	fmt.Println(allpolicies)
    12  
    13  
    14  
    15  Example to Create a Backup Policy
    16  	policy:=policies.CreateOpts{
    17  				Name : "c2c-policy",
    18  				Description : "My plan",
    19  				ProviderId : "fc4d5750-22e7-4798-8a46-f48f62c4c1da",
    20  				Parameters : policies.PolicyParam{
    21  				Common:map[string]interface{}{},
    22  				},
    23  				ScheduledOperations : []policies.ScheduledOperation{ {
    24  					Name:  "my-backup",
    25  					Description: "My backup policy",
    26  					Enabled: true,
    27  					OperationDefinition: policies.OperationDefinition{
    28  						MaxBackups: 5,
    29  					},
    30  					Trigger: policies.Trigger{
    31  						Properties : policies.TriggerProperties{
    32  							Pattern : "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nRRULE:FREQ=WEEKLY;BYDAY=TH;BYHOUR=12;BYMINUTE=27\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
    33  						},
    34  					},
    35  					OperationType: "backup",
    36  				}},
    37  				Resources : []policies.Resource{{
    38  					Id:  "9422f270-6fcf-4ba2-9319-a007f2f63a8e",
    39  					Type: "OS::Nova::Server",
    40  					Name: "resource4"
    41  				}},
    42  		}
    43  	out,err:=policies.Create(client,policy).Extract()
    44  	fmt.Println(out)
    45  	fmt.Println(err)
    46  
    47  
    48  Example to Update a Backup Policy
    49  	updatepolicy:=policies.UpdateOpts{
    50  								Name:"my-plan-c2c-update",
    51  								Parameters : policies.PolicyParamUpdate{
    52  									Common:map[string]interface{}{},
    53  								},
    54  								ScheduledOperations:[]policies.ScheduledOperationToUpdate{{
    55  									Id:"b70c712d-f48b-43f7-9a0f-3bab86d59149",
    56  									Name:"my-backup-policy",
    57  									Description:"My backup policy",
    58  									Enabled:true,
    59  									OperationDefinition:policies.OperationDefinition{
    60  										RetentionDurationDays:-1,
    61  										MaxBackups:20,
    62  									},
    63  									Trigger:policies.Trigger{
    64  										Properties:policies.TriggerProperties{
    65  											Pattern:"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nRRULE:FREQ=WEEKLY;BYDAY=TH;BYHOUR=12;BYMINUTE=27\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"}}
    66  										}
    67  									}
    68  								}
    69  							}
    70  		out,err:=policies.Update(client,"5af626d2-19b9-4dc4-8e95-ddba008318b3",updatepolicy).Extract()
    71  		fmt.Println(out)
    72  
    73  Example to Delete a Backup Policy
    74  	out:=policies.Delete(client,"16d4bf9e-85b2-41e2-a482-e48ace2ad726")
    75  	fmt.Println(out)
    76  	if err != nil {
    77  		panic(err)
    78  	}
    79  
    80  Example to Get Backup Policy
    81  	result:=policies.Get(client,"5af626d2-19b9-4dc4-8e95-ddba008318b3")
    82  	out,err:=result.Extract()
    83  	fmt.Println(out)
    84  
    85  */
    86  package policies