Skip to content
Open
54 changes: 54 additions & 0 deletions github/copilot_cloud_agent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2026 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"
"encoding/json"
"fmt"
)

// CopilotCloudAgentConfiguration represents the Copilot cloud agent configuration for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/copilot/copilot-cloud-agent-management?apiVersion=2026-03-10#get-copilot-cloud-agent-configuration-for-a-repository
type CopilotCloudAgentConfiguration struct {
Comment thread
maishivamhoo123 marked this conversation as resolved.
McpConfiguration *json.RawMessage `json:"mcp_configuration"`
EnabledTools *CopilotCloudAgentEnabledTools `json:"enabled_tools"`
RequireActionsWorkflowApproval bool `json:"require_actions_workflow_approval"`
IsFirewallEnabled bool `json:"is_firewall_enabled"`
IsFirewallRecommendedAllowlistEnabled bool `json:"is_firewall_recommended_allowlist_enabled"`
CustomAllowlist []string `json:"custom_allowlist"`
}

// CopilotCloudAgentEnabledTools represents the enabled review tools for Copilot cloud agent.
type CopilotCloudAgentEnabledTools struct {
Codeql bool `json:"codeql"`
CopilotCodeReview bool `json:"copilot_code_review"`
SecretScanning bool `json:"secret_scanning"`
DependencyVulnerabilityChecks bool `json:"dependency_vulnerability_checks"`
}

// GetCloudAgentConfiguration gets the Copilot cloud agent configuration for a repository.
//
// GitHub API docs: https://docs.github.com/rest/copilot/copilot-cloud-agent-management?apiVersion=2022-11-28#get-copilot-cloud-agent-configuration-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/copilot/cloud-agent/configuration
func (s *CopilotService) GetCloudAgentConfiguration(ctx context.Context, owner, repo string) (*CopilotCloudAgentConfiguration, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/copilot/cloud-agent/configuration", owner, repo)

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

var config *CopilotCloudAgentConfiguration
resp, err := s.client.Do(req, &config)
Comment thread
maishivamhoo123 marked this conversation as resolved.
if err != nil {
return nil, resp, err
}

return config, resp, nil
}
Loading