MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / GitHubService

Class GitHubService

scripts/agents/devops/src/github/github.py:55–922  ·  view source on GitHub ↗

Service class for interacting with GitHub APIs. Provides methods for managing repositories, content, branches, pull requests, and other GitHub resources, with caching and error handling.

Source from the content-addressed store, hash-verified

53
54
55class GitHubService:
56 """
57 Service class for interacting with GitHub APIs.
58
59 Provides methods for managing repositories, content, branches, pull requests,
60 and other GitHub resources, with caching and error handling.
61 """
62
63 def __init__(
64 self,
65 token: Optional[str] = None,
66 api_url: str = DEFAULT_API_URL,
67 organization: Optional[str] = None,
68 use_agent_endpoint: bool = False,
69 agent_url: Optional[str] = None
70 ):
71 """
72 Initialize the GitHub service.
73
74 Args:
75 token: GitHub API token. If None, will be loaded from credentials manager.
76 api_url: GitHub API URL, defaults to public GitHub API.
77 organization: Default GitHub organization to use.
78 use_agent_endpoint: Whether to use the agent endpoint instead of direct GitHub API.
79 agent_url: URL of the agent endpoint, if use_agent_endpoint is True.
80
81 Raises:
82 AuthenticationError: If token is not provided and cannot be loaded.
83 """
84 self.api_url = api_url
85 self.organization = organization
86 self.use_agent_endpoint = use_agent_endpoint
87 self.agent_url = agent_url
88
89 # Set up credentials
90 if token:
91 self.token = token
92 else:
93 cred_manager = get_credential_manager()
94 try:
95 github_credentials = cred_manager.get_github_credentials()
96 self.token = github_credentials.token
97 except Exception as e:
98 raise AuthenticationError(f"Failed to get GitHub token: {e}")
99
100 if not self.token:
101 raise AuthenticationError("GitHub token is required")
102
103 # Load configuration
104 self.config = get_config()
105
106 # If no organization is provided, try to get from config or env
107 if not self.organization:
108 self.organization = (
109 self.config.get("github.organization") or
110 os.environ.get("GITHUB_ORG") or
111 None
112 )

Callers 5

github_serviceFunction · 0.90
mainFunction · 0.90
handle_github_commandFunction · 0.85
handle_deploy_commandFunction · 0.85
deploy_from_githubMethod · 0.85

Calls

no outgoing calls

Tested by 1

github_serviceFunction · 0.72