github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/v1/snapshots/results.go (about) 1 package snapshots 2 3 import ( 4 "encoding/json" 5 "time" 6 7 "github.com/opentelekomcloud/gophertelekomcloud" 8 ) 9 10 type Snapshot struct { 11 // Current status of the Snapshot. 12 Status string `json:"status"` 13 // Display name. 14 Name string `json:"display_name"` 15 // Instances onto which the Snapshot is attached. 16 Attachments []string `json:"attachments"` 17 // Logical group. 18 AvailabilityZone string `json:"availability_zone"` 19 // Is the Snapshot bootable? 20 Bootable string `json:"bootable"` 21 // Date created. 22 CreatedAt time.Time `json:"-"` 23 // Display description. 24 Description string `json:"display_description"` 25 // See VolumeType object for more information. 26 VolumeType string `json:"volume_type"` 27 // ID of the Snapshot from which this Snapshot was created. 28 SnapshotID string `json:"snapshot_id"` 29 // ID of the Volume from which this Snapshot was created. 30 VolumeID string `json:"volume_id"` 31 // User-defined key-value pairs. 32 Metadata map[string]string `json:"metadata"` 33 // Unique identifier. 34 ID string `json:"id"` 35 // Size of the Snapshot, in GB. 36 Size int `json:"size"` 37 } 38 39 func (r *Snapshot) UnmarshalJSON(b []byte) error { 40 type tmp Snapshot 41 var s struct { 42 tmp 43 CreatedAt golangsdk.JSONRFC3339MilliNoZ `json:"created_at"` 44 } 45 err := json.Unmarshal(b, &s) 46 if err != nil { 47 return err 48 } 49 *r = Snapshot(s.tmp) 50 51 r.CreatedAt = time.Time(s.CreatedAt) 52 53 return err 54 }