github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/drs/v2/replications/results.go (about) 1 package replications 2 3 import ( 4 "encoding/json" 5 6 "github.com/huaweicloud/golangsdk" 7 "github.com/huaweicloud/golangsdk/pagination" 8 ) 9 10 // ReplicationCreate response 11 type ReplicationCreate struct { 12 ID string `json:"id"` 13 Name string `json:"name"` 14 Description string `json:"description"` 15 Status string `json:"status"` 16 ReplicationConsistencyGroupID string `json:"replication_consistency_group_id"` 17 VolumeIDs string `json:"volume_ids"` 18 PriorityStation string `json:"priority_station"` 19 CreatedAt string `json:"created_at"` 20 UpdatedAt string `json:"updated_at"` 21 } 22 23 // CreateResult is a struct that contains all the return parameters of creation 24 type CreateResult struct { 25 golangsdk.Result 26 } 27 28 // Extract from CreateResult 29 func (r CreateResult) Extract() (*ReplicationCreate, error) { 30 var s struct { 31 Replication *ReplicationCreate `json:"replication"` 32 } 33 err := r.Result.ExtractInto(&s) 34 return s.Replication, err 35 } 36 37 // DeleteResult is a struct which contains the result of deletion 38 type DeleteResult struct { 39 golangsdk.ErrResult 40 } 41 42 // Replication response 43 type Replication struct { 44 ID string `json:"id"` 45 Name string `json:"name"` 46 Description string `json:"description"` 47 Status string `json:"status"` 48 ReplicationConsistencyGroupID string `json:"replication_consistency_group_id"` 49 VolumeIDs string `json:"volume_ids"` 50 PriorityStation string `json:"priority_station"` 51 CreatedAt string `json:"created_at"` 52 UpdatedAt string `json:"updated_at"` 53 ReplicationModel string `json:"replication_model"` 54 ReplicationStatus string `json:"replication_status"` 55 Progress string `json:"progress"` 56 FailureDetail string `json:"failure_detail"` 57 // RecordMetadata includes volume_type and multiattach currently. 58 RecordMetadata json.RawMessage `json:"record_metadata"` 59 FaultLevel string `json:"fault_level"` 60 } 61 62 // GetResult contains the body of getting detailed 63 type GetResult struct { 64 golangsdk.Result 65 } 66 67 // Extract from GetResult 68 func (r GetResult) Extract() (*Replication, error) { 69 var s struct { 70 Replication *Replication `json:"replication"` 71 } 72 err := r.Result.ExtractInto(&s) 73 return s.Replication, err 74 } 75 76 // ReplicationPage may be embedded in a Page 77 // that contains all of the results from an operation at once. 78 type ReplicationPage struct { 79 pagination.SinglePageBase 80 } 81 82 // IsEmpty returns true if a ListResult contains no replications. 83 func (r ReplicationPage) IsEmpty() (bool, error) { 84 rs, err := ExtractReplications(r) 85 return len(rs) == 0, err 86 } 87 88 // ExtractReplications from List 89 func ExtractReplications(r pagination.Page) ([]Replication, error) { 90 var s struct { 91 Replications []Replication `json:"replications"` 92 } 93 err := (r.(ReplicationPage)).ExtractInto(&s) 94 return s.Replications, err 95 }