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

Code before:

package github

import (
	"context"
	"fmt"
)

// ImmutableReleaseSettings represents the response from the immutable releases settings endpoint.
type ImmutableReleaseSettings struct {
	// EnforcedRepositories specifies how immutable releases are enforced in the organization.
	// Possible values include "all", "none", or "selected".
	EnforcedRepositories string `json:"enforced_repositories,omitempty"`
	// SelectedRepositoriesURL provides the API URL for managing the repositories
	// selected for immutable releases enforcement when EnforcedRepositories is set to "selected".
	SelectedRepositoriesURL *string `json:"selected_repositories_url,omitempty"`
}

// ImmutableReleaseRepository for seting the immutable releases policy for repositories in an organization.
type ImmutableReleaseRepository struct {
	// EnforcedRepositories specifies how immutable releases are enforced in the organization.
	// Possible values include "all", "none", or "selected".
	EnforcedRepositories string `json:"enforced_repositories"`
	// An array of repository ids for which immutable releases enforcement should be applied.
	// You can only provide a list of repository ids when the enforced_repositories is set to "selected"
	SelectedRepositoriesIDs []int64 `json:"selected_repository_ids,omitempty"`
}

// SelectedRepositories represents the request body for setting repositories.
type SelectedRepositories struct {
	// An array of repository ids for which immutable releases enforcement should be applied.
	// You can only provide a list of repository ids when the enforced_repositories is set to "selected"
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids"`
}

// GetImmutableReleasesSettings gets immutable releases settings for an organization.
//
// This endpoint returns the immutable releases configuration that applies to repositories
// within the given organization.
//
// GitHub API docs: https://docs.github.com/rest/orgs/orgs#get-immutable-releases-settings-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/immutable-releases
func (s *OrganizationsService) GetImmutableReleasesSettings(ctx context.Context, org string) (*ImmutableReleaseSettings, *Response, error) {
	u := fmt.Sprintf("orgs/%v/settings/immutable-releases", org)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}


Review comment (suggestion):
```suggestion
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
```

This will eventually be caught by #3757.

Code after:

package github

import (
	"context"
	"fmt"
)

// ImmutableReleaseSettings represents the response from the immutable releases settings endpoint.
type ImmutableReleaseSettings struct {
	// EnforcedRepositories specifies how immutable releases are enforced in the organization. Possible values include "all", "none", or "selected".
	EnforcedRepositories *string `json:"enforced_repositories,omitempty"`
	// SelectedRepositoriesURL provides the API URL for managing the repositories
	// selected for immutable releases enforcement when EnforcedRepositories is set to "selected".
	SelectedRepositoriesURL *string `json:"selected_repositories_url,omitempty"`
}

// ImmutableReleasePolicy is for setting the immutable releases policy for repositories in an organization.
type ImmutableReleasePolicy struct {
	// EnforcedRepositories specifies how immutable releases are enforced in the organization. Possible values include "all", "none", or "selected".
	EnforcedRepositories *string `json:"enforced_repositories,omitempty"`
	// An array of repository ids for which immutable releases enforcement should be applied.
	// You can only provide a list of repository ids when the enforced_repositories is set to "selected"
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
}

// setImmutableReleasesRepositoriesOptions represents the request body for setting repositories.
type setImmutableReleasesRepositoriesOptions struct {
	SelectedRepositoryIDs []int64 `json:"selected_repository_ids"`
}

// GetImmutableReleasesSettings returns the immutable releases configuration that applies to repositories within the given organization.
//
// GitHub API docs: https://docs.github.com/rest/orgs/orgs#get-immutable-releases-settings-for-an-organization
//
//meta:operation GET /orgs/{org}/settings/immutable-releases
func (s *OrganizationsService) GetImmutableReleasesSettings(ctx context.Context, org string) (*ImmutableReleaseSettings, *Response, error) {
	u := fmt.Sprintf("orgs/%v/settings/immutable-releases", org)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var settings *ImmutableReleaseSettings
	resp, err := s.client.Do(ctx, req, &settings)
	if err != nil {
		return nil, resp, err
	}

	return settings, resp, nil