MCPcopy Index your code
hub / github.com/AgentOps-AI/agentops / __call__

Method __call__

app/api/agentops/deploy/views/setup.py:68–127  ·  view source on GitHub ↗
(
        self,
        project_id: str,
        orm: Session = Depends(get_orm_session),
    )

Source from the content-addressed store, hash-verified

66 """
67
68 async def __call__(
69 self,
70 project_id: str,
71 orm: Session = Depends(get_orm_session),
72 ) -> list[dict]:
73 project = HostingProjectModel.get_by_id(orm, project_id)
74 if not project:
75 raise HTTPException(status_code=404, detail="Project not found")
76 if not project.github_oath_access_token:
77 raise HTTPException(status_code=400, detail="No GitHub access token stored for this project")
78
79 headers = {
80 "Authorization": f"Bearer {project.github_oath_access_token}",
81 "Accept": "application/vnd.github+json",
82 }
83
84 all_repos = []
85 page = 1
86 per_page = 100 # Maximum allowed by GitHub API
87
88 try:
89 while True:
90 params = {
91 "page": page,
92 "per_page": per_page,
93 "sort": "created", # Sort by creation date
94 "direction": "desc" # Most recent first
95 }
96
97 resp = requests.get("https://api.github.com/user/repos", headers=headers, params=params)
98 resp.raise_for_status()
99 repos = resp.json()
100
101 # If no repos returned, we've reached the end
102 if not repos:
103 break
104
105 # Add repos from this page
106 all_repos.extend([
107 {
108 "id": repo["id"],
109 "name": repo["name"],
110 "full_name": repo["full_name"],
111 "private": repo["private"],
112 "html_url": repo["html_url"],
113 "description": repo.get("description"),
114 }
115 for repo in repos
116 ])
117
118 # If we got fewer repos than per_page, we've reached the end
119 if len(repos) < per_page:
120 break
121
122 page += 1
123
124 return all_repos
125

Callers

nothing calls this directly

Calls 4

jsonMethod · 0.80
extendMethod · 0.80
get_by_idMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected