1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the LGPLv3, see LICENCE file for details.
4
// This file was initially autogenerated from the upstream wadl file, but has
5
// since been updated by hand.
6
// The WADLs were originally sourced from:
7
// https://github.com/openstack/api-site/tree/master/api-ref/src/wadls/volume-api/src/v2
20
// RequestHandlerFn specifies a function signature which wadl2go will
21
// use to process the http.Request. What this means is up to the
23
type RequestHandlerFn func(*http.Request) (*http.Response, error)
25
type UpdateVolumeTypeParams struct {
27
// VolumeType is required.
29
// A volume type offers a way to categorize or group volumes.
30
VolumeType string `json:"volume_type"`
33
// The unique identifier of the tenant or account.
34
TenantId string `json:"-"`
36
// VolumeTypeId is required.
38
// The unique identifier for an existing volume type.
39
VolumeTypeId string `json:"-"`
42
type VolumeType struct {
44
Capabilities string `json:"capabilities"`
45
} `json:"extra_specs"`
47
Name string `json:"name"`
50
type UpdateVolumeTypeResults struct {
51
VolumeType VolumeType `json:"volume_type"`
55
// Updates a volume type.
56
func updateVolumeType(client *Client, args UpdateVolumeTypeParams) (*UpdateVolumeTypeResults, error) {
58
argsAsJson, err := json.Marshal(args)
63
urlPath := url.URL{Path: fmt.Sprintf("types/%s", args.VolumeTypeId)}
64
url := client.endpoint.ResolveReference(&urlPath).String()
67
if string(argsAsJson) != "{}" {
68
req, err = http.NewRequest("PUT", url, bytes.NewBuffer(argsAsJson))
72
req.Header.Set("Content-Type", "application/json")
74
req, err = http.NewRequest("PUT", url, nil)
80
resp, err := client.handleRequest(req)
85
body, err := ioutil.ReadAll(resp.Body)
90
switch resp.StatusCode {
92
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
97
var results UpdateVolumeTypeResults
98
json.Unmarshal(body, &results)
103
type UpdateVolumeTypeExtraSpecsParams struct {
105
// VolumeType is required.
107
// A volume type offers a way to categorize or group volumes.
108
VolumeType string `json:"volume_type"`
110
// ExtraSpecs is required.
112
// A key:value pair that offers a way to show additional specifications associated with the volume type. Examples include capabilities, capacity, compression, and so on, depending on the storage driver in use.
113
ExtraSpecs string `json:"extra_specs"`
116
// The unique identifier of the tenant or account.
117
TenantId string `json:"-"`
119
// VolumeTypeId is required.
121
// The unique identifier for an existing volume type.
122
VolumeTypeId string `json:"-"`
125
type UpdateVolumeTypeExtraSpecsResults struct {
126
VolumeType VolumeType `json:"volume_type"`
130
// Updates the extra specifications assigned to a volume type.
131
func updateVolumeTypeExtraSpecs(client *Client, args UpdateVolumeTypeExtraSpecsParams) (*UpdateVolumeTypeExtraSpecsResults, error) {
133
argsAsJson, err := json.Marshal(args)
138
urlPath := url.URL{Path: fmt.Sprintf("types/%s", args.VolumeTypeId)}
139
url := client.endpoint.ResolveReference(&urlPath).String()
141
var req *http.Request
142
if string(argsAsJson) != "{}" {
143
req, err = http.NewRequest("PUT", url, bytes.NewBuffer(argsAsJson))
147
req.Header.Set("Content-Type", "application/json")
149
req, err = http.NewRequest("PUT", url, nil)
155
resp, err := client.handleRequest(req)
160
body, err := ioutil.ReadAll(resp.Body)
165
switch resp.StatusCode {
167
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
172
var results UpdateVolumeTypeExtraSpecsResults
173
json.Unmarshal(body, &results)
178
type GetSnapshotsSimpleParams struct {
181
// The unique identifier of the tenant or account.
182
TenantId string `json:"-"`
185
type Snapshot struct {
186
CreatedAt string `json:"created_at"`
187
Description string `json:"description"`
188
ID string `json:"id"`
190
Key string `json:"key"`
192
Name string `json:"name"`
193
Size int `json:"size"`
194
Status string `json:"status"`
195
VolumeID string `json:"volume_id"`
196
Os_Extended_Snapshot_Attributes_Progress string `json:"os-extended-snapshot-attributes:progress"`
197
Os_Extended_Snapshot_Attributes_ProjectID string `json:"os-extended-snapshot-attributes:project_id"`
200
type GetSnapshotsSimpleResults struct {
201
Snapshots []Snapshot `json:"snapshots"`
205
// Lists summary information for all Block Storage snapshots that the tenant who submits the request can access.
206
func getSnapshotsSimple(client *Client, args GetSnapshotsSimpleParams) (*GetSnapshotsSimpleResults, error) {
208
argsAsJson, err := json.Marshal(args)
213
urlPath := url.URL{Path: "snapshots"}
214
url := client.endpoint.ResolveReference(&urlPath).String()
216
var req *http.Request
217
if string(argsAsJson) != "{}" {
218
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
222
req.Header.Set("Content-Type", "application/json")
224
req, err = http.NewRequest("GET", url, nil)
230
resp, err := client.handleRequest(req)
235
body, err := ioutil.ReadAll(resp.Body)
240
switch resp.StatusCode {
242
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
247
var results GetSnapshotsSimpleResults
248
json.Unmarshal(body, &results)
253
type UpdateSnapshotSnapshotParams struct {
255
// Describes the snapshot.
256
Description string `json:"description,omitempty"`
258
// The name of the snapshot.
259
Name string `json:"name,omitempty"`
262
type UpdateSnapshotParams struct {
264
// Snapshot is required.
266
Snapshot UpdateSnapshotSnapshotParams `json:"snapshot"`
269
// The unique identifier of the tenant or account.
270
TenantId string `json:"-"`
272
// SnapshotId is required.
274
// The unique identifier of an existing snapshot.
275
SnapshotId string `json:"-"`
278
type UpdateSnapshotResults struct {
279
Snapshot Snapshot `json:"snapshot"`
283
// Updates a specified snapshot.
284
func updateSnapshot(client *Client, args UpdateSnapshotParams) (*UpdateSnapshotResults, error) {
286
argsAsJson, err := json.Marshal(args)
291
urlPath := url.URL{Path: fmt.Sprintf("snapshots/%s", args.SnapshotId)}
292
url := client.endpoint.ResolveReference(&urlPath).String()
294
var req *http.Request
295
if string(argsAsJson) != "{}" {
296
req, err = http.NewRequest("PUT", url, bytes.NewBuffer(argsAsJson))
300
req.Header.Set("Content-Type", "application/json")
302
req, err = http.NewRequest("PUT", url, nil)
308
resp, err := client.handleRequest(req)
313
body, err := ioutil.ReadAll(resp.Body)
318
switch resp.StatusCode {
320
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
325
var results UpdateSnapshotResults
326
json.Unmarshal(body, &results)
331
type ShowSnapshotMetadataParams struct {
334
// The unique identifier of the tenant or account.
335
TenantId string `json:"-"`
337
// SnapshotId is required.
339
// The unique identifier of an existing snapshot.
340
SnapshotId string `json:"-"`
343
type ShowSnapshotMetadataResults struct {
344
Snapshot Snapshot `json:"snapshot"`
348
// Shows the metadata for a specified snapshot.
349
func showSnapshotMetadata(client *Client, args ShowSnapshotMetadataParams) (*ShowSnapshotMetadataResults, error) {
351
argsAsJson, err := json.Marshal(args)
356
urlPath := url.URL{Path: fmt.Sprintf("snapshots/%s/metadata", args.SnapshotId)}
357
url := client.endpoint.ResolveReference(&urlPath).String()
359
var req *http.Request
360
if string(argsAsJson) != "{}" {
361
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
365
req.Header.Set("Content-Type", "application/json")
367
req, err = http.NewRequest("GET", url, nil)
373
resp, err := client.handleRequest(req)
378
body, err := ioutil.ReadAll(resp.Body)
383
switch resp.StatusCode {
385
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
390
var results ShowSnapshotMetadataResults
391
json.Unmarshal(body, &results)
396
type GetVolumesDetailParams struct {
399
// The unique identifier of the tenant or account.
400
TenantId string `json:"-"`
403
type VolumeAttachment struct {
404
Device string `json:"device"`
405
Id string `json:"id"`
406
ServerId string `json:"server_id"`
407
VolumeId string `json:"volume_id"`
411
Attachments []VolumeAttachment `json:"attachments"`
412
AvailabilityZone string `json:"availability_zone"`
413
Bootable string `json:"bootable"`
414
CreatedAt string `json:"created_at"`
415
Description string `json:"description"`
416
ID string `json:"id"`
418
Href string `json:"href"`
419
Rel string `json:"rel"`
421
Metadata map[string]string `json:"metadata"`
422
Name string `json:"name"`
423
Os_Vol_Host_Attr_Host string `json:"os-vol-host-attr:host"`
424
Os_Vol_Tenant_Attr_TenantID string `json:"os-vol-tenant-attr:tenant_id"`
425
Size int `json:"size"`
426
SnapshotID interface{} `json:"snapshot_id"`
427
SourceVolid interface{} `json:"source_volid"`
428
Status string `json:"status"`
429
VolumeType string `json:"volume_type"`
432
type GetVolumesDetailResults struct {
433
Volumes []Volume `json:"volumes"`
437
// Lists detailed information for all Block Storage volumes that the tenant who submits the request can access.
438
func getVolumesDetail(client *Client, args GetVolumesDetailParams) (*GetVolumesDetailResults, error) {
440
argsAsJson, err := json.Marshal(args)
445
urlPath := url.URL{Path: "volumes/detail"}
446
url := client.endpoint.ResolveReference(&urlPath).String()
448
var req *http.Request
449
if string(argsAsJson) != "{}" {
450
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
454
req.Header.Set("Content-Type", "application/json")
456
req, err = http.NewRequest("GET", url, nil)
462
resp, err := client.handleRequest(req)
467
body, err := ioutil.ReadAll(resp.Body)
472
switch resp.StatusCode {
474
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
479
var results GetVolumesDetailResults
480
json.Unmarshal(body, &results)
485
type GetVolumeParams struct {
488
// The unique identifier of the tenant or account.
489
TenantId string `json:"-"`
491
// VolumeId is required.
493
// The unique identifier of an existing volume.
494
VolumeId string `json:"-"`
497
type GetVolumeResults struct {
498
Volume Volume `json:"volume"`
502
// Shows information about a specified volume.
505
// The specified volume must exist. :
506
func getVolume(client *Client, args GetVolumeParams) (*GetVolumeResults, error) {
508
argsAsJson, err := json.Marshal(args)
513
urlPath := url.URL{Path: fmt.Sprintf("volumes/%s", args.VolumeId)}
514
url := client.endpoint.ResolveReference(&urlPath).String()
516
var req *http.Request
517
if string(argsAsJson) != "{}" {
518
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
522
req.Header.Set("Content-Type", "application/json")
524
req, err = http.NewRequest("GET", url, nil)
530
resp, err := client.handleRequest(req)
535
body, err := ioutil.ReadAll(resp.Body)
540
switch resp.StatusCode {
542
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
547
var results GetVolumeResults
548
json.Unmarshal(body, &results)
553
type UpdateVolumeVolumeParams struct {
554
Name string `json:"name,omitempty"`
556
Description string `json:"description,omitempty"`
559
type UpdateVolumeParams struct {
561
// Volume is required.
563
Volume UpdateVolumeVolumeParams `json:"volume"`
566
// The unique identifier of the tenant or account.
567
TenantId string `json:"-"`
569
// VolumeId is required.
571
// The unique identifier of an existing volume.
572
VolumeId string `json:"-"`
575
type UpdateVolumeResults struct {
576
Volume Volume `json:"volume"`
581
func updateVolume(client *Client, args UpdateVolumeParams) (*UpdateVolumeResults, error) {
583
argsAsJson, err := json.Marshal(args)
588
urlPath := url.URL{Path: fmt.Sprintf("volumes/%s", args.VolumeId)}
589
url := client.endpoint.ResolveReference(&urlPath).String()
591
var req *http.Request
592
if string(argsAsJson) != "{}" {
593
req, err = http.NewRequest("PUT", url, bytes.NewBuffer(argsAsJson))
597
req.Header.Set("Content-Type", "application/json")
599
req, err = http.NewRequest("PUT", url, nil)
605
resp, err := client.handleRequest(req)
610
body, err := ioutil.ReadAll(resp.Body)
615
switch resp.StatusCode {
617
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
622
var results UpdateVolumeResults
623
json.Unmarshal(body, &results)
628
type DeleteVolumeParams struct {
631
// The unique identifier of the tenant or account.
632
TenantId string `json:"-"`
634
// VolumeId is required.
636
// The unique identifier of an existing volume.
637
VolumeId string `json:"-"`
640
type DeleteVolumeResults struct {
644
// Deletes a specified volume.
647
// Volume status must be available, in-use, error, or error_restoring.
648
// You cannot already have a snapshot related to the specified volume.
649
// You cannot delete a volume that is in a migration. :
650
// Asynchronous Postconditions
652
// The volume is deleted in volume index.
653
// The volume managed by OpenStack Block Storage is deleted in storage node. :
656
// If volume status remains in deleting or becomes error_deleting the request failed. Ensure you meet the preconditions then investigate the storage backend.
657
// The volume managed by OpenStack Block Storage is not deleted from the storage system. :
658
func deleteVolume(client *Client, args DeleteVolumeParams) (*DeleteVolumeResults, error) {
660
argsAsJson, err := json.Marshal(args)
665
urlPath := url.URL{Path: fmt.Sprintf("volumes/%s", args.VolumeId)}
666
url := client.endpoint.ResolveReference(&urlPath).String()
668
var req *http.Request
669
if string(argsAsJson) != "{}" {
670
req, err = http.NewRequest("DELETE", url, bytes.NewBuffer(argsAsJson))
674
req.Header.Set("Content-Type", "application/json")
676
req, err = http.NewRequest("DELETE", url, nil)
682
resp, err := client.handleRequest(req)
687
body, err := ioutil.ReadAll(resp.Body)
692
switch resp.StatusCode {
694
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
699
var results DeleteVolumeResults
700
json.Unmarshal(body, &results)
705
type CreateVolumeTypeVolumeTypeExtraSpecsParams struct {
706
Capabilities string `json:"capabilities,omitempty"`
709
type CreateVolumeTypeVolumeTypeParams struct {
711
// The name of the volume type.
712
Name string `json:"name,omitempty"`
714
ExtraSpecs CreateVolumeTypeVolumeTypeExtraSpecsParams `json:"extra_specs,omitempty"`
717
type CreateVolumeTypeParams struct {
719
// VolumeType is required.
720
// A partial representation of a volume type used in the creation process.
721
VolumeType CreateVolumeTypeVolumeTypeParams `json:"volume_type"`
724
// The unique identifier of the tenant or account.
725
TenantId string `json:"-"`
728
type CreateVolumeTypeResults struct {
729
VolumeType VolumeType `json:"volume_type"`
733
// Creates a volume type.
734
func createVolumeType(client *Client, args CreateVolumeTypeParams) (*CreateVolumeTypeResults, error) {
736
argsAsJson, err := json.Marshal(args)
741
urlPath := url.URL{Path: "types"}
742
url := client.endpoint.ResolveReference(&urlPath).String()
744
var req *http.Request
745
if string(argsAsJson) != "{}" {
746
req, err = http.NewRequest("POST", url, bytes.NewBuffer(argsAsJson))
750
req.Header.Set("Content-Type", "application/json")
752
req, err = http.NewRequest("POST", url, nil)
758
resp, err := client.handleRequest(req)
763
body, err := ioutil.ReadAll(resp.Body)
768
switch resp.StatusCode {
770
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
775
var results CreateVolumeTypeResults
776
json.Unmarshal(body, &results)
781
type CreateSnapshotSnapshotParams struct {
783
// [True/False] Indicate whether to snapshot, even if the volume is attached. Default==False.
784
Force bool `json:"force,omitempty"`
786
// Name of the snapshot. The default is None.
787
Name string `json:"name,omitempty"`
789
// Description of the snapshot. The default is None.
790
Description string `json:"description,omitempty"`
792
// VolumeId is required.
793
// To create a snapshot from an existing volume, specify the ID of the existing volume.
794
VolumeId string `json:"volume_id"`
797
type CreateSnapshotParams struct {
799
// Snapshot is required.
800
// A partial representation of a snapshot used in the creation process.
801
Snapshot CreateSnapshotSnapshotParams `json:"snapshot"`
804
// The unique identifier of the tenant or account.
805
TenantId string `json:"-"`
808
type CreateSnapshotResults struct {
809
Snapshot Snapshot `json:"snapshot"`
813
// Creates a snapshot, which is a point-in-time complete copy of a volume. You can create a volume from the snapshot.
814
func createSnapshot(client *Client, args CreateSnapshotParams) (*CreateSnapshotResults, error) {
816
argsAsJson, err := json.Marshal(args)
821
urlPath := url.URL{Path: "snapshots"}
822
url := client.endpoint.ResolveReference(&urlPath).String()
824
var req *http.Request
825
if string(argsAsJson) != "{}" {
826
req, err = http.NewRequest("POST", url, bytes.NewBuffer(argsAsJson))
830
req.Header.Set("Content-Type", "application/json")
832
req, err = http.NewRequest("POST", url, nil)
838
resp, err := client.handleRequest(req)
843
body, err := ioutil.ReadAll(resp.Body)
848
switch resp.StatusCode {
850
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
855
var results CreateSnapshotResults
856
json.Unmarshal(body, &results)
861
type GetSnapshotsDetailParams struct {
864
// The unique identifier of the tenant or account.
865
TenantId string `json:"-"`
868
type GetSnapshotsDetailResults struct {
869
Snapshots []Snapshot `json:"snapshots"`
873
// Lists detailed information for all Block Storage snapshots that the tenant who submits the request can access.
874
func getSnapshotsDetail(client *Client, args GetSnapshotsDetailParams) (*GetSnapshotsDetailResults, error) {
876
argsAsJson, err := json.Marshal(args)
881
urlPath := url.URL{Path: "snapshots/detail"}
882
url := client.endpoint.ResolveReference(&urlPath).String()
884
var req *http.Request
885
if string(argsAsJson) != "{}" {
886
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
890
req.Header.Set("Content-Type", "application/json")
892
req, err = http.NewRequest("GET", url, nil)
898
resp, err := client.handleRequest(req)
903
body, err := ioutil.ReadAll(resp.Body)
908
switch resp.StatusCode {
910
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
915
var results GetSnapshotsDetailResults
916
json.Unmarshal(body, &results)
921
type GetSnapshotParams struct {
924
// The unique identifier of the tenant or account.
925
TenantId string `json:"-"`
927
// SnapshotId is required.
929
// The unique identifier of an existing snapshot.
930
SnapshotId string `json:"-"`
933
type GetSnapshotResults struct {
934
Snapshot Snapshot `json:"snapshot"`
938
// Shows information for a specified snapshot.
939
func getSnapshot(client *Client, args GetSnapshotParams) (*GetSnapshotResults, error) {
941
argsAsJson, err := json.Marshal(args)
946
urlPath := url.URL{Path: fmt.Sprintf("snapshots/%s", args.SnapshotId)}
947
url := client.endpoint.ResolveReference(&urlPath).String()
949
var req *http.Request
950
if string(argsAsJson) != "{}" {
951
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
955
req.Header.Set("Content-Type", "application/json")
957
req, err = http.NewRequest("GET", url, nil)
963
resp, err := client.handleRequest(req)
968
body, err := ioutil.ReadAll(resp.Body)
973
switch resp.StatusCode {
975
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
980
var results GetSnapshotResults
981
json.Unmarshal(body, &results)
986
type ListVersionsParams struct {
989
type Version struct {
990
ID string `json:"id"`
992
Href string `json:"href"`
993
Rel string `json:"rel"`
995
Media_Types []struct {
996
Base string `json:"base"`
997
Type string `json:"type"`
998
} `json:"media-types"`
999
Status string `json:"status"`
1000
Updated string `json:"updated"`
1003
type ListVersionsResults struct {
1004
Versions []Version `json:"versions"`
1008
// Lists information about all Block Storage API versions.
1009
func listVersions(client *Client, args ListVersionsParams) (*ListVersionsResults, error) {
1011
argsAsJson, err := json.Marshal(args)
1016
urlPath := url.URL{Path: "../.."}
1017
url := client.endpoint.ResolveReference(&urlPath).String()
1019
var req *http.Request
1020
if string(argsAsJson) != "{}" {
1021
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1025
req.Header.Set("Content-Type", "application/json")
1027
req, err = http.NewRequest("GET", url, nil)
1033
resp, err := client.handleRequest(req)
1038
body, err := ioutil.ReadAll(resp.Body)
1043
switch resp.StatusCode {
1045
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1050
var results ListVersionsResults
1051
json.Unmarshal(body, &results)
1053
return &results, nil
1056
type VersionDetailsParams struct {
1059
type VersionDetailsResults struct {
1060
Version Version `json:"version"`
1064
// Shows details for Block Storage API v2.
1065
func versionDetails(client *Client, args VersionDetailsParams) (*VersionDetailsResults, error) {
1067
argsAsJson, err := json.Marshal(args)
1072
urlPath := url.URL{Path: ".."}
1073
url := client.endpoint.ResolveReference(&urlPath).String()
1075
var req *http.Request
1076
if string(argsAsJson) != "{}" {
1077
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1081
req.Header.Set("Content-Type", "application/json")
1083
req, err = http.NewRequest("GET", url, nil)
1089
resp, err := client.handleRequest(req)
1094
body, err := ioutil.ReadAll(resp.Body)
1099
switch resp.StatusCode {
1101
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1106
var results VersionDetailsResults
1107
json.Unmarshal(body, &results)
1109
return &results, nil
1112
type CreateVolumeVolumeParams struct {
1114
// To create a volume from an existing volume, specify the ID of the existing volume. If specified, the volume is created with same size of the source volume.
1115
SourceVolid string `json:"source_volid,omitempty"`
1117
// To create a volume from an existing snapshot, specify the ID of the existing volume snapshot. If specified, the volume is created in same availability zone and with same size of the snapshot.
1118
SnapshotId string `json:"snapshot_id,omitempty"`
1120
// The ID of the image from which you want to create the volume. Required to create a bootable volume.
1121
ImageRef string `json:"imageRef,omitempty"`
1123
// The associated volume type.
1124
VolumeType string `json:"volume_type,omitempty"`
1126
// Enables or disables the bootable attribute. You can boot an instance from a bootable volume.
1127
Bootable bool `json:"bootable,omitempty"`
1129
// One or more metadata key and value pairs to associate with the volume.
1130
Metadata interface{} `json:"metadata,omitempty"`
1132
// The availability zone.
1133
AvailabilityZone string `json:"availability_zone,omitempty"`
1135
// The volume description.
1136
Description string `json:"description,omitempty"`
1138
// Size is required.
1139
// The size of the volume, in GBs.
1140
Size int `json:"size"`
1143
Name string `json:"name,omitempty"`
1146
type CreateVolumeParams struct {
1148
// Volume is required.
1150
Volume CreateVolumeVolumeParams `json:"volume"`
1153
// The unique identifier of the tenant or account.
1154
TenantId string `json:"-"`
1157
type CreateVolumeResults struct {
1158
Volume Volume `json:"volume"`
1162
// Creates a volume.
1163
// To create a bootable volume, include the image ID and set the bootable flag to true in the request body.
1166
// The user must have enough volume storage quota remaining to create a volume of size requested. :
1167
// Asynchronous Postconditions
1169
// With correct permissions, you can see the volume status as available through API calls.
1170
// With correct access, you can see the created volume in the storage system that OpenStack Block Storage manages. :
1173
// If volume status remains creating or shows another error status, the request failed. Ensure you meet the preconditions then investigate the storage backend.
1174
// Volume is not created in the storage system which OpenStack Block Storage manages.
1175
// The storage node needs enough free storage space to match the specified size of the volume creation request. :
1176
func createVolume(client *Client, args CreateVolumeParams) (*CreateVolumeResults, error) {
1178
argsAsJson, err := json.Marshal(args)
1183
urlPath := url.URL{Path: "volumes"}
1184
url := client.endpoint.ResolveReference(&urlPath).String()
1186
var req *http.Request
1187
if string(argsAsJson) != "{}" {
1188
req, err = http.NewRequest("POST", url, bytes.NewBuffer(argsAsJson))
1192
req.Header.Set("Content-Type", "application/json")
1194
req, err = http.NewRequest("POST", url, nil)
1200
resp, err := client.handleRequest(req)
1205
body, err := ioutil.ReadAll(resp.Body)
1210
switch resp.StatusCode {
1212
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1217
var results CreateVolumeResults
1218
json.Unmarshal(body, &results)
1220
return &results, nil
1223
type GetVolumesSimpleParams struct {
1226
// The unique identifier of the tenant or account.
1227
TenantId string `json:"-"`
1230
type GetVolumesSimpleResults struct {
1231
Volumes []Volume `json:"volumes"`
1235
// Lists summary information for all Block Storage volumes that the tenant who submits the request can access.
1236
func getVolumesSimple(client *Client, args GetVolumesSimpleParams) (*GetVolumesSimpleResults, error) {
1238
argsAsJson, err := json.Marshal(args)
1243
urlPath := url.URL{Path: "volumes"}
1244
url := client.endpoint.ResolveReference(&urlPath).String()
1246
var req *http.Request
1247
if string(argsAsJson) != "{}" {
1248
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1252
req.Header.Set("Content-Type", "application/json")
1254
req, err = http.NewRequest("GET", url, nil)
1260
resp, err := client.handleRequest(req)
1265
body, err := ioutil.ReadAll(resp.Body)
1270
switch resp.StatusCode {
1272
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1277
var results GetVolumesSimpleResults
1278
json.Unmarshal(body, &results)
1280
return &results, nil
1283
type GetVolumeTypeParams struct {
1286
// The unique identifier of the tenant or account.
1287
TenantId string `json:"-"`
1289
// VolumeTypeId is required.
1291
// The unique identifier for an existing volume type.
1292
VolumeTypeId string `json:"-"`
1295
type GetVolumeTypeResults struct {
1296
VolumeType VolumeType `json:"volume_type"`
1300
// Shows information about a specified volume type.
1301
func getVolumeType(client *Client, args GetVolumeTypeParams) (*GetVolumeTypeResults, error) {
1303
argsAsJson, err := json.Marshal(args)
1308
urlPath := url.URL{Path: fmt.Sprintf("types/%s", args.VolumeTypeId)}
1309
url := client.endpoint.ResolveReference(&urlPath).String()
1311
var req *http.Request
1312
if string(argsAsJson) != "{}" {
1313
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1317
req.Header.Set("Content-Type", "application/json")
1319
req, err = http.NewRequest("GET", url, nil)
1325
resp, err := client.handleRequest(req)
1330
body, err := ioutil.ReadAll(resp.Body)
1335
switch resp.StatusCode {
1337
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1342
var results GetVolumeTypeResults
1343
json.Unmarshal(body, &results)
1345
return &results, nil
1348
type DeleteSnapshotParams struct {
1351
// The unique identifier of the tenant or account.
1352
TenantId string `json:"-"`
1354
// SnapshotId is required.
1356
// The unique identifier of an existing snapshot.
1357
SnapshotId string `json:"-"`
1360
type DeleteSnapshotResults struct {
1364
// Deletes a specified snapshot.
1365
func deleteSnapshot(client *Client, args DeleteSnapshotParams) (*DeleteSnapshotResults, error) {
1367
argsAsJson, err := json.Marshal(args)
1372
urlPath := url.URL{Path: fmt.Sprintf("snapshots/%s", args.SnapshotId)}
1373
url := client.endpoint.ResolveReference(&urlPath).String()
1375
var req *http.Request
1376
if string(argsAsJson) != "{}" {
1377
req, err = http.NewRequest("DELETE", url, bytes.NewBuffer(argsAsJson))
1381
req.Header.Set("Content-Type", "application/json")
1383
req, err = http.NewRequest("DELETE", url, nil)
1389
resp, err := client.handleRequest(req)
1394
body, err := ioutil.ReadAll(resp.Body)
1399
switch resp.StatusCode {
1401
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1406
var results DeleteSnapshotResults
1407
json.Unmarshal(body, &results)
1409
return &results, nil
1412
type ListExtensionsCinderV2Params struct {
1415
type Extension struct {
1416
Alias string `json:"alias"`
1417
Description string `json:"description"`
1418
Links []interface{} `json:"links"`
1419
Name string `json:"name"`
1420
Namespace string `json:"namespace"`
1421
Updated string `json:"updated"`
1424
type ListExtensionsCinderV2Results struct {
1425
Extensions []Extension `json:"extensions"`
1429
// Lists Block Storage API extensions.
1430
func listExtensionsCinderV2(client *Client, args ListExtensionsCinderV2Params) (*ListExtensionsCinderV2Results, error) {
1432
argsAsJson, err := json.Marshal(args)
1437
urlPath := url.URL{Path: ".."}
1438
url := client.endpoint.ResolveReference(&urlPath).String()
1440
var req *http.Request
1441
if string(argsAsJson) != "{}" {
1442
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1446
req.Header.Set("Content-Type", "application/json")
1448
req, err = http.NewRequest("GET", url, nil)
1454
resp, err := client.handleRequest(req)
1459
body, err := ioutil.ReadAll(resp.Body)
1464
switch resp.StatusCode {
1466
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1471
var results ListExtensionsCinderV2Results
1472
json.Unmarshal(body, &results)
1474
return &results, nil
1477
type GetVolumeTypesParams struct {
1480
// The unique identifier of the tenant or account.
1481
TenantId string `json:"-"`
1484
type GetVolumeTypesResults struct {
1485
VolumeTypes []VolumeType `json:"volume_types"`
1489
// Lists volume types.
1490
func getVolumeTypes(client *Client, args GetVolumeTypesParams) (*GetVolumeTypesResults, error) {
1492
argsAsJson, err := json.Marshal(args)
1497
urlPath := url.URL{Path: "types"}
1498
url := client.endpoint.ResolveReference(&urlPath).String()
1500
var req *http.Request
1501
if string(argsAsJson) != "{}" {
1502
req, err = http.NewRequest("GET", url, bytes.NewBuffer(argsAsJson))
1506
req.Header.Set("Content-Type", "application/json")
1508
req, err = http.NewRequest("GET", url, nil)
1514
resp, err := client.handleRequest(req)
1519
body, err := ioutil.ReadAll(resp.Body)
1524
switch resp.StatusCode {
1526
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1531
var results GetVolumeTypesResults
1532
json.Unmarshal(body, &results)
1534
return &results, nil
1537
type DeleteVolumeTypeParams struct {
1540
// The unique identifier of the tenant or account.
1541
TenantId string `json:"-"`
1543
// VolumeTypeId is required.
1545
// The unique identifier for an existing volume type.
1546
VolumeTypeId string `json:"-"`
1549
type DeleteVolumeTypeResults struct {
1553
// Deletes a specified volume type.
1554
func deleteVolumeType(client *Client, args DeleteVolumeTypeParams) (*DeleteVolumeTypeResults, error) {
1556
argsAsJson, err := json.Marshal(args)
1561
urlPath := url.URL{Path: fmt.Sprintf("types/%s", args.VolumeTypeId)}
1562
url := client.endpoint.ResolveReference(&urlPath).String()
1564
var req *http.Request
1565
if string(argsAsJson) != "{}" {
1566
req, err = http.NewRequest("DELETE", url, bytes.NewBuffer(argsAsJson))
1570
req.Header.Set("Content-Type", "application/json")
1572
req, err = http.NewRequest("DELETE", url, nil)
1578
resp, err := client.handleRequest(req)
1583
body, err := ioutil.ReadAll(resp.Body)
1588
switch resp.StatusCode {
1590
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1595
var results DeleteVolumeTypeResults
1596
json.Unmarshal(body, &results)
1598
return &results, nil
1601
type UpdateSnapshotMetadataMetadataParams struct {
1605
Key string `json:"key"`
1608
type UpdateSnapshotMetadataParams struct {
1610
// Metadata is required.
1611
// One or more metadata key and value pairs to set or unset for the snapshot. To unset a metadata key value, specify only the key name. To set a metadata key value, specify the key and value pair. The Block Storage server does not respect case-sensitive key names. For example, if you specify both "key": "v1" and "KEY": "V1", the server sets and returns only the KEY key and value pair.
1612
Metadata UpdateSnapshotMetadataMetadataParams `json:"metadata"`
1615
// The unique identifier of the tenant or account.
1616
TenantId string `json:"-"`
1618
// SnapshotId is required.
1620
// The unique identifier of an existing snapshot.
1621
SnapshotId string `json:"-"`
1624
type UpdateSnapshotMetadataResults struct {
1626
Key string `json:"key"`
1631
// Updates the metadata for a specified snapshot.
1632
func updateSnapshotMetadata(client *Client, args UpdateSnapshotMetadataParams) (*UpdateSnapshotMetadataResults, error) {
1634
argsAsJson, err := json.Marshal(args)
1639
urlPath := url.URL{Path: fmt.Sprintf("snapshots/%s/metadata", args.SnapshotId)}
1640
url := client.endpoint.ResolveReference(&urlPath).String()
1642
var req *http.Request
1643
if string(argsAsJson) != "{}" {
1644
req, err = http.NewRequest("PUT", url, bytes.NewBuffer(argsAsJson))
1648
req.Header.Set("Content-Type", "application/json")
1650
req, err = http.NewRequest("PUT", url, nil)
1656
resp, err := client.handleRequest(req)
1661
body, err := ioutil.ReadAll(resp.Body)
1666
switch resp.StatusCode {
1668
return nil, fmt.Errorf("invalid status (%d): %s", resp.StatusCode, body)
1673
var results UpdateSnapshotMetadataResults
1674
json.Unmarshal(body, &results)
1676
return &results, nil