github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/backups/Create.go (about) 1 package backups 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 type BackupDatabase struct { 10 // Specifies the names of self-built databases. 11 Name string `json:"name"` 12 } 13 14 type CreateOpts struct { 15 // Specifies the DB instance ID. 16 InstanceID string `json:"instance_id" required:"true"` 17 // Specifies the backup name. It must be 4 to 64 characters in length and start with a letter. It is case-sensitive and can contain only letters, digits, hyphens (-), and underscores (_). 18 // The backup name must be unique. 19 Name string `json:"name" required:"true"` 20 // Specifies the backup description. It contains a maximum of 256 characters and cannot contain the following special characters: >!<"&'= 21 Description string `json:"description,omitempty"` 22 // Specifies a list of self-built Microsoft SQL Server databases that are partially backed up. (Only Microsoft SQL Server support partial backups.) 23 Databases []BackupDatabase `json:"databases,omitempty"` 24 } 25 26 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*Backup, error) { 27 b, err := build.RequestBody(opts, "") 28 if err != nil { 29 return nil, err 30 } 31 32 // POST https://{Endpoint}/v3/{project_id}/backups 33 raw, err := c.Post(c.ServiceURL("backups"), b, nil, &golangsdk.RequestOpts{ 34 OkCodes: []int{200, 201}, 35 }) 36 if err != nil { 37 return nil, err 38 } 39 40 var res Backup 41 err = extract.IntoStructPtr(raw.Body, &res, "backup") 42 return &res, err 43 }