-
Notifications
You must be signed in to change notification settings - Fork 4
/
library.go
81 lines (64 loc) · 1.82 KB
/
library.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// (C) Copyright 2021 Hewlett Packard Enterprise Development LP
package client
import (
"context"
"encoding/json"
"fmt"
consts "github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk/pkg/common"
"github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk/pkg/models"
)
type LibraryAPIService struct {
Client APIClientHandler
Cfg Configuration
}
/*
LibrariesAPIService
Get All layouts
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc.
Passed from http.Request or context.Background().
* @param serviceInstanceID
*/
func (a *LibraryAPIService) GetAllLayouts(ctx context.Context,
param map[string]string) (models.LayoutsResp, error) {
response := models.LayoutsResp{}
allLayoutsAPI := &api{
method: "GET",
path: consts.LibraryLayoutPath,
client: a.Client,
jsonParser: func(body []byte) error {
return json.Unmarshal(body, &response)
},
}
err := allLayoutsAPI.do(ctx, nil, param)
return response, err
}
func (a *LibraryAPIService) GetAllInstanceTypes(ctx context.Context,
param map[string]string) (models.InstanceTypesResp, error) {
response := models.InstanceTypesResp{}
allInstTypeAPI := &api{
method: "GET",
path: consts.LibraryInstanceTypesPath,
client: a.Client,
jsonParser: func(body []byte) error {
return json.Unmarshal(body, &response)
},
}
err := allInstTypeAPI.do(ctx, nil, param)
return response, err
}
func (a *LibraryAPIService) GetSpecificLayout(
ctx context.Context,
layoutID int,
) (models.GetSpecificLayout, error) {
response := models.GetSpecificLayout{}
allLayoutsAPI := &api{
method: "GET",
path: fmt.Sprintf("%s/%d", consts.LibraryLayoutPath, layoutID),
client: a.Client,
jsonParser: func(body []byte) error {
return json.Unmarshal(body, &response)
},
}
err := allLayoutsAPI.do(ctx, nil, nil)
return response, err
}