-
Notifications
You must be signed in to change notification settings - Fork 115
Adding free-text extension. #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vincentsarago
merged 6 commits into
stac-utils:main
from
rhysrevans3:freetext-search-ext
Jul 19, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0a10b00
Adding free-text extension.
rhysrevans3 0b54e63
Adding pull request to change log.
rhysrevans3 461cd45
q parameter should be string for post.
rhysrevans3 195433c
Removing unneeded imports.
rhysrevans3 6bc4ce3
update and refactor
vincentsarago 5be3671
split free-text ext
vincentsarago File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 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[str] = attr.ib(default=None) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.