-
Notifications
You must be signed in to change notification settings - Fork 0
/
execenv_container.go
75 lines (57 loc) · 1.93 KB
/
execenv_container.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
package cli
import (
"context"
"errors"
api "github.com/atricore/josso-api-go"
)
// Gets an IdP based on the appliance name and idp name
func (c *IdbusApiClient) GetExecEnv(ida string, idsource string) (api.ExecEnvContainerDTO, error) {
c.logger.Debugf("getExecEnv. %s [%s]", idsource, ida)
var result api.ExecEnvContainerDTO
sc, err := c.IdbusServerForOperation("DefaultApiService.GetExecEnv") // Also hard-coded in generated client
if err != nil {
return result, err
}
ctx := context.WithValue(context.Background(), api.ContextAccessToken, sc.Authn.AccessToken)
req := c.apiClient.DefaultApi.GetExecEnv(ctx)
req = req.GetExecEnvReq(api.GetExecEnvReq{IdOrName: &ida, Name: &idsource})
res, _, err := c.apiClient.DefaultApi.GetExecEnvExecute(req)
if err != nil {
c.logger.Errorf("getExecEnv. Error %v", err)
return result, err
}
if res.Error != nil {
c.logger.Errorf("getExecEnv. Error %v", err)
return result, errors.New(*res.Error)
}
if res.ExecEnv == nil {
c.logger.Debugf("getExecEnv. NOT FOUND %s", idsource)
return result, nil
}
result = res.GetExecEnv()
return result, nil
}
func (c *IdbusApiClient) GetExecEnvs(ida string) ([]api.ExecEnvContainerDTO, error) {
c.logger.Debugf("getExecEnvs: all [%s]", ida)
var result []api.ExecEnvContainerDTO
sc, err := c.IdbusServerForOperation("DefaultApiService.GetExecEnvs") // Also hard-coded in generated client
if err != nil {
return result, err
}
ctx := context.WithValue(context.Background(), api.ContextAccessToken, sc.Authn.AccessToken)
req := c.apiClient.DefaultApi.GetExecEnvs(ctx)
req = req.GetApplianceReq(api.GetApplianceReq{IdOrName: &ida})
res, _, err := c.apiClient.DefaultApi.GetExecEnvsExecute(req)
if err != nil {
c.logger.Errorf("getExecEnvs. Error %v", err)
return result, err
}
if res.Error != nil {
return result, errors.New(*res.Error)
}
if res.ExecEnvs == nil {
return result, nil
}
result = res.ExecEnvs
return result, nil
}