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

Method __init__

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

Initialize the GitHub service. Args: token: GitHub API token. If None, will be loaded from credentials manager. api_url: GitHub API URL, defaults to public GitHub API. organization: Default GitHub organization to use. use_agen

(
        self,
        token: Optional[str] = None,
        api_url: str = DEFAULT_API_URL,
        organization: Optional[str] = None,
        use_agent_endpoint: bool = False,
        agent_url: Optional[str] = None
    )

Source from the content-addressed store, hash-verified

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 )
113
114 # Initialize cache
115 self.cache: Dict[str, Dict[str, Any]] = {}
116
117 # Verify access
118 self._verify_access()
119
120 def _verify_access(self) -> None:

Callers

nothing calls this directly

Calls 6

_verify_accessMethod · 0.95
get_credential_managerFunction · 0.85
get_configFunction · 0.85
AuthenticationErrorClass · 0.70
getMethod · 0.65

Tested by

no test coverage detected