-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53711ec
commit 0a10b00
Showing
7 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
stac_fastapi/extensions/stac_fastapi/extensions/third_party/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
"""stac_api.extensions.third_party module.""" | ||
|
||
from .bulk_transactions import BulkTransactionExtension | ||
from .free_text import FreeTextExtension | ||
|
||
__all__ = ("BulkTransactionExtension",) | ||
__all__ = ( | ||
"BulkTransactionExtension", | ||
"FreeTextExtension", | ||
) |
5 changes: 5 additions & 0 deletions
5
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Query extension module.""" | ||
|
||
from .free_text import FreeTextExtension | ||
|
||
__all__ = ["FreeTextExtension"] |
46 changes: 46 additions & 0 deletions
46
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/free_text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Free-text extension.""" | ||
|
||
from typing import List, Optional | ||
|
||
import attr | ||
from fastapi import FastAPI | ||
|
||
from stac_fastapi.types.extension import ApiExtension | ||
|
||
from .request import FreeTextExtensionGetRequest, FreeTextExtensionPostRequest | ||
|
||
|
||
@attr.s | ||
class FreeTextExtension(ApiExtension): | ||
"""Free-text Extension. | ||
The Free-text extension adds an additional `q` parameter to `/search` requests which | ||
allows the caller to perform free-text queries against STAC metadata. | ||
https://github.com/stac-api-extensions/freetext-search/README.md | ||
""" | ||
|
||
GET = FreeTextExtensionGetRequest | ||
POST = FreeTextExtensionPostRequest | ||
|
||
conformance_classes: List[str] = attr.ib( | ||
factory=lambda: [ | ||
"https://api.stacspec.org/v1.0.0-rc.1/item-search#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/item-search#advanced-free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#advanced-free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#free-text", | ||
"https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#advanced-free-text", | ||
] | ||
) | ||
schema_href: Optional[str] = attr.ib(default=None) | ||
|
||
def register(self, app: FastAPI) -> None: | ||
"""Register the extension with a FastAPI application. | ||
Args: | ||
app: target FastAPI application. | ||
Returns: | ||
None | ||
""" | ||
pass |
21 changes: 21 additions & 0 deletions
21
stac_fastapi/extensions/stac_fastapi/extensions/third_party/free_text/request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Request model for the Free-text extension.""" | ||
|
||
from typing import Any, Dict, Optional | ||
|
||
import attr | ||
from pydantic import BaseModel | ||
|
||
from stac_fastapi.types.search import APIRequest | ||
|
||
|
||
@attr.s | ||
class FreeTextExtensionGetRequest(APIRequest): | ||
"""Free-text Extension GET request model.""" | ||
|
||
q: Optional[str] = attr.ib(default=None) | ||
|
||
|
||
class FreeTextExtensionPostRequest(BaseModel): | ||
"""Free-text Extension POST request model.""" | ||
|
||
q: Optional[Dict[str, Dict[str, Any]]] |