github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/css/v1/snapshots/results.go (about) 1 package snapshots 2 3 import ( 4 "time" 5 6 "github.com/huaweicloud/golangsdk" 7 ) 8 9 // Policy contains all the information associated with a snapshot policy. 10 type Policy struct { 11 KeepDay int `json:"keepday"` 12 Period string `json:"period"` 13 Prefix string `json:"prefix"` 14 Bucket string `json:"bucket"` 15 BasePath string `json:"basePath"` 16 Agency string `json:"agency"` 17 Enable string `json:"enable"` 18 } 19 20 // Snapshot contains all the information associated with a Cluster Snapshot. 21 type Snapshot struct { 22 ID string `json:"id"` 23 Name string `json:"name"` 24 Type string `json:"backupType"` 25 Method string `json:"backupMethod"` 26 Description string `json:"description"` 27 ClusterID string `json:"clusterId"` 28 ClusterName string `json:"clusterName"` 29 Indices string `json:"indices"` 30 TotalShards int `json:"totalShards"` 31 FailedShards int `json:"failedShards"` 32 KeepDays int `json:"backupKeepDay"` 33 Period string `json:"backupPeriod"` 34 Bucket string `json:"bucketName"` 35 Version string `json:"version"` 36 Status string `json:"status"` 37 RestoreStatus string `json:"restoreStatus"` 38 39 // type of the data search engine 40 DataStore DataStore `json:"datastore"` 41 42 // the information about times 43 ExpectedStartTime time.Time `json:"-"` 44 StartTime time.Time `json:"-"` 45 EndTime time.Time `json:"-"` 46 Created string `json:"created"` 47 Updated string `json:"updated"` 48 } 49 50 type DataStore struct { 51 Type string `json:"type"` 52 Version string `json:"version"` 53 } 54 55 type commonResult struct { 56 golangsdk.Result 57 } 58 59 // PolicyResult contains the response body and error from a policy request. 60 type PolicyResult struct { 61 commonResult 62 } 63 64 // CreateResult contains the response body and error from a Create request. 65 type CreateResult struct { 66 commonResult 67 } 68 69 // ListResult contains the response body and error from a List request. 70 type ListResult struct { 71 commonResult 72 } 73 74 // ErrorResult contains the response body and error from a request. 75 type ErrorResult struct { 76 golangsdk.ErrResult 77 } 78 79 // Extract will get the Policy object out of the PolicyResult object. 80 func (r PolicyResult) Extract() (*Policy, error) { 81 var pol Policy 82 err := r.ExtractInto(&pol) 83 return &pol, err 84 } 85 86 // Extract will get the Snapshot object out of the CreateResult object. 87 func (r CreateResult) Extract() (*Snapshot, error) { 88 var s struct { 89 Snapshot *Snapshot `json:"backup"` 90 } 91 err := r.ExtractInto(&s) 92 return s.Snapshot, err 93 } 94 95 // Extract will get all Snapshot objects out of the ListResult object. 96 func (r ListResult) Extract() ([]Snapshot, error) { 97 var s struct { 98 Snapshots []Snapshot `json:"backups"` 99 } 100 err := r.ExtractInto(&s) 101 return s.Snapshots, err 102 }