-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject.go
68 lines (59 loc) · 1.99 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
60
61
62
63
64
65
66
67
68
package yapi
import "net/http"
type EnvHeader struct {
ID string `json:"_id,omitempty" structs:"_id,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
Value string `json:"value,omitempty" structs:"value,omitempty"`
}
type EnvGlobal struct {
ID string `json:"_id,omitempty" structs:"_id,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
Value string `json:"value,omitempty" structs:"value,omitempty"`
}
type ProjectEnv struct {
Header []EnvHeader `json:"header,omitempty" structs:"header,omitempty"`
Global []EnvGlobal `json:"global,omitempty" structs:"global,omitempty"`
ID string `json:"_id" structs:"_id"`
Name string `json:"name" structs:"name"`
Domain string `json:"domain" structs:"domain"`
}
type ProjectData struct {
ID int `json:"_id" structs:"_id"`
UID int `json:"uid" structs:"uid"`
GroupID int `json:"group_id" structs:"group_id"`
Name string `json:"name" structs:"name"`
Type string `json:"project_type" structs:"project_type"`
Role string `json:"role" structs:"role"`
Env []ProjectEnv `json:"env" structs:"env"`
}
type Project struct {
ErrCode int `json:"errcode" structs:"errcode"`
ErrMsg string `json:"errmsg" structs:"errmsg"`
Data ProjectData `json:"data" structs:"data"`
}
// ProjectService .
type ProjectService struct {
client *Client
}
type ProjectParam struct {
Token string `url:"token"`
}
func (s *ProjectService) Get() (*Project, *http.Response, error) {
apiEndpoint := "api/project/get"
projectParam := new(ProjectParam)
projectParam.Token = s.client.Authentication.token
url, err := addOptions(apiEndpoint, projectParam)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", url, nil)
if err != nil {
return nil, nil, err
}
result := new(Project)
resp, err := s.client.Do(req, result)
if err != nil {
return nil, resp, NewServerError(resp, err)
}
return result, resp, err
}