@@ -19,6 +19,7 @@ package gitlab
19
19
import (
20
20
"fmt"
21
21
"net/url"
22
+ "time"
22
23
)
23
24
24
25
// ServicesService handles communication with the services related methods of
@@ -29,6 +30,19 @@ type ServicesService struct {
29
30
client * Client
30
31
}
31
32
33
+ type Service struct {
34
+ ID * int `json:"id"`
35
+ Title * string `json:"title"`
36
+ CreatedAt * time.Time `json:"created_at"`
37
+ UpdatedAt * time.Time `json:"created_at"`
38
+ Active * bool `json:"active"`
39
+ PushEvents * bool `json:"push_events"`
40
+ IssuesEvents * bool `json:"issues_events"`
41
+ MergeRequestsEvents * bool `json:"merge_requests_events"`
42
+ TagPushEvents * bool `json:"tag_push_events"`
43
+ NoteEvents * bool `json:"note_events"`
44
+ }
45
+
32
46
// SetGitLabCIServiceOptions represents the available SetGitLabCIService()
33
47
// options.
34
48
//
@@ -148,3 +162,102 @@ func (s *ServicesService) DeleteHipChatService(pid interface{}) (*Response, erro
148
162
149
163
return resp , err
150
164
}
165
+
166
+ // SetDroneCIServiceOptions represents the available SetDroneCIService()
167
+ // options.
168
+ //
169
+ // GitLab API docs:
170
+ // http://doc.gitlab.com/ce/api/services.html#createedit-drone-ci-service
171
+ type SetDroneCIServiceOptions struct {
172
+ Token string `url:"token"`
173
+ DroneURL string `url:"drone_url"`
174
+ EnableSSLVerification string `url:"enable_ssl_verification,omitempty"`
175
+ }
176
+
177
+ // SetDroneCIService sets Drone CI service for a project.
178
+ //
179
+ // GitLab API docs:
180
+ // http://doc.gitlab.com/ce/api/services.html#createedit-drone-ci-service
181
+ func (s * ServicesService ) SetDroneCIService (
182
+ pid interface {},
183
+ opt * SetDroneCIServiceOptions ) (* Response , error ) {
184
+ project , err := parseID (pid )
185
+ if err != nil {
186
+ return nil , err
187
+ }
188
+ u := fmt .Sprintf ("projects/%s/services/drone-ci" , url .QueryEscape (project ))
189
+
190
+ req , err := s .client .NewRequest ("PUT" , u , opt )
191
+ if err != nil {
192
+ return nil , err
193
+ }
194
+
195
+ resp , err := s .client .Do (req , nil )
196
+ if err != nil {
197
+ return resp , err
198
+ }
199
+
200
+ return resp , err
201
+ }
202
+
203
+ // DeleteDroneCIService deletes Drone CI service settings for a project.
204
+ //
205
+ // GitLab API docs:
206
+ // http://doc.gitlab.com/ce/api/services.html#delete-drone-ci-service
207
+ func (s * ServicesService ) DeleteDroneCIService (pid interface {}) (* Response , error ) {
208
+ project , err := parseID (pid )
209
+ if err != nil {
210
+ return nil , err
211
+ }
212
+ u := fmt .Sprintf ("projects/%s/services/drone-ci" , url .QueryEscape (project ))
213
+
214
+ req , err := s .client .NewRequest ("DELETE" , u , nil )
215
+ if err != nil {
216
+ return nil , err
217
+ }
218
+
219
+ resp , err := s .client .Do (req , nil )
220
+ if err != nil {
221
+ return resp , err
222
+ }
223
+
224
+ return resp , err
225
+ }
226
+
227
+ // DroneCIServiceProperties represents Drone CI specific properties.
228
+ type DroneCIServiceProperties struct {
229
+ Token * string `url:"token"`
230
+ DroneURL * string `url:"drone_url"`
231
+ EnableSSLVerification * string `url:"enable_ssl_verification"`
232
+ }
233
+
234
+ // DroneCIService represents Drone CI service settings.
235
+ type DroneCIService struct {
236
+ Service
237
+ Properties * DroneCIServiceProperties `json:"properties"`
238
+ }
239
+
240
+ // GetDroneCIService gets Drone CI service settings for a project.
241
+ //
242
+ // GitLab API docs:
243
+ // http://doc.gitlab.com/ce/api/services.html#get-drone-ci-service-settings
244
+ func (s * ServicesService ) GetDroneCIService (pid interface {}) (* DroneCIService , * Response , error ) {
245
+ project , err := parseID (pid )
246
+ if err != nil {
247
+ return nil , nil , err
248
+ }
249
+ u := fmt .Sprintf ("projects/%s/services/drone-ci" , url .QueryEscape (project ))
250
+
251
+ req , err := s .client .NewRequest ("GET" , u , nil )
252
+ if err != nil {
253
+ return nil , nil , err
254
+ }
255
+
256
+ opt := new (DroneCIService )
257
+ resp , err := s .client .Do (req , opt )
258
+ if err != nil {
259
+ return nil , resp , err
260
+ }
261
+
262
+ return opt , resp , err
263
+ }
0 commit comments