dsl struct tags; wip
diff --git a/openstack/compute/v2/extensions/volumeattach/requests.go b/openstack/compute/v2/extensions/volumeattach/requests.go
index c2bc2ee..c8ef930 100644
--- a/openstack/compute/v2/extensions/volumeattach/requests.go
+++ b/openstack/compute/v2/extensions/volumeattach/requests.go
@@ -6,8 +6,8 @@
)
// List returns a Pager that allows you to iterate over a collection of VolumeAttachments.
-func List(client *gophercloud.ServiceClient, serverId string) pagination.Pager {
- return pagination.NewPager(client, listURL(client, serverId), func(r pagination.PageResult) pagination.Page {
+func List(client *gophercloud.ServiceClient, serverID string) pagination.Pager {
+ return pagination.NewPager(client, listURL(client, serverID), func(r pagination.PageResult) pagination.Page {
return VolumeAttachmentPage{pagination.SinglePageBase(r)}
})
}
@@ -21,56 +21,40 @@
// CreateOpts specifies volume attachment creation or import parameters.
type CreateOpts struct {
// Device is the device that the volume will attach to the instance as. Omit for "auto"
- Device string
-
+ Device string `json:"device,omitempty"`
// VolumeID is the ID of the volume to attach to the instance
- VolumeID string
+ VolumeID string `json:"volumeId" required:"true"`
}
// ToVolumeAttachmentCreateMap constructs a request body from CreateOpts.
func (opts CreateOpts) ToVolumeAttachmentCreateMap() (map[string]interface{}, error) {
- if opts.VolumeID == "" {
- err := gophercloud.ErrMissingInput{}
- err.Function = "volumeattach.ToVolumeAttachmentCreateMap"
- err.Argument = "volumeattach.CreateOpts.VolumeID"
- return nil, err
- }
-
- volumeAttachment := make(map[string]interface{})
- volumeAttachment["volumeId"] = opts.VolumeID
- if opts.Device != "" {
- volumeAttachment["device"] = opts.Device
- }
-
- return map[string]interface{}{"volumeAttachment": volumeAttachment}, nil
+ return gophercloud.BuildRequestBody(opts, "volumeAttachment")
}
// Create requests the creation of a new volume attachment on the server
-func Create(client *gophercloud.ServiceClient, serverId string, opts CreateOptsBuilder) CreateResult {
- var res CreateResult
-
- reqBody, err := opts.ToVolumeAttachmentCreateMap()
+func Create(client *gophercloud.ServiceClient, serverID string, opts CreateOptsBuilder) CreateResult {
+ var r CreateResult
+ b, err := opts.ToVolumeAttachmentCreateMap()
if err != nil {
- res.Err = err
- return res
+ r.Err = err
+ return r
}
-
- _, res.Err = client.Post(createURL(client, serverId), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, r.Err = client.Post(createURL(client, serverID), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
- return res
+ return r
}
// Get returns public data about a previously created VolumeAttachment.
-func Get(client *gophercloud.ServiceClient, serverId, aId string) GetResult {
- var res GetResult
- _, res.Err = client.Get(getURL(client, serverId, aId), &res.Body, nil)
- return res
+func Get(client *gophercloud.ServiceClient, serverID, attachmentID string) GetResult {
+ var r GetResult
+ _, r.Err = client.Get(getURL(client, serverID, attachmentID), &r.Body, nil)
+ return r
}
// Delete requests the deletion of a previous stored VolumeAttachment from the server.
-func Delete(client *gophercloud.ServiceClient, serverId, aId string) DeleteResult {
- var res DeleteResult
- _, res.Err = client.Delete(deleteURL(client, serverId, aId), nil)
- return res
+func Delete(client *gophercloud.ServiceClient, serverID, attachmentID string) DeleteResult {
+ var r DeleteResult
+ _, r.Err = client.Delete(deleteURL(client, serverID, attachmentID), nil)
+ return r
}