Repository: google/go-github
File: github/orgs_immutable_releases.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"
)

// 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

Review comment (suggestion):
If this field is required, please remove the `omitempty`.
Otherwise, please keep the `omitempty` and change its type from `string` to `*string`.
Same for similar fields in this PR that use `string` with `omitempty`.

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"
)

// 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)