github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcs/v1/backups/RestoreInstance.go (about)

     1  package backups
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type RestoreInstanceOpts struct {
    10  	// ID of the backup record
    11  	BackupId string `json:"backup_id"`
    12  	// Description of DCS instance restoration
    13  	Remark string `json:"remark,omitempty"`
    14  }
    15  
    16  func RestoreInstance(client *golangsdk.ServiceClient, instancesId string, opts RestoreInstanceOpts) (string, error) {
    17  	b, err := build.RequestBody(opts, "")
    18  	if err != nil {
    19  		return "", err
    20  	}
    21  
    22  	raw, err := client.Post(client.ServiceURL("instances", instancesId, "restores"), b, nil, &golangsdk.RequestOpts{
    23  		OkCodes: []int{200},
    24  	})
    25  	if err != nil {
    26  		return "", err
    27  	}
    28  
    29  	var res struct {
    30  		RestoreId string `json:"restore_id"`
    31  	}
    32  	err = extract.Into(raw.Body, &res)
    33  	return res.RestoreId, err
    34  }