github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/v1/volumes/results.go (about)

     1  package volumes
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	"github.com/opentelekomcloud/gophertelekomcloud"
     8  )
     9  
    10  type Volume struct {
    11  	// Current status of the volume.
    12  	Status string `json:"status"`
    13  	// Human-readable display name for the volume.
    14  	Name string `json:"display_name"`
    15  	// Instances onto which the volume is attached.
    16  	Attachments []map[string]interface{} `json:"attachments"`
    17  	// This parameter is no longer used.
    18  	AvailabilityZone string `json:"availability_zone"`
    19  	// Indicates whether this is a bootable volume.
    20  	Bootable string `json:"bootable"`
    21  	// The date when this volume was created.
    22  	CreatedAt time.Time `json:"-"`
    23  	// Human-readable description for the volume.
    24  	Description string `json:"display_description"`
    25  	// The type of volume to create, either SATA or SSD.
    26  	VolumeType string `json:"volume_type"`
    27  	// The ID of the snapshot from which the volume was created
    28  	SnapshotID string `json:"snapshot_id"`
    29  	// The ID of another block storage volume from which the current volume was created
    30  	SourceVolID string `json:"source_volid"`
    31  	// Arbitrary key-value pairs defined by the user.
    32  	Metadata map[string]string `json:"metadata"`
    33  	// Unique identifier for the volume.
    34  	ID string `json:"id"`
    35  	// Size of the volume in GB.
    36  	Size int `json:"size"`
    37  }
    38  
    39  func (r *Volume) UnmarshalJSON(b []byte) error {
    40  	type tmp Volume
    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 = Volume(s.tmp)
    50  
    51  	r.CreatedAt = time.Time(s.CreatedAt)
    52  
    53  	return err
    54  }