github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/checkpoint/requests.go (about)

     1  package checkpoint
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type CreateOpts struct {
     9  	// ID of the vault
    10  	VaultID string `json:"vault_id" required:"true"`
    11  	// Checkpoint parameters
    12  	Parameters CheckpointParam `json:"parameters,omitempty"`
    13  }
    14  
    15  type CheckpointParam struct {
    16  	// Describes whether automatic triggering is enabled
    17  	// Default: false
    18  	AutoTrigger bool `json:"auto_trigger,omitempty"`
    19  	// Backup description
    20  	Description string `json:"description,omitempty"`
    21  	// Whether bacup is incremental or not
    22  	// Default: true
    23  	Incremental bool `json:"incremental,omitempty"`
    24  	// Backup name
    25  	Name string `json:"name,omitempty"`
    26  	// UUID list of resources to be backed up
    27  	Resources []string `json:"resources,omitempty"`
    28  	// Additional information on Resource
    29  	ResourceDetails []Resource `json:"resource_details,omitempty"`
    30  }
    31  
    32  type Resource struct {
    33  	// ID of the resource to be backed up
    34  	ID string `json:"id"`
    35  	// Name of the resource to be backed up
    36  	Name string `json:"name,omitempty"`
    37  	// Type of the resource to be backed up
    38  	// OS::Nova::Server | OS::Cinder::Volume
    39  	Type string `json:"type,omitempty"`
    40  }
    41  
    42  func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*Checkpoint, error) {
    43  	b, err := golangsdk.BuildRequestBody(opts, "checkpoint")
    44  	if err != nil {
    45  		return nil, err
    46  	}
    47  
    48  	raw, err := client.Post(client.ServiceURL("checkpoints"), b, nil, &golangsdk.RequestOpts{
    49  		OkCodes: []int{200},
    50  	})
    51  	if err != nil {
    52  		return nil, err
    53  	}
    54  
    55  	var res Checkpoint
    56  	err = extract.IntoStructPtr(raw.Body, &res, "checkpoint")
    57  	return &res, err
    58  }
    59  
    60  type Checkpoint struct {
    61  	CreatedAt string    `json:"created_at"`
    62  	ID        string    `json:"id"`
    63  	ProjectID string    `json:"project_id"`
    64  	Status    string    `json:"status"`
    65  	Vault     Vault     `json:"vault"`
    66  	ExtraInfo ExtraInfo `json:"extra_info"`
    67  }
    68  
    69  type Vault struct {
    70  	ID               string                `json:"id"`
    71  	Name             string                `json:"name"`
    72  	Resources        []CheckpointResources `json:"resources"`
    73  	SkippedResources []SkippedResources    `json:"skipped_resources"`
    74  }
    75  
    76  type ExtraInfo struct {
    77  	Name              string `json:"name"`
    78  	Description       string `json:"description"`
    79  	RetentionDuration int    `json:"retention_duration"`
    80  }
    81  
    82  type CheckpointResources struct {
    83  	ExtraInfo     string `json:"extra_info"`
    84  	ID            string `json:"id"`
    85  	Name          string `json:"name"`
    86  	ProtectStatus string `json:"protect_status"`
    87  	ResourceSize  string `json:"resource_size"`
    88  	Type          string `json:"type"`
    89  	BackupSize    string `json:"backup_size"`
    90  	BackupCount   string `json:"backup_count"`
    91  }
    92  
    93  type SkippedResources struct {
    94  	ID     string `json:"id"`
    95  	Type   string `json:"type"`
    96  	Name   string `json:"name"`
    97  	Code   string `json:"code"`
    98  	Reason string `json:"reason"`
    99  }