...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package gitlab
18
19 import (
20 "fmt"
21 "net/http"
22 "time"
23 )
24
25
26
27
28
29
30 type LicenseService struct {
31 client *Client
32 }
33
34
35
36
37
38 type License struct {
39 ID int `json:"id"`
40 Plan string `json:"plan"`
41 CreatedAt *time.Time `json:"created_at"`
42 StartsAt *ISOTime `json:"starts_at"`
43 ExpiresAt *ISOTime `json:"expires_at"`
44 HistoricalMax int `json:"historical_max"`
45 MaximumUserCount int `json:"maximum_user_count"`
46 Expired bool `json:"expired"`
47 Overage int `json:"overage"`
48 UserLimit int `json:"user_limit"`
49 ActiveUsers int `json:"active_users"`
50 Licensee struct {
51 Name string `json:"Name"`
52 Company string `json:"Company"`
53 Email string `json:"Email"`
54 } `json:"licensee"`
55
56
57 AddOns struct {
58 GitLabAuditorUser int `json:"GitLab_Auditor_User"`
59 GitLabDeployBoard int `json:"GitLab_DeployBoard"`
60 GitLabFileLocks int `json:"GitLab_FileLocks"`
61 GitLabGeo int `json:"GitLab_Geo"`
62 GitLabServiceDesk int `json:"GitLab_ServiceDesk"`
63 } `json:"add_ons"`
64 }
65
66 func (l License) String() string {
67 return Stringify(l)
68 }
69
70
71
72
73
74 func (s *LicenseService) GetLicense(options ...RequestOptionFunc) (*License, *Response, error) {
75 req, err := s.client.NewRequest(http.MethodGet, "license", nil, options)
76 if err != nil {
77 return nil, nil, err
78 }
79
80 l := new(License)
81 resp, err := s.client.Do(req, l)
82 if err != nil {
83 return nil, resp, err
84 }
85
86 return l, resp, nil
87 }
88
89
90
91
92 type AddLicenseOptions struct {
93 License *string `url:"license" json:"license"`
94 }
95
96
97
98
99
100 func (s *LicenseService) AddLicense(opt *AddLicenseOptions, options ...RequestOptionFunc) (*License, *Response, error) {
101 req, err := s.client.NewRequest(http.MethodPost, "license", opt, options)
102 if err != nil {
103 return nil, nil, err
104 }
105
106 l := new(License)
107 resp, err := s.client.Do(req, l)
108 if err != nil {
109 return nil, resp, err
110 }
111
112 return l, resp, nil
113 }
114
115
116
117
118
119 func (s *LicenseService) DeleteLicense(licenseID int, options ...RequestOptionFunc) (*Response, error) {
120 u := fmt.Sprintf("license/%d", licenseID)
121
122 req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
123 if err != nil {
124 return nil, err
125 }
126
127 return s.client.Do(req, nil)
128 }
129
View as plain text