Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion github/orgs_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ type CustomPropertyValue struct {
Value any `json:"value"`
}

// ListCustomPropertyValuesOptions specifies the optional parameters to the
// OrganizationsService.ListCustomPropertyValues method.
type ListCustomPropertyValuesOptions struct {
RepositoryQuery string `url:"repository_query,omitempty"`
ListOptions
}

// UnmarshalJSON implements the json.Unmarshaler interface.
// This helps us handle the fact that Value can be either a string, []string, or nil.
func (cpv *CustomPropertyValue) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -197,7 +204,7 @@ func (s *OrganizationsService) RemoveCustomProperty(ctx context.Context, org, cu
// GitHub API docs: https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories
//
//meta:operation GET /orgs/{org}/properties/values
func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListOptions) ([]*RepoCustomPropertyValue, *Response, error) {
func (s *OrganizationsService) ListCustomPropertyValues(ctx context.Context, org string, opts *ListCustomPropertyValuesOptions) ([]*RepoCustomPropertyValue, *Response, error) {
u := fmt.Sprintf("orgs/%v/properties/values", org)
u, err := addOptions(u, opts)
if err != nil {
Expand Down
17 changes: 12 additions & 5 deletions github/orgs_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {

mux.HandleFunc("/orgs/o/properties/values", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"page": "1", "per_page": "100"})
testFormValues(t, r, values{
"page": "1",
"per_page": "100",
"repository_query": "repo:octocat/Hello-World",
})
fmt.Fprint(w, `[{
"repository_id": 1296269,
"repository_name": "Hello-World",
Expand All @@ -310,9 +314,12 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
})

ctx := context.Background()
repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListOptions{
Page: 1,
PerPage: 100,
repoPropertyValues, _, err := client.Organizations.ListCustomPropertyValues(ctx, "o", &ListCustomPropertyValuesOptions{
ListOptions: ListOptions{
Page: 1,
PerPage: 100,
},
RepositoryQuery: "repo:octocat/Hello-World",
})
if err != nil {
t.Errorf("Organizations.ListCustomPropertyValues returned error: %v", err)
Expand Down Expand Up @@ -351,7 +358,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
const methodName = "ListCustomPropertyValues"

testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListOptions{})
_, _, err = client.Organizations.ListCustomPropertyValues(ctx, "\n", &ListCustomPropertyValuesOptions{})
return err
})

Expand Down
Loading