def register_post_search(self): """Register search endpoint (POST /search). Returns: None """ search_request_model = _create_request_model(self.search_request_model) fields_ext = self.get_extension(FieldsExtension) self.router.add_api_route( name="Search", path="/search", response_model=(ItemCollection if not fields_ext else None) if self.settings.enable_response_models else None, response_class=self.response_class, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["POST"], endpoint=self._create_endpoint( self.client.post_search, search_request_model ), )
def register(self, app: FastAPI) -> None: """Register the extension with a FastAPI application. Args: app: target FastAPI application. Returns: None """ items_request_model = _create_request_model(Items) router = APIRouter() router.add_api_route( name="Bulk Create Item", path="/collections/{collectionId}/bulk_items", response_model=str, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["POST"], endpoint=create_sync_endpoint(self.client.bulk_item_insert, items_request_model), ) app.include_router(router, tags=["Bulk Transaction Extension"])
def register(self, app: FastAPI) -> None: """Register the extension with a FastAPI application. Args: app: target FastAPI application. Returns: None """ item_request_model = _create_request_model(Item) collection_request_model = _create_request_model(Collection) router = APIRouter() router.add_api_route( name="Create Item", path="/collections/{collectionId}/items", response_model=Item, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["POST"], endpoint=create_endpoint(self.client.create_item, item_request_model), ) router.add_api_route( name="Update Item", path="/collections/{collectionId}/items", response_model=Item, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["PUT"], endpoint=create_endpoint(self.client.update_item, item_request_model), ) router.add_api_route( name="Delete Item", path="/collections/{collectionId}/items/{itemId}", response_model=Item, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["DELETE"], endpoint=create_endpoint(self.client.delete_item, ItemUri), ) router.add_api_route( name="Create Collection", path="/collections", response_model=Collection, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["POST"], endpoint=create_endpoint( self.client.create_collection, collection_request_model ), ) router.add_api_route( name="Update Collection", path="/collections", response_model=Collection, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["PUT"], endpoint=create_endpoint( self.client.update_collection, collection_request_model ), ) router.add_api_route( name="Delete Collection", path="/collections/{collectionId}", response_model=Collection, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["DELETE"], endpoint=create_endpoint(self.client.delete_collection, CollectionUri), ) app.include_router(router, tags=["Transaction Extension"])
def register_core(self): """Register core STAC endpoints. GET / GET /conformance GET /collections GET /collections/{collectionId} GET /collections/{collectionId}/items GET /collection/{collectionId}/items/{itemId} GET /search POST /search Injects application logic (StacApi.client) into the API layer. Returns: None """ search_request_model = _create_request_model(self.search_request_model) fields_ext = self.get_extension(FieldsExtension) router = APIRouter() router.add_api_route( name="Landing Page", path="/", response_model=LandingPage, response_model_exclude_unset=False, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.landing_page, EmptyRequest), ) router.add_api_route( name="Conformance Classes", path="/conformance", response_model=ConformanceClasses, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.conformance, EmptyRequest), ) router.add_api_route( name="Get Item", path="/collections/{collectionId}/items/{itemId}", response_model=Item, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.get_item, ItemUri), ) router.add_api_route( name="Search", path="/search", response_model=ItemCollection if not fields_ext else None, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["POST"], endpoint=create_endpoint(self.client.post_search, search_request_model), ), router.add_api_route( name="Search", path="/search", response_model=ItemCollection if not fields_ext else None, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.get_search, SearchGetRequest), ) router.add_api_route( name="Get Collections", path="/collections", response_model=List[Collection], response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.all_collections, EmptyRequest), ) router.add_api_route( name="Get Collection", path="/collections/{collectionId}", response_model=Collection, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.get_collection, CollectionUri), ) router.add_api_route( name="Get ItemCollection", path="/collections/{collectionId}/items", response_model=ItemCollection, response_model_exclude_unset=True, response_model_exclude_none=True, methods=["GET"], endpoint=create_endpoint(self.client.item_collection, ItemCollectionUri), ) self.app.include_router(router)