/
list_volume_attachments.go
44 lines (37 loc) · 1.83 KB
/
list_volume_attachments.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*******************************************************************************
* IBM Confidential
* OCO Source Materials
* IBM Cloud Container Service, 5737-D43
* (C) Copyright IBM Corp. 2018, 2019 All Rights Reserved.
* The source code for this program is not published or otherwise divested of
* its trade secrets, irrespective of what has been deposited with
* the U.S. Copyright Office.
******************************************************************************/
package instances
import (
"github.com/IBM/ibmcloud-storage-volume-lib/lib/utils"
"github.com/IBM/ibmcloud-storage-volume-lib/volume-providers/vpc/vpcclient/client"
"github.com/IBM/ibmcloud-storage-volume-lib/volume-providers/vpc/vpcclient/models"
"go.uber.org/zap"
"time"
)
// ListVolumeAttachment retrives the list volume attachments with givne volume attachment details
func (vs *VolumeAttachService) ListVolumeAttachment(volumeAttachmentTemplate *models.VolumeAttachment, ctxLogger *zap.Logger) (*models.VolumeAttachmentList, error) {
defer util.TimeTracker("GetAttachStatus", time.Now())
operation := &client.Operation{
Name: "ListVolumeAttachment",
Method: "GET",
PathPattern: vs.pathPrefix + instanceIDvolumeAttachmentPath,
}
var volumeAttachmentList models.VolumeAttachmentList
apiErr := vs.receiverError
request := vs.client.NewRequest(operation)
ctxLogger.Info("Equivalent curl command details", zap.Reflect("URL", request.URL()), zap.Reflect("volumeAttachmentTemplate", volumeAttachmentTemplate), zap.Reflect("Operation", operation))
req := vs.populatePathPrefixParameters(request, volumeAttachmentTemplate)
_, err := req.JSONSuccess(&volumeAttachmentList).JSONError(apiErr).Invoke()
if err != nil {
ctxLogger.Error("Error occured while getting volume attahment", zap.Error(err))
return nil, err
}
return &volumeAttachmentList, nil
}