Repository: google/go-github
File: github/codespaces_orgs.go (Go)

Code before:
// 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"
)

// CodespacesOrgAccessControlRequest represent request for SetOrgAccessControl.
type CodespacesOrgAccessControlRequest struct {
	// Visibility represent which users can access codespaces in the organization.
	// Can be one of: disabled, selected_members, all_members, all_members_and_outside_collaborators.
	Visibility string `json:"visibility"`
	// SelectedUsernames represent the usernames of the organization members who should have access to codespaces in the organization.
	// Required when visibility is selected_members.
	SelectedUsernames []string `json:"selected_usernames,omitempty"`
}

// ListInOrg lists the codespaces associated to a specified organization.
//
// GitHub API docs: https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-the-organization
//
//meta:operation GET /orgs/{org}/codespaces
func (s *CodespacesService) ListInOrg(ctx context.Context, org string, opts *ListOptions) (*ListCodespaces, *Response, error) {
	u := fmt.Sprintf("orgs/%v/codespaces", org)
	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 codespaces *ListCodespaces
	resp, err := s.client.Do(ctx, req, &codespaces)
	if err != nil {
		return nil, resp, err
	}


Review comment (suggestion):
Maybe `omitzero` would be better?

```suggestion
	SelectedUsernames []string `json:"selected_usernames,omitzero"`
```

Code after:
// 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"
)

// CodespacesOrgAccessControlRequest represent request for SetOrgAccessControl.
type CodespacesOrgAccessControlRequest struct {
	// Visibility represent which users can access codespaces in the organization.
	// Can be one of: disabled, selected_members, all_members, all_members_and_outside_collaborators.
	Visibility string `json:"visibility"`
	// SelectedUsernames represent the usernames of the organization members who should have access to codespaces in the organization.
	// Required when visibility is selected_members.
	SelectedUsernames []string `json:"selected_usernames,omitzero"`
}

// ListInOrg lists the codespaces associated to a specified organization.
//
// GitHub API docs: https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-the-organization
//
//meta:operation GET /orgs/{org}/codespaces
func (s *CodespacesService) ListInOrg(ctx context.Context, org string, opts *ListOptions) (*ListCodespaces, *Response, error) {
	u := fmt.Sprintf("orgs/%v/codespaces", org)
	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 codespaces *ListCodespaces
	resp, err := s.client.Do(ctx, req, &codespaces)
	if err != nil {
		return nil, resp, err
	}