Skip to content

Commit

Permalink
feat!: Add name query parameter to ActionsService.ListArtifacts (#3330)
Browse files Browse the repository at this point in the history
Fixes: #3328.

BREAKING CHANGE: `opts` argument to `ActionsService.ListArtifacts` changed from `ListOptions` to `ListArtifactsOptions`.
  • Loading branch information
gmlewis authored Oct 21, 2024
1 parent 9412ac2 commit cc9a0ed
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
12 changes: 11 additions & 1 deletion github/actions_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ type ArtifactList struct {
Artifacts []*Artifact `json:"artifacts,omitempty"`
}

// ListArtifactsOptions specifies the optional parameters to the
// ActionsService.ListArtifacts method.
type ListArtifactsOptions struct {
// Name represents the name field of an artifact.
// When specified, only artifacts with this name will be returned.
Name *string `url:"name,omitempty"`

ListOptions
}

// ListArtifacts lists all artifacts that belong to a repository.
//
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-artifacts-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/artifacts
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) {
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListArtifactsOptions) (*ArtifactList, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
u, err := addOptions(u, opts)
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestActionsService_ListArtifacts(t *testing.T) {

mux.HandleFunc("/repos/o/r/actions/artifacts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"page": "2"})
testFormValues(t, r, values{"page": "2", "name": "TheArtifact"})
fmt.Fprint(w,
`{
"total_count":1,
Expand All @@ -31,7 +31,10 @@ func TestActionsService_ListArtifacts(t *testing.T) {
)
})

opts := &ListOptions{Page: 2}
opts := &ListArtifactsOptions{
Name: String("TheArtifact"),
ListOptions: ListOptions{Page: 2},
}
ctx := context.Background()
artifacts, _, err := client.Actions.ListArtifacts(ctx, "o", "r", opts)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cc9a0ed

Please sign in to comment.