This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.webapps.galaxy.api.licenses

from typing import List

from fastapi import (
from fastapi.routing import APIRouter
from fastapi_utils.cbv import cbv

from galaxy.managers.licenses import (
from galaxy.web import expose_api_anonymous_and_sessionless
from galaxy.webapps.base.controller import BaseAPIController

router = APIRouter(tags=['licenses'])

LicenseIdPath: str = Path(
    ...,  # Mark this Path parameter as required
    title="SPDX license short ID",
    description="The [SPDX license short identifier](https://spdx.github.io/spdx-spec/appendix-I-SPDX-license-list/)",

[docs]def get_licenses_manager() -> LicensesManager: return LicensesManager()
[docs]@cbv(router) class FastAPILicenses: licenses_manager: LicensesManager = Depends(get_licenses_manager)
[docs] @router.get('/api/licenses', summary="Lists all available SPDX licenses", response_model=List[LicenseMetadataModel], response_description="List of SPDX licenses") async def index(self) -> List[LicenseMetadataModel]: """Returns an index with all the available [SPDX licenses](https://spdx.org/licenses/).""" return self.licenses_manager.get_licenses()
[docs] @router.get('/api/licenses/{id}', summary="Gets the SPDX license metadata associated with the short identifier", response_model=LicenseMetadataModel, response_description="SPDX license metadata") async def get(self, id=LicenseIdPath) -> LicenseMetadataModel: """Returns the license metadata associated with the given [SPDX license short ID](https://spdx.github.io/spdx-spec/appendix-I-SPDX-license-list/).""" return self.licenses_manager.get_license_by_id(id)
[docs]class LicensesController(BaseAPIController):
[docs] def __init__(self, app): self.licenses_manager = LicensesManager()
[docs] @expose_api_anonymous_and_sessionless def index(self, trans, **kwd): """ GET /api/licenses Return an index of known licenses. """ return self.licenses_manager.index()
[docs] @expose_api_anonymous_and_sessionless def get(self, trans, id, **kwd): """ GET /api/licenses/<license_id> Return license metadata by URI or SPDX id. """ license_id = id return self.licenses_manager.get_license_by_id(license_id)