Skip to content
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

Updating collection self link for collections page. #297

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Updated CollectionLinks to generate correct `self` link for collections endpoint. [#297](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/297)
- Refactored aggregation in database logic. [#294](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/294)
- Fixed the `self` link for the `/collections/{collection_id}/aggregations` endpoint. [#295](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/295)

Expand Down
8 changes: 8 additions & 0 deletions stac_fastapi/core/stac_fastapi/core/models/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class CollectionLinks(BaseLinks):
collection_id: str = attr.ib()
extensions: List[str] = attr.ib(default=attr.Factory(list))

def link_self(self) -> Dict:
"""Return the self link."""
return dict(
rel=Relations.self.value,
type=MimeTypes.json.value,
href=urljoin(self.base_url, f"collections/{self.collection_id}"),
)

def link_parent(self) -> Dict[str, Any]:
"""Create the `parent` link."""
return dict(rel=Relations.parent, type=MimeTypes.json.value, href=self.base_url)
Expand Down