-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject.go
59 lines (45 loc) · 1.18 KB
/
project.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
package symbiosis
import "fmt"
// /rest/v1/github/{owner}/{repository}/project/secret?environment=preview|development|production
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
Owner string `json:"owner"`
Repository string `json:"repository"`
Configuration Configuration `json:"configuration"`
ProductionClusterID interface{} `json:"productionClusterId"`
}
type Configuration struct {
ProductionBranch string `json:"productionBranch"`
}
type ProjectService interface {
List() ([]*Project, error)
Describe(projectName string) (*Project, error)
}
type ProjectServiceClient struct {
client *Client
}
func (n *ProjectServiceClient) List() ([]*Project, error) {
var projects []*Project
err := n.client.Call(
"/rest/v1/project",
"Get",
&projects,
)
if err != nil {
return nil, err
}
return projects, nil
}
func (n *ProjectServiceClient) Describe(projectName string) (*Project, error) {
var project *Project
err := n.client.Call(
fmt.Sprintf("/rest/v1/project/%s", projectName),
"Get",
&project,
)
if err != nil {
return nil, err
}
return project, nil
}