-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
51 lines (42 loc) · 1.17 KB
/
app.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
package appcenter
import (
"fmt"
"github.com/electric-feel/appcenter/client"
"github.com/electric-feel/appcenter/model"
)
// AppAPI ...
type AppAPI struct {
API client.API
ReleaseOptions model.ReleaseOptions
}
// CreateApplicationAPI ...
func CreateApplicationAPI(api client.API, releaseOptions model.ReleaseOptions) AppAPI {
return AppAPI{
API: api,
ReleaseOptions: releaseOptions,
}
}
// NewRelease ...
func (a AppAPI) NewRelease() (model.Release, error) {
releaseID, err := a.API.CreateRelease(a.ReleaseOptions)
if err != nil {
return model.Release{},
fmt.Errorf("failed to create new release on app: %s, owner: %s, %v",
a.ReleaseOptions.App.AppName,
a.ReleaseOptions.App.Owner,
err)
}
return a.API.GetAppReleaseDetails(a.ReleaseOptions.App, releaseID)
}
// Groups ...
func (a AppAPI) Groups(name string) (model.Group, error) {
return a.API.GetGroupByName(name, a.ReleaseOptions.App)
}
// AllGroups ...
func (a AppAPI) AllGroups() ([]model.Group, error) {
return a.API.GetAllGroups(a.ReleaseOptions.App)
}
// Stores ...
func (a AppAPI) Stores(name string) (model.Store, error) {
return a.API.GetStore(name, a.ReleaseOptions.App)
}