forked from google/go-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenterprise_actions_hosted_runners.go
More file actions
344 lines (294 loc) · 13.5 KB
/
enterprise_actions_hosted_runners.go
File metadata and controls
344 lines (294 loc) · 13.5 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// Copyright 2025 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// ListHostedRunners lists all the GitHub-hosted runners for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#list-github-hosted-runners-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners
func (s *EnterpriseService) ListHostedRunners(ctx context.Context, enterprise string, opts *ListOptions) (*HostedRunners, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners", enterprise)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var runners *HostedRunners
resp, err := s.client.Do(ctx, req, &runners)
if err != nil {
return nil, resp, err
}
return runners, resp, nil
}
// CreateHostedRunner creates a GitHub-hosted runner for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#create-a-github-hosted-runner-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/hosted-runners
func (s *EnterpriseService) CreateHostedRunner(ctx context.Context, enterprise string, request CreateHostedRunnerRequest) (*HostedRunner, *Response, error) {
if err := validateCreateHostedRunnerRequest(&request); err != nil {
return nil, nil, fmt.Errorf("validation failed: %w", err)
}
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners", enterprise)
req, err := s.client.NewRequest("POST", u, request)
if err != nil {
return nil, nil, err
}
var hostedRunner *HostedRunner
resp, err := s.client.Do(ctx, req, &hostedRunner)
if err != nil {
return nil, resp, err
}
return hostedRunner, resp, nil
}
// GetHostedRunnerGitHubOwnedImages gets the list of GitHub-owned images available for GitHub-hosted runners for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-github-owned-images-for-github-hosted-runners-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/github-owned
func (s *EnterpriseService) GetHostedRunnerGitHubOwnedImages(ctx context.Context, enterprise string) (*HostedRunnerImages, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/github-owned", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var hostedRunnerImages *HostedRunnerImages
resp, err := s.client.Do(ctx, req, &hostedRunnerImages)
if err != nil {
return nil, resp, err
}
return hostedRunnerImages, resp, nil
}
// GetHostedRunnerPartnerImages gets the list of partner images available for GitHub-hosted runners for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-partner-images-for-github-hosted-runners-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/partner
func (s *EnterpriseService) GetHostedRunnerPartnerImages(ctx context.Context, enterprise string) (*HostedRunnerImages, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/partner", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var hostedRunnerImages *HostedRunnerImages
resp, err := s.client.Do(ctx, req, &hostedRunnerImages)
if err != nil {
return nil, resp, err
}
return hostedRunnerImages, resp, nil
}
// GetHostedRunnerLimits gets the GitHub-hosted runners Static public IP Limits for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-limits-on-github-hosted-runners-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/limits
func (s *EnterpriseService) GetHostedRunnerLimits(ctx context.Context, enterprise string) (*HostedRunnerPublicIPLimits, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/limits", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var publicIPLimits *HostedRunnerPublicIPLimits
resp, err := s.client.Do(ctx, req, &publicIPLimits)
if err != nil {
return nil, resp, err
}
return publicIPLimits, resp, nil
}
// GetHostedRunnerMachineSpecs gets the list of machine specs available for GitHub-hosted runners for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-github-hosted-runners-machine-specs-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/machine-sizes
func (s *EnterpriseService) GetHostedRunnerMachineSpecs(ctx context.Context, enterprise string) (*HostedRunnerMachineSpecs, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/machine-sizes", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var machineSpecs *HostedRunnerMachineSpecs
resp, err := s.client.Do(ctx, req, &machineSpecs)
if err != nil {
return nil, resp, err
}
return machineSpecs, resp, nil
}
// GetHostedRunnerPlatforms gets list of platforms available for GitHub-hosted runners for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-platforms-for-github-hosted-runners-in-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/platforms
func (s *EnterpriseService) GetHostedRunnerPlatforms(ctx context.Context, enterprise string) (*HostedRunnerPlatforms, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/platforms", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var platforms *HostedRunnerPlatforms
resp, err := s.client.Do(ctx, req, &platforms)
if err != nil {
return nil, resp, err
}
return platforms, resp, nil
}
// GetHostedRunner gets a GitHub-hosted runner in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-a-github-hosted-runner-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/{hosted_runner_id}
func (s *EnterpriseService) GetHostedRunner(ctx context.Context, enterprise string, runnerID int64) (*HostedRunner, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/%v", enterprise, runnerID)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var hostedRunner *HostedRunner
resp, err := s.client.Do(ctx, req, &hostedRunner)
if err != nil {
return nil, resp, err
}
return hostedRunner, resp, nil
}
// UpdateHostedRunner updates a GitHub-hosted runner for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#update-a-github-hosted-runner-for-an-enterprise
//
//meta:operation PATCH /enterprises/{enterprise}/actions/hosted-runners/{hosted_runner_id}
func (s *EnterpriseService) UpdateHostedRunner(ctx context.Context, enterprise string, runnerID int64, request UpdateHostedRunnerRequest) (*HostedRunner, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/%v", enterprise, runnerID)
req, err := s.client.NewRequest("PATCH", u, request)
if err != nil {
return nil, nil, err
}
var hostedRunner *HostedRunner
resp, err := s.client.Do(ctx, req, &hostedRunner)
if err != nil {
return nil, resp, err
}
return hostedRunner, resp, nil
}
// DeleteHostedRunner deletes GitHub-hosted runner from an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#delete-a-github-hosted-runner-for-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/hosted-runners/{hosted_runner_id}
func (s *EnterpriseService) DeleteHostedRunner(ctx context.Context, enterprise string, runnerID int64) (*HostedRunner, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/%v", enterprise, runnerID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, nil, err
}
var hostedRunner *HostedRunner
resp, err := s.client.Do(ctx, req, &hostedRunner)
if err != nil {
return nil, resp, err
}
return hostedRunner, resp, nil
}
// ListHostedRunnerCustomImages lists custom images for GitHub-hosted runners in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#list-custom-images-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/custom
func (s *EnterpriseService) ListHostedRunnerCustomImages(ctx context.Context, enterprise string) (*HostedRunnerCustomImages, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var images *HostedRunnerCustomImages
resp, err := s.client.Do(ctx, req, &images)
if err != nil {
return nil, resp, err
}
return images, resp, nil
}
// GetHostedRunnerCustomImage gets a custom image definition for GitHub-hosted runners in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-an-enterprise-custom-image-definition-for-github-actions-hosted-runners
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/custom/{image_definition_id}
func (s *EnterpriseService) GetHostedRunnerCustomImage(ctx context.Context, enterprise string, imageDefinitionID int64) (*HostedRunnerCustomImage, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom/%v", enterprise, imageDefinitionID)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var image *HostedRunnerCustomImage
resp, err := s.client.Do(ctx, req, &image)
if err != nil {
return nil, resp, err
}
return image, resp, nil
}
// DeleteHostedRunnerCustomImage deletes a custom image from the enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#delete-a-custom-image-from-the-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/hosted-runners/images/custom/{image_definition_id}
func (s *EnterpriseService) DeleteHostedRunnerCustomImage(ctx context.Context, enterprise string, imageDefinitionID int64) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom/%v", enterprise, imageDefinitionID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
return s.client.Do(ctx, req, nil)
}
// ListHostedRunnerCustomImageVersions lists image versions of a custom image for an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#list-image-versions-of-a-custom-image-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/custom/{image_definition_id}/versions
func (s *EnterpriseService) ListHostedRunnerCustomImageVersions(ctx context.Context, enterprise string, imageDefinitionID int64) (*HostedRunnerCustomImageVersions, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom/%v/versions", enterprise, imageDefinitionID)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var versions *HostedRunnerCustomImageVersions
resp, err := s.client.Do(ctx, req, &versions)
if err != nil {
return nil, resp, err
}
return versions, resp, nil
}
// GetHostedRunnerCustomImageVersion gets an image version of a custom image for GitHub-hosted runners in an enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#get-an-image-version-of-an-enterprise-custom-image-for-github-actions-hosted-runners
//
//meta:operation GET /enterprises/{enterprise}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}
func (s *EnterpriseService) GetHostedRunnerCustomImageVersion(ctx context.Context, enterprise string, imageDefinitionID int64, version string) (*HostedRunnerCustomImageVersion, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom/%v/versions/%v", enterprise, imageDefinitionID, version)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
var imageVersion *HostedRunnerCustomImageVersion
resp, err := s.client.Do(ctx, req, &imageVersion)
if err != nil {
return nil, resp, err
}
return imageVersion, resp, nil
}
// DeleteHostedRunnerCustomImageVersion deletes an image version of a custom image from the enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/hosted-runners#delete-an-image-version-of-custom-image-from-the-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version}
func (s *EnterpriseService) DeleteHostedRunnerCustomImageVersion(ctx context.Context, enterprise string, imageDefinitionID int64, version string) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/hosted-runners/images/custom/%v/versions/%v", enterprise, imageDefinitionID, version)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
return s.client.Do(ctx, req, nil)
}