github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vbs/v2/policies/doc.go (about) 1 package policies 2 3 /* 4 Package policies enables management and retrieval of backup policies 5 VBS service. 6 7 Example to List Policies 8 9 listopts := policies.ListOpts{PolicyID:"ef5c5859-a8f4-48cb-869a-dbbc466cd6b6",Frequency:0} 10 list,err := policies.List(client,listopts) 11 if err != nil { 12 panic(err) 13 } 14 15 16 Example to Create a Policy 17 18 creatopts := policies.CreateOpts{PolicyName: "Demo_policy", ScheduledPolicy: policies.ScheduledPolicy{StartTime: "12:00", Status: "ON", Frequency: 1, RententionNum: 12, RemainFirstBackup: "Y",}, Tags:[]policies.Tag{{Key:"key",Value:"value"}}} 19 create, err := policies.Create(client, creatopts).Extract() 20 if err != nil { 21 panic(err) 22 } 23 24 Example to Delete a Policy 25 26 delete := policies.Delete(client,"c776176d-eb3c-4f48-902a-da3a12c4fea9") 27 if delete.Err != nil { 28 panic(delete.Err) 29 } 30 31 Example to Associate a resource to a Policy 32 33 assopts := policies.AssociateOpts{PolicyID:"5b549fad-c4e5-4d7e-83b9-eea366f27017",Resources:[]policies.AssociateResource{{ResourceID:"bdec76de-3cca-46b4-8b71-a333467a1b79",ResourceType:"volume"},{ResourceID:"286b8b84-6640-4f6f-acde-2a58e490f371",ResourceType:"volume"}}} 34 associate,err := policies.Associate(client,assopts).ExtractResource() 35 36 Example to disassociate a resource to a Policy 37 disassopts := policies.DisassociateOpts{Resources: []policies.DisassociateResource{{ResourceID: "bdec76de-3cca-46b4-8b71-a333467a1b79"},{ResourceID: "286b8b84-6640-4f6f-acde-2a58e490f371"}}} 38 disassociate,err := policies.Disassociate(client,"5b549fad-c4e5-4d7e-83b9-eea366f27017",disassopts).ExtractResource() 39 40 */