Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/routers/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ...types.scalars import StrictDateTime
from .. import iri_router
from ..error_handlers import DEFAULT_RESPONSES
from ..iri_meta import iri_meta_dict
from . import facility_adapter, models

router = iri_router.IriRouter(
Expand All @@ -21,6 +22,7 @@
responses=DEFAULT_RESPONSES,
operation_id="getCapabilities",
response_model_exclude_none=True,
openapi_extra=iri_meta_dict("production", "required")
)
async def get_capabilities(
request: Request,
Expand All @@ -39,6 +41,7 @@ async def get_capabilities(
description="Get a single capability at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getCapability",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_capability(
capability_id: str,
Expand All @@ -60,6 +63,7 @@ async def get_capability(
description="Get a list of projects for the currently authenticated user at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getProjects",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_projects(
request: Request,
Expand All @@ -78,6 +82,7 @@ async def get_projects(
description="Get a single project at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getProject",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_project(
project_id: str,
Expand All @@ -101,6 +106,7 @@ async def get_project(
description="Get a list of allocations for the currently authenticated user's projects at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getProjectAllocationsByProject",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_project_allocations(
project_id: str,
Expand All @@ -124,6 +130,7 @@ async def get_project_allocations(
description="Get a single project allocation at this facility for this user.",
responses=DEFAULT_RESPONSES,
operation_id="getProjectAllocationByProject",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_project_allocation(
project_id: str,
Expand Down Expand Up @@ -152,6 +159,7 @@ async def get_project_allocation(
description="Get a list of user allocations for the currently authenticated user's projects at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getUserAllocationsByProjectAllocation",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_user_allocations(
project_id: str,
Expand Down Expand Up @@ -180,6 +188,7 @@ async def get_user_allocations(
description="Get a user allocation for the currently authenticated user's projects at this facility.",
responses=DEFAULT_RESPONSES,
operation_id="getUserAllocationByProjectAllocation",
openapi_extra=iri_meta_dict("production", "required")
)
async def get_user_allocation(
project_id: str,
Expand Down
6 changes: 6 additions & 0 deletions app/routers/compute/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ...types.scalars import StrictHTTPBool
from .. import iri_router
from ..error_handlers import DEFAULT_RESPONSES
from ..iri_meta import iri_meta_dict
from ..status.status import router as status_router
from . import facility_adapter, models

Expand All @@ -23,6 +24,7 @@
response_model_exclude_unset=True,
responses=DEFAULT_RESPONSES,
operation_id="launchJob",
openapi_extra=iri_meta_dict("beta", "required")
)
async def submit_job(
resource_id: str,
Expand Down Expand Up @@ -94,6 +96,7 @@ async def submit_job(
response_model_exclude_unset=True,
responses=DEFAULT_RESPONSES,
operation_id="updateJob",
openapi_extra=iri_meta_dict("beta", "required")
)
async def update_job(
resource_id: str,
Expand Down Expand Up @@ -129,6 +132,7 @@ async def update_job(
response_model_exclude_unset=True,
responses=DEFAULT_RESPONSES,
operation_id="getJob",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_job_status(
resource_id: str,
Expand Down Expand Up @@ -159,6 +163,7 @@ async def get_job_status(
response_model_exclude_unset=True,
responses=DEFAULT_RESPONSES,
operation_id="getJobs",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_job_statuses(
resource_id: str,
Expand Down Expand Up @@ -192,6 +197,7 @@ async def get_job_statuses(
response_model_exclude_unset=True,
responses=DEFAULT_RESPONSES,
operation_id="cancelJob",
openapi_extra=iri_meta_dict("beta", "required")
)
async def cancel_job(
resource_id: str,
Expand Down
17 changes: 13 additions & 4 deletions app/routers/facility/facility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
from ...types.scalars import StrictDateTime
from .. import iri_router
from ..error_handlers import DEFAULT_RESPONSES
from ..iri_meta import iri_meta_dict
from . import facility_adapter, models

router = iri_router.IriRouter(facility_adapter.FacilityAdapter, prefix="/facility", tags=["facility"])


@router.get("", responses=DEFAULT_RESPONSES, operation_id="getFacility", response_model_exclude_none=True,)
@router.get("/", responses=DEFAULT_RESPONSES, operation_id="getFacilityWithSlash", response_model_exclude_none=True, include_in_schema=False,)
@router.get("",
responses=DEFAULT_RESPONSES,
operation_id="getFacility",
response_model_exclude_none=True,
openapi_extra=iri_meta_dict("production", "required"))
@router.get("/",
responses=DEFAULT_RESPONSES,
operation_id="getFacilityWithSlash",
response_model_exclude_none=True,
include_in_schema=False)
async def get_facility(
request: Request,
modified_since: StrictDateTime = Query(default=None),
Expand All @@ -23,7 +32,7 @@ async def get_facility(
return facility


@router.get("/sites", responses=DEFAULT_RESPONSES, operation_id="getSites", response_model_exclude_none=True,)
@router.get("/sites", responses=DEFAULT_RESPONSES, operation_id="getSites", response_model_exclude_none=True, openapi_extra=iri_meta_dict("production", "required"))
async def list_sites(
request: Request,
modified_since: StrictDateTime = Query(default=None),
Expand All @@ -40,7 +49,7 @@ async def list_sites(
return sites


@router.get("/sites/{site_id}", responses=DEFAULT_RESPONSES, operation_id="getSite", response_model_exclude_none=True,)
@router.get("/sites/{site_id}", responses=DEFAULT_RESPONSES, operation_id="getSite", response_model_exclude_none=True, openapi_extra=iri_meta_dict("production", "required"))
async def get_site(
request: Request,
site_id: str,
Expand Down
19 changes: 19 additions & 0 deletions app/routers/filesystem/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from fastapi import Depends, HTTPException, status, Query, Request, File, UploadFile
from .. import iri_router
from ..error_handlers import DEFAULT_RESPONSES
from ..iri_meta import iri_meta_dict
from ..status.status import router as status_router, models as status_models
from ..account.account import models as account_models
from ..task import facility_adapter as task_facility_adapter, models as task_models
Expand Down Expand Up @@ -47,6 +48,7 @@ async def _user_resource(
response_description="File permissions changed successfully",
responses=DEFAULT_RESPONSES,
operation_id="chmod",
openapi_extra=iri_meta_dict("beta", "required")
)
async def put_chmod(
resource_id: str,
Expand Down Expand Up @@ -76,6 +78,7 @@ async def put_chmod(
response_description="File ownership changed successfully",
responses=DEFAULT_RESPONSES,
operation_id="chown",
openapi_extra=iri_meta_dict("beta", "required")
)
async def put_chown(
resource_id: str,
Expand Down Expand Up @@ -105,6 +108,7 @@ async def put_chown(
response_description="Type returned successfully",
responses=DEFAULT_RESPONSES,
operation_id="file",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_file(
resource_id: str,
Expand Down Expand Up @@ -134,6 +138,7 @@ async def get_file(
response_description="Stat returned successfully",
responses=DEFAULT_RESPONSES,
operation_id="stat",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_stat(
resource_id: str,
Expand Down Expand Up @@ -165,6 +170,7 @@ async def get_stat(
response_description="Directory created successfully",
responses=DEFAULT_RESPONSES,
operation_id="mkdir",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_mkdir(
resource_id: str,
Expand Down Expand Up @@ -194,6 +200,7 @@ async def post_mkdir(
response_description="Symlink created successfully",
responses=DEFAULT_RESPONSES,
operation_id="symlink",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_symlink(
resource_id: str,
Expand Down Expand Up @@ -224,6 +231,7 @@ async def post_symlink(
include_in_schema=router.task_adapter is not None,
responses=DEFAULT_RESPONSES,
operation_id="ls",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_ls_async(
resource_id: str,
Expand Down Expand Up @@ -261,6 +269,7 @@ async def get_ls_async(
response_description="Head operation finished successfully",
responses=DEFAULT_RESPONSES,
operation_id="head",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_head(
resource_id: str,
Expand Down Expand Up @@ -321,6 +330,7 @@ async def get_head(
response_description="View operation finished successfully",
responses=DEFAULT_RESPONSES,
operation_id="view",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_view(
resource_id: str,
Expand Down Expand Up @@ -355,6 +365,7 @@ async def get_view(
response_description="`tail` operation finished successfully",
responses=DEFAULT_RESPONSES,
operation_id="tail",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_tail(
resource_id: str,
Expand Down Expand Up @@ -408,6 +419,7 @@ async def get_tail(
response_description="Checksum returned successfully",
responses=DEFAULT_RESPONSES,
operation_id="checksum",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_checksum(
resource_id: str,
Expand Down Expand Up @@ -435,6 +447,7 @@ async def get_checksum(
response_description="File or directory deleted successfully",
responses=DEFAULT_RESPONSES,
operation_id="rm",
openapi_extra=iri_meta_dict("beta", "required")
)
async def delete_rm(
resource_id: str,
Expand Down Expand Up @@ -464,6 +477,7 @@ async def delete_rm(
response_description="File and/or directories compressed successfully",
responses=DEFAULT_RESPONSES,
operation_id="compress",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_compress(
resource_id: str,
Expand Down Expand Up @@ -493,6 +507,7 @@ async def post_compress(
response_description="File extracted successfully",
responses=DEFAULT_RESPONSES,
operation_id="extract",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_extract(
resource_id: str,
Expand Down Expand Up @@ -522,6 +537,7 @@ async def post_extract(
response_description="Move file or directory operation created successfully",
responses=DEFAULT_RESPONSES,
operation_id="mv",
openapi_extra=iri_meta_dict("beta", "required")
)
async def move_mv(
resource_id: str,
Expand Down Expand Up @@ -551,6 +567,7 @@ async def move_mv(
response_description="Copy file or directory operation created successfully",
responses=DEFAULT_RESPONSES,
operation_id="cp",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_cp(
resource_id: str,
Expand Down Expand Up @@ -580,6 +597,7 @@ async def post_cp(
response_description="File downloaded successfully",
responses=DEFAULT_RESPONSES,
operation_id="download",
openapi_extra=iri_meta_dict("beta", "required")
)
async def get_download(
resource_id: str,
Expand Down Expand Up @@ -609,6 +627,7 @@ async def get_download(
response_description="File uploaded successfully",
responses=DEFAULT_RESPONSES,
operation_id="upload",
openapi_extra=iri_meta_dict("beta", "required")
)
async def post_upload(
resource_id: str,
Expand Down
38 changes: 38 additions & 0 deletions app/routers/iri_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
"""
Utility for generating the IRI OpenAPI extension metadata.
It generates:
{
"x-iri": {
"maturity": "production",
"implementation": {
"level": "required",
"required_if_capability": "dpu"
}
}
}
"""


def iri_meta_dict(
maturity: str | None = None,
implementation_level: str | None = None,
required_if: str | None = None,
) -> dict:
"""Generate the IRI OpenAPI extension metadata."""

out_obj = {}

if maturity is not None:
out_obj["maturity"] = maturity

if implementation_level is not None:
out_obj.setdefault("implementation", {})["level"] = implementation_level

if required_if is not None:
out_obj.setdefault("implementation", {})["required_if_capability"] = required_if

if not out_obj:
return {}

return {"x-iri": out_obj}
Loading
Loading