-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add custom image endpoints for GitHub-hosted runners #4101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
austenstone
wants to merge
4
commits into
google:master
Choose a base branch
from
austenstone:add-custom-image-endpoints
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,124
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f48c67e
Add custom image endpoints for GitHub-hosted runners
austenstone ceb848b
fix: ListHostedRunnerCustomImages return type should be HostedRunnerC…
austenstone 29b8b22
Use var declaration style and regenerate accessors
austenstone e8a20cb
Fix images JSON tag and add state_details field per review
austenstone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -160,6 +160,39 @@ func (s *ActionsService) CreateHostedRunner(ctx context.Context, org string, req | |||||||||||||||||||||||||
| return hostedRunner, resp, nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // HostedRunnerCustomImage represents a custom image definition for GitHub-hosted runners. | ||||||||||||||||||||||||||
| type HostedRunnerCustomImage struct { | ||||||||||||||||||||||||||
| ID *int64 `json:"id,omitempty"` | ||||||||||||||||||||||||||
| Platform *string `json:"platform,omitempty"` | ||||||||||||||||||||||||||
| Name *string `json:"name,omitempty"` | ||||||||||||||||||||||||||
| Source *string `json:"source,omitempty"` | ||||||||||||||||||||||||||
| VersionsCount *int `json:"versions_count,omitempty"` | ||||||||||||||||||||||||||
| TotalVersionsSize *int `json:"total_versions_size,omitempty"` | ||||||||||||||||||||||||||
| LatestVersion *string `json:"latest_version,omitempty"` | ||||||||||||||||||||||||||
| State *string `json:"state,omitempty"` | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // HostedRunnerCustomImages represents a collection of custom images for GitHub-hosted runners. | ||||||||||||||||||||||||||
| type HostedRunnerCustomImages struct { | ||||||||||||||||||||||||||
| TotalCount int `json:"total_count"` | ||||||||||||||||||||||||||
| Images []*HostedRunnerCustomImage `json:"images"` | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // HostedRunnerCustomImageVersion represents a version of a custom image for GitHub-hosted runners. | ||||||||||||||||||||||||||
| type HostedRunnerCustomImageVersion struct { | ||||||||||||||||||||||||||
| Version *string `json:"version,omitempty"` | ||||||||||||||||||||||||||
| SizeGB *int `json:"size_gb,omitempty"` | ||||||||||||||||||||||||||
| State *string `json:"state,omitempty"` | ||||||||||||||||||||||||||
| StateDetails *string `json:"state_details,omitempty"` | ||||||||||||||||||||||||||
| CreatedOn *Timestamp `json:"created_on,omitempty"` | ||||||||||||||||||||||||||
|
Comment on lines
+182
to
+187
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Can we remove |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
austenstone marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // HostedRunnerCustomImageVersions represents a collection of versions of a custom image. | ||||||||||||||||||||||||||
| type HostedRunnerCustomImageVersions struct { | ||||||||||||||||||||||||||
| TotalCount int `json:"total_count"` | ||||||||||||||||||||||||||
| ImageVersions []*HostedRunnerCustomImageVersion `json:"image_versions"` | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // HostedRunnerImageSpecs represents the details of a GitHub-hosted runner image. | ||||||||||||||||||||||||||
| type HostedRunnerImageSpecs struct { | ||||||||||||||||||||||||||
| ID string `json:"id"` | ||||||||||||||||||||||||||
|
|
@@ -365,3 +398,117 @@ func (s *ActionsService) DeleteHostedRunner(ctx context.Context, org string, run | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return hostedRunner, resp, nil | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // ListHostedRunnerCustomImages lists custom images for GitHub-hosted runners in an organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#list-custom-images-for-an-organization | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom | ||||||||||||||||||||||||||
| func (s *ActionsService) ListHostedRunnerCustomImages(ctx context.Context, org string) (*HostedRunnerCustomImages, *Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom", org) | ||||||||||||||||||||||||||
| 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 organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#get-a-custom-image-definition-for-github-actions-hosted-runners | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id} | ||||||||||||||||||||||||||
| func (s *ActionsService) GetHostedRunnerCustomImage(ctx context.Context, org string, imageDefinitionID int64) (*HostedRunnerCustomImage, *Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v", org, 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 organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#delete-a-custom-image-from-the-organization | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation DELETE /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id} | ||||||||||||||||||||||||||
| func (s *ActionsService) DeleteHostedRunnerCustomImage(ctx context.Context, org string, imageDefinitionID int64) (*Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v", org, 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 organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#list-image-versions-of-a-custom-image-for-an-organization | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions | ||||||||||||||||||||||||||
| func (s *ActionsService) ListHostedRunnerCustomImageVersions(ctx context.Context, org string, imageDefinitionID int64) (*HostedRunnerCustomImageVersions, *Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions", org, 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 organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#get-an-image-version-of-a-custom-image-for-github-actions-hosted-runners | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation GET /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version} | ||||||||||||||||||||||||||
| func (s *ActionsService) GetHostedRunnerCustomImageVersion(ctx context.Context, org string, imageDefinitionID int64, version string) (*HostedRunnerCustomImageVersion, *Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions/%v", org, 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 organization. | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| // GitHub API docs: https://docs.github.com/rest/actions/hosted-runners#delete-an-image-version-of-custom-image-from-the-organization | ||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||
| //meta:operation DELETE /orgs/{org}/actions/hosted-runners/images/custom/{image_definition_id}/versions/{version} | ||||||||||||||||||||||||||
| func (s *ActionsService) DeleteHostedRunnerCustomImageVersion(ctx context.Context, org string, imageDefinitionID int64, version string) (*Response, error) { | ||||||||||||||||||||||||||
| u := fmt.Sprintf("orgs/%v/actions/hosted-runners/images/custom/%v/versions/%v", org, imageDefinitionID, version) | ||||||||||||||||||||||||||
| req, err := s.client.NewRequest("DELETE", u, nil) | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return s.client.Do(ctx, req, nil) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same