Skip to content

extension

stac_fastapi.types.extension

Base api extension.

ApiExtension

Bases: ABC

Abstract base class for defining API extensions.

Source code in stac_fastapi/types/extension.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@attr.s
class ApiExtension(abc.ABC):
    """Abstract base class for defining API extensions."""

    GET = None
    POST = None

    def get_request_model(self, verb: str = "GET") -> Optional[BaseModel]:
        """Return the request model for the extension.method.

        The model can differ based on HTTP verb
        """
        return getattr(self, verb)

    conformance_classes: List[str] = attr.ib(factory=list)
    schema_href: Optional[str] = attr.ib(default=None)

    @abc.abstractmethod
    def register(self, app: FastAPI) -> None:
        """Register the extension with a FastAPI application.

        Args:
            app: target FastAPI application.

        Returns:
            None
        """
        pass

get_request_model

get_request_model(verb: str = 'GET') -> Optional[BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

Source code in stac_fastapi/types/extension.py
18
19
20
21
22
23
def get_request_model(self, verb: str = "GET") -> Optional[BaseModel]:
    """Return the request model for the extension.method.

    The model can differ based on HTTP verb
    """
    return getattr(self, verb)

register abstractmethod

register(app: FastAPI) -> None

Register the extension with a FastAPI application.

Parameters:

  • app (FastAPI) –

    target FastAPI application.

Returns:

  • None

    None

Source code in stac_fastapi/types/extension.py
28
29
30
31
32
33
34
35
36
37
38
@abc.abstractmethod
def register(self, app: FastAPI) -> None:
    """Register the extension with a FastAPI application.

    Args:
        app: target FastAPI application.

    Returns:
        None
    """
    pass