github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/css/v1/snapshots/PolicyCreate.go (about) 1 package snapshots 2 3 import "github.com/opentelekomcloud/gophertelekomcloud" 4 5 // PolicyCreateOpts contains options for creating a snapshot policy. 6 // This object is passed to the snapshots.PolicyCreate function. 7 type PolicyCreateOpts struct { 8 Prefix string `json:"prefix" required:"true"` 9 Period string `json:"period" required:"true"` 10 KeepDay int `json:"keepday" required:"true"` 11 Enable string `json:"enable" required:"true"` 12 DeleteAuto string `json:"deleteAuto,omitempty"` 13 } 14 15 // PolicyCreate will create a new snapshot policy based on the values in PolicyCreateOpts. 16 func PolicyCreate(client *golangsdk.ServiceClient, opts PolicyCreateOpts, clusterId string) (err error) { 17 b, err := golangsdk.BuildRequestBody(opts, "") 18 if err != nil { 19 return 20 } 21 22 _, err = client.Post(client.ServiceURL("clusters", clusterId, "index_snapshot/policy"), b, nil, &golangsdk.RequestOpts{ 23 OkCodes: []int{200}, 24 }) 25 return 26 }