github.com/gophercloud/gophercloud@v1.11.0/openstack/blockstorage/extensions/volumeactions/results.go (about)

     1  package volumeactions
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	"github.com/gophercloud/gophercloud"
     8  )
     9  
    10  // AttachResult contains the response body and error from an Attach request.
    11  type AttachResult struct {
    12  	gophercloud.ErrResult
    13  }
    14  
    15  // BeginDetachingResult contains the response body and error from a BeginDetach
    16  // request.
    17  type BeginDetachingResult struct {
    18  	gophercloud.ErrResult
    19  }
    20  
    21  // DetachResult contains the response body and error from a Detach request.
    22  type DetachResult struct {
    23  	gophercloud.ErrResult
    24  }
    25  
    26  // UploadImageResult contains the response body and error from an UploadImage
    27  // request.
    28  type UploadImageResult struct {
    29  	gophercloud.Result
    30  }
    31  
    32  // SetImageMetadataResult contains the response body and error from an SetImageMetadata
    33  // request.
    34  type SetImageMetadataResult struct {
    35  	gophercloud.ErrResult
    36  }
    37  
    38  // SetBootableResult contains the response body and error from a SetBootable
    39  // request.
    40  type SetBootableResult struct {
    41  	gophercloud.ErrResult
    42  }
    43  
    44  // ReserveResult contains the response body and error from a Reserve request.
    45  type ReserveResult struct {
    46  	gophercloud.ErrResult
    47  }
    48  
    49  // UnreserveResult contains the response body and error from an Unreserve
    50  // request.
    51  type UnreserveResult struct {
    52  	gophercloud.ErrResult
    53  }
    54  
    55  // TerminateConnectionResult contains the response body and error from a
    56  // TerminateConnection request.
    57  type TerminateConnectionResult struct {
    58  	gophercloud.ErrResult
    59  }
    60  
    61  // InitializeConnectionResult contains the response body and error from an
    62  // InitializeConnection request.
    63  type InitializeConnectionResult struct {
    64  	gophercloud.Result
    65  }
    66  
    67  // ExtendSizeResult contains the response body and error from an ExtendSize request.
    68  type ExtendSizeResult struct {
    69  	gophercloud.ErrResult
    70  }
    71  
    72  // Extract will get the connection information out of the
    73  // InitializeConnectionResult object.
    74  //
    75  // This will be a generic map[string]interface{} and the results will be
    76  // dependent on the type of connection made.
    77  func (r InitializeConnectionResult) Extract() (map[string]interface{}, error) {
    78  	var s struct {
    79  		ConnectionInfo map[string]interface{} `json:"connection_info"`
    80  	}
    81  	err := r.ExtractInto(&s)
    82  	return s.ConnectionInfo, err
    83  }
    84  
    85  // ImageVolumeType contains volume type information obtained from UploadImage
    86  // action.
    87  type ImageVolumeType struct {
    88  	// The ID of a volume type.
    89  	ID string `json:"id"`
    90  
    91  	// Human-readable display name for the volume type.
    92  	Name string `json:"name"`
    93  
    94  	// Human-readable description for the volume type.
    95  	Description string `json:"display_description"`
    96  
    97  	// Flag for public access.
    98  	IsPublic bool `json:"is_public"`
    99  
   100  	// Extra specifications for volume type.
   101  	ExtraSpecs map[string]interface{} `json:"extra_specs"`
   102  
   103  	// ID of quality of service specs.
   104  	QosSpecsID string `json:"qos_specs_id"`
   105  
   106  	// Flag for deletion status of volume type.
   107  	Deleted bool `json:"deleted"`
   108  
   109  	// The date when volume type was deleted.
   110  	DeletedAt time.Time `json:"-"`
   111  
   112  	// The date when volume type was created.
   113  	CreatedAt time.Time `json:"-"`
   114  
   115  	// The date when this volume was last updated.
   116  	UpdatedAt time.Time `json:"-"`
   117  }
   118  
   119  func (r *ImageVolumeType) UnmarshalJSON(b []byte) error {
   120  	type tmp ImageVolumeType
   121  	var s struct {
   122  		tmp
   123  		CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
   124  		UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
   125  		DeletedAt gophercloud.JSONRFC3339MilliNoZ `json:"deleted_at"`
   126  	}
   127  	err := json.Unmarshal(b, &s)
   128  	if err != nil {
   129  		return err
   130  	}
   131  	*r = ImageVolumeType(s.tmp)
   132  
   133  	r.CreatedAt = time.Time(s.CreatedAt)
   134  	r.UpdatedAt = time.Time(s.UpdatedAt)
   135  	r.DeletedAt = time.Time(s.DeletedAt)
   136  
   137  	return err
   138  }
   139  
   140  // VolumeImage contains information about volume uploaded to an image service.
   141  type VolumeImage struct {
   142  	// The ID of a volume an image is created from.
   143  	VolumeID string `json:"id"`
   144  
   145  	// Container format, may be bare, ofv, ova, etc.
   146  	ContainerFormat string `json:"container_format"`
   147  
   148  	// Disk format, may be raw, qcow2, vhd, vdi, vmdk, etc.
   149  	DiskFormat string `json:"disk_format"`
   150  
   151  	// Human-readable description for the volume.
   152  	Description string `json:"display_description"`
   153  
   154  	// The ID of the created image.
   155  	ImageID string `json:"image_id"`
   156  
   157  	// Human-readable display name for the image.
   158  	ImageName string `json:"image_name"`
   159  
   160  	// Size of the volume in GB.
   161  	Size int `json:"size"`
   162  
   163  	// Current status of the volume.
   164  	Status string `json:"status"`
   165  
   166  	// Visibility defines who can see/use the image.
   167  	// supported since 3.1 microversion
   168  	Visibility string `json:"visibility"`
   169  
   170  	// whether the image is not deletable.
   171  	// supported since 3.1 microversion
   172  	Protected bool `json:"protected"`
   173  
   174  	// The date when this volume was last updated.
   175  	UpdatedAt time.Time `json:"-"`
   176  
   177  	// Volume type object of used volume.
   178  	VolumeType ImageVolumeType `json:"volume_type"`
   179  }
   180  
   181  func (r *VolumeImage) UnmarshalJSON(b []byte) error {
   182  	type tmp VolumeImage
   183  	var s struct {
   184  		tmp
   185  		UpdatedAt gophercloud.JSONRFC3339MilliNoZ `json:"updated_at"`
   186  	}
   187  	err := json.Unmarshal(b, &s)
   188  	if err != nil {
   189  		return err
   190  	}
   191  	*r = VolumeImage(s.tmp)
   192  
   193  	r.UpdatedAt = time.Time(s.UpdatedAt)
   194  
   195  	return err
   196  }
   197  
   198  // Extract will get an object with info about the uploaded image out of the
   199  // UploadImageResult object.
   200  func (r UploadImageResult) Extract() (VolumeImage, error) {
   201  	var s struct {
   202  		VolumeImage VolumeImage `json:"os-volume_upload_image"`
   203  	}
   204  	err := r.ExtractInto(&s)
   205  	return s.VolumeImage, err
   206  }
   207  
   208  // ForceDeleteResult contains the response body and error from a ForceDelete request.
   209  type ForceDeleteResult struct {
   210  	gophercloud.ErrResult
   211  }
   212  
   213  // ChangeTypeResult contains the response body and error from an ChangeType request.
   214  type ChangeTypeResult struct {
   215  	gophercloud.ErrResult
   216  }
   217  
   218  // ReImageResult contains the response body and error from a ReImage request.
   219  type ReImageResult struct {
   220  	gophercloud.ErrResult
   221  }
   222  
   223  // ResetStatusResult contains the response error from a ResetStatus request.
   224  type ResetStatusResult struct {
   225  	gophercloud.ErrResult
   226  }