github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/backups/Update.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/openstack"
     7  )
     8  
     9  // UpdateOpts contains all the values needed to update a Backup.
    10  type UpdateOpts struct {
    11  	InstanceId string `json:"-"`
    12  	// Specifies the number of days to retain the generated backup files.
    13  	// The value range is from 0 to 732. The value 0 indicates that the automated backup policy is disabled. To extend the retention period, contact customer service. Automated backups can be retained for up to 2562 days.
    14  	// NOTICE
    15  	// Once the automated backup policy is disabled, automated backups are no longer created and all incremental backups are deleted immediately. Operations related to the incremental backups, including downloads, replications, restorations, and rebuilds, may fail.
    16  	// Disabling Automated Backup Policy is not allowed for SQL Server Primary/Standby and Cluster instances. So "keep_days" cannot be set to 0 for SQL Server Primary/Standby and Cluster instances.
    17  	KeepDays *int `json:"keep_days" required:"true"`
    18  	// Specifies the backup time window. Automated backups will be triggered during the backup time window. This parameter is mandatory except that the automated backup policy is disabled.
    19  	// The value must be a valid value in the "hh:mm-HH:MM" format. The current time is in the UTC format.
    20  	// The HH value must be 1 greater than the hh value.
    21  	// The values of mm and MM must be the same and must be set to any of the following: 00, 15, 30, or 45.
    22  	// Example value:
    23  	// 08:15-09:15
    24  	// 23:00-00:00
    25  	StartTime string `json:"start_time,omitempty"`
    26  	// Specifies the backup cycle configuration. Data will be automatically backed up on the selected days every week. This parameter is mandatory except that the automated backup policy is disabled.
    27  	// Value range: The value is digits separated by commas (,), indicating the day of the week and starting from Monday.
    28  	// For example, the value 1,2,3,4 indicates that the backup period is Monday, Tuesday, Wednesday, and Thursday.
    29  	Period string `json:"period,omitempty"`
    30  }
    31  
    32  // Update accepts a UpdateOpts struct and uses the values to update a Backup.The response code from api is 200
    33  func Update(c *golangsdk.ServiceClient, opts UpdateOpts) (err error) {
    34  	b, err := build.RequestBody(opts, "backup_policy")
    35  	if err != nil {
    36  		return
    37  	}
    38  
    39  	// PUT https://{Endpoint}/v3/{project_id}/instances/{instance_id}/backups/policy
    40  	_, err = c.Put(c.ServiceURL("instances", opts.InstanceId, "backups", "policy"), b, nil,
    41  		&golangsdk.RequestOpts{OkCodes: []int{200}, MoreHeaders: openstack.StdRequestOpts().MoreHeaders})
    42  	return
    43  }