Skip to content

Commit

Permalink
return more than names
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Dec 30, 2024
1 parent 97fbf93 commit 0d403d6
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def initialize(self) -> None:
)
self.add_endpoint(
"/ftrackProjects",
self.get_ftrack_project_names,
self.get_ftrack_projects_info,
method="GET",
)

Expand Down Expand Up @@ -116,35 +116,34 @@ async def get_custom_processor_handlers(

return output

async def get_ftrack_project_names(
async def get_ftrack_projects_info(
self,
user: CurrentUser,
variant: str = Query("production"),
) -> {}:
# TODO validate user permissions
# - What permissions user must have to allow this endpoint?
settings = await self.get_studio_overrides(variant)
ftrack_server_url = settings.ftrack_server_url
settings = await self.get_studio_settings(variant)
ftrack_server_url = settings.ftrack_server
service_settings = settings.service_settings
api_key_secret = service_settings.api_key
username_secret = service_settings.username

projects = []
output = {
"success": False,
"error": None,
"projects": projects,
}

if not ftrack_server_url or not api_key_secret or not username_secret:
# TODO return some status code result?
return {
"success": False,
"reason": "Required settings are not set",
"project_name": [],
}
output["error"] = "Required settings are not set."
return output

ftrack_api_key = await Secrets.get(api_key_secret)
ftrack_username = await Secrets.get(username_secret)

project_names = []
output = {
"success": False,
"error": None,
"project_name": project_names,
}
if not ftrack_api_key or not ftrack_username:
# TODO return some status code result?
output["error"] = "Invalid service settings, secrets are not set."
Expand All @@ -163,10 +162,13 @@ async def get_ftrack_project_names(

if error is None:
output["success"] = True
project_names.extend([
project["full_name"]
async for project in await session.get_projects()
])
async for project in await session.get_projects():
projects.append({
"id": project["id"],
"name": project["full_name"],
"code": project["name"],
"active": project["status"] == "active",
})

output["error"] = error
return output
Expand Down

0 comments on commit 0d403d6

Please sign in to comment.