-
Notifications
You must be signed in to change notification settings - Fork 1
/
utility.go
73 lines (56 loc) · 1.61 KB
/
utility.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
package mcis
import (
"context"
"errors"
gc "github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/common"
pb "github.com/cloud-barista/poc-cicd-tumblebug/src/api/grpc/protobuf/cbtumblebug"
)
// ===== [ Constants and Variables ] =====
// ===== [ Types ] =====
// ===== [ Implementations ] =====
// CheckMcis - Check whether MCIS exists or not
func (r *MCISRequest) CheckMcis() (string, error) {
// Check input data
if r.InData == "" {
return "", errors.New("input data required")
}
// Unmarshal (json/yaml -> Request Input)
var item pb.TbMcisQryRequest
err := gc.ConvertToMessage(r.InType, r.InData, &item)
if err != nil {
return "", err
}
// Request to server
ctx, cancel := context.WithTimeout(context.Background(), r.Timeout)
defer cancel()
resp, err := r.Client.CheckMcis(ctx, &item)
if err != nil {
return "", err
}
// Marshal (Response -> json/yaml)
return gc.ConvertToOutput(r.OutType, &resp)
}
// CheckVm - Check whether MCIS VM exists or not
func (r *MCISRequest) CheckVm() (string, error) {
// Check input data
if r.InData == "" {
return "", errors.New("input data required")
}
// Unmarshal (json/yaml -> Request Input)
var item pb.TbVmQryRequest
err := gc.ConvertToMessage(r.InType, r.InData, &item)
if err != nil {
return "", err
}
// Request to server
ctx, cancel := context.WithTimeout(context.Background(), r.Timeout)
defer cancel()
resp, err := r.Client.CheckVm(ctx, &item)
if err != nil {
return "", err
}
// Marshal (Response -> json/yaml)
return gc.ConvertToOutput(r.OutType, &resp)
}
// ===== [ Private Functions ] =====
// ===== [ Public Functions ] =====