forked from ehazlett/stellar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
64 lines (51 loc) · 1.14 KB
/
application.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
package client
import (
"context"
api "github.com/ehazlett/stellar/api/services/application/v1"
)
type application struct {
client api.ApplicationClient
}
func (a *application) Create(req *api.CreateRequest) error {
ctx := context.Background()
if _, err := a.client.Create(ctx, req); err != nil {
return err
}
return nil
}
func (a *application) Delete(name string) error {
ctx := context.Background()
if _, err := a.client.Delete(ctx, &api.DeleteRequest{
Name: name,
}); err != nil {
return err
}
return nil
}
func (a *application) List() ([]*api.App, error) {
ctx := context.Background()
resp, err := a.client.List(ctx, &api.ListRequest{})
if err != nil {
return nil, err
}
return resp.Applications, nil
}
func (a *application) Get(name string) (*api.App, error) {
ctx := context.Background()
resp, err := a.client.Get(ctx, &api.GetRequest{
Name: name,
})
if err != nil {
return nil, err
}
return resp.Application, nil
}
func (a *application) Restart(name string) error {
ctx := context.Background()
if _, err := a.client.Restart(ctx, &api.RestartRequest{
Name: name,
}); err != nil {
return err
}
return nil
}