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

Code before:
func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) {
	u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository)

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

	// TODO: remove custom Accept header when this API fully launches
	req.Header.Set("Accept", mediaTypeRequiredVulnerabilityAlertsPreview)

	return s.client.Do(ctx, req, nil)
}

// GetAutomatedSecurityFixes checks if the automated security fixes for a repository are enabled.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-automated-security-fixes-are-enabled-for-a-repository
func (s *RepositoriesService) GetAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*AutomatedSecurityFixes, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)

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

	// TODO: remove custom Accept header when this API fully launches
	req.Header.Set("Accept", mediaTypeRequiredAutomatedSecurityFixesPreview)

	p := new(AutomatedSecurityFixes)
	resp, err := s.client.Do(ctx, req, p)
	if err != nil {
		return nil, resp, err
	}
	return p, resp, nil
}

// EnableAutomatedSecurityFixes enables the automated security fixes for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-automated-security-fixes
func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) {
	u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)

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

	// TODO: remove custom Accept header when this API fully launches
	req.Header.Set("Accept", mediaTypeRequiredAutomatedSecurityFixesPreview)

	return s.client.Do(ctx, req, nil)

Review comment (refactor):
Looks like API docs now recommend using the common `application/vnd.github+json` header. Maybe we can remove this custom header?

Code after:
func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) {
	u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository)

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

	// TODO: remove custom Accept header when this API fully launches
	req.Header.Set("Accept", mediaTypeRequiredVulnerabilityAlertsPreview)

	return s.client.Do(ctx, req, nil)
}

// GetAutomatedSecurityFixes checks if the automated security fixes for a repository are enabled.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-automated-security-fixes-are-enabled-for-a-repository
func (s *RepositoriesService) GetAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*AutomatedSecurityFixes, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)

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

	p := new(AutomatedSecurityFixes)
	resp, err := s.client.Do(ctx, req, p)
	if err != nil {
		return nil, resp, err
	}
	return p, resp, nil
}

// EnableAutomatedSecurityFixes enables the automated security fixes for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-automated-security-fixes
func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) {
	u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository)

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

	return s.client.Do(ctx, req, nil)
}

// DisableAutomatedSecurityFixes disables vulnerability alerts and the dependency graph for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/repos/repos#disable-automated-security-fixes
func (s *RepositoriesService) DisableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) {