You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/vendor/github.com/linode/linodego/instance_volumes.go

39 lines
1.0 KiB

package linodego
import (
"context"
)
// InstanceVolumesPagedResponse represents a paginated InstanceVolume API response
type InstanceVolumesPagedResponse struct {
*PageOptions
Data []Volume `json:"data"`
}
// endpoint gets the endpoint URL for InstanceVolume
func (InstanceVolumesPagedResponse) endpointWithID(c *Client, id int) string {
endpoint, err := c.InstanceVolumes.endpointWithID(id)
if err != nil {
panic(err)
}
return endpoint
}
// appendData appends InstanceVolumes when processing paginated InstanceVolume responses
func (resp *InstanceVolumesPagedResponse) appendData(r *InstanceVolumesPagedResponse) {
resp.Data = append(resp.Data, r.Data...)
}
// ListInstanceVolumes lists InstanceVolumes
func (c *Client) ListInstanceVolumes(ctx context.Context, linodeID int, opts *ListOptions) ([]Volume, error) {
response := InstanceVolumesPagedResponse{}
err := c.listHelperWithID(ctx, &response, linodeID, opts)
for i := range response.Data {
response.Data[i].fixDates()
}
if err != nil {
return nil, err
}
return response.Data, nil
}