-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps.go
69 lines (57 loc) · 1.57 KB
/
apps.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
package nuon
import (
"context"
"github.com/nuonco/nuon-go/client/operations"
"github.com/nuonco/nuon-go/models"
)
// internal methods
func (c *client) GetApp(ctx context.Context, appID string) (*models.AppApp, error) {
resp, err := c.genClient.Operations.GetApp(&operations.GetAppParams{
Context: ctx,
AppID: appID,
}, c.getOrgIDAuthInfo())
if err != nil {
return nil, err
}
return resp.Payload, nil
}
func (c *client) GetApps(ctx context.Context) ([]*models.AppApp, error) {
resp, err := c.genClient.Operations.GetApps(&operations.GetAppsParams{
Context: ctx,
}, nil)
if err != nil {
return nil, err
}
return resp.Payload, nil
}
func (c *client) CreateApp(ctx context.Context, req *models.ServiceCreateAppRequest) (*models.AppApp, error) {
resp, err := c.genClient.Operations.CreateApp(&operations.CreateAppParams{
Req: req,
Context: ctx,
}, c.getOrgIDAuthInfo())
if err != nil {
return nil, err
}
return resp.Payload, nil
}
func (c *client) UpdateApp(ctx context.Context, appID string, req *models.ServiceUpdateAppRequest) (*models.AppApp, error) {
resp, err := c.genClient.Operations.UpdateApp(&operations.UpdateAppParams{
AppID: appID,
Req: req,
Context: ctx,
}, c.getOrgIDAuthInfo())
if err != nil {
return nil, err
}
return resp.Payload, nil
}
func (c *client) DeleteApp(ctx context.Context, appID string) (bool, error) {
resp, err := c.genClient.Operations.DeleteApp(&operations.DeleteAppParams{
AppID: appID,
Context: ctx,
}, c.getOrgIDAuthInfo())
if err != nil {
return false, err
}
return resp.IsSuccess(), nil
}