stac-fastapi-core 6.7.2__py3-none-any.whl → 6.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
stac_fastapi/core/core.py CHANGED
@@ -137,20 +137,6 @@ class CoreClient(AsyncBaseCoreClient):
137
137
  "href": urljoin(base_url, "search"),
138
138
  "method": "POST",
139
139
  },
140
- {
141
- "rel": "collections-search",
142
- "type": "application/json",
143
- "title": "Collections Search",
144
- "href": urljoin(base_url, "collections-search"),
145
- "method": "GET",
146
- },
147
- {
148
- "rel": "collections-search",
149
- "type": "application/json",
150
- "title": "Collections Search",
151
- "href": urljoin(base_url, "collections-search"),
152
- "method": "POST",
153
- },
154
140
  ],
155
141
  stac_extensions=extension_schemas,
156
142
  )
@@ -202,6 +188,26 @@ class CoreClient(AsyncBaseCoreClient):
202
188
  ]
203
189
  )
204
190
 
191
+ if self.extension_is_enabled("CollectionsSearchEndpointExtension"):
192
+ landing_page["links"].extend(
193
+ [
194
+ {
195
+ "rel": "collections-search",
196
+ "type": "application/json",
197
+ "title": "Collections Search",
198
+ "href": urljoin(base_url, "collections-search"),
199
+ "method": "GET",
200
+ },
201
+ {
202
+ "rel": "collections-search",
203
+ "type": "application/json",
204
+ "title": "Collections Search",
205
+ "href": urljoin(base_url, "collections-search"),
206
+ "method": "POST",
207
+ },
208
+ ]
209
+ )
210
+
205
211
  # Add OpenAPI URL
206
212
  landing_page["links"].append(
207
213
  {
@@ -36,6 +36,14 @@ class RedisSentinelSettings(BaseSettings):
36
36
  raise ValueError("REDIS_DB must be a positive integer")
37
37
  return v
38
38
 
39
+ @field_validator("REDIS_MAX_CONNECTIONS", mode="before")
40
+ @classmethod
41
+ def validate_max_connections(cls, v):
42
+ """Handle empty/None values for REDIS_MAX_CONNECTIONS."""
43
+ if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]:
44
+ return None
45
+ return v
46
+
39
47
  @field_validator("REDIS_SELF_LINK_TTL")
40
48
  @classmethod
41
49
  def validate_self_link_ttl_sentinel(cls, v: int) -> int:
@@ -118,6 +126,14 @@ class RedisSettings(BaseSettings):
118
126
  raise ValueError("REDIS_DB must be a positive integer")
119
127
  return v
120
128
 
129
+ @field_validator("REDIS_MAX_CONNECTIONS", mode="before")
130
+ @classmethod
131
+ def validate_max_connections(cls, v):
132
+ """Handle empty/None values for REDIS_MAX_CONNECTIONS."""
133
+ if v in ["", "null", "Null", "NULL", "none", "None", "NONE", None]:
134
+ return None
135
+ return v
136
+
121
137
  @field_validator("REDIS_SELF_LINK_TTL")
122
138
  @classmethod
123
139
  def validate_self_link_ttl_standalone(cls, v: int) -> int:
@@ -2,6 +2,7 @@
2
2
 
3
3
  import abc
4
4
  import logging
5
+ import os
5
6
  from copy import deepcopy
6
7
  from typing import Any, List, Optional
7
8
 
@@ -10,7 +11,7 @@ from starlette.requests import Request
10
11
 
11
12
  from stac_fastapi.core.datetime_utils import now_to_rfc3339_str
12
13
  from stac_fastapi.core.models.links import CollectionLinks
13
- from stac_fastapi.core.utilities import get_bool_env
14
+ from stac_fastapi.core.utilities import get_bool_env, get_excluded_from_items
14
15
  from stac_fastapi.types import stac as stac_types
15
16
  from stac_fastapi.types.links import ItemLinks, resolve_links
16
17
 
@@ -108,7 +109,7 @@ class ItemSerializer(Serializer):
108
109
  else:
109
110
  assets = item.get("assets", {})
110
111
 
111
- return stac_types.Item(
112
+ stac_item = stac_types.Item(
112
113
  type="Feature",
113
114
  stac_version=item.get("stac_version", ""),
114
115
  stac_extensions=item.get("stac_extensions", []),
@@ -121,6 +122,14 @@ class ItemSerializer(Serializer):
121
122
  assets=assets,
122
123
  )
123
124
 
125
+ excluded_fields = os.getenv("EXCLUDED_FROM_ITEMS")
126
+ if excluded_fields:
127
+ for field_path in excluded_fields.split(","):
128
+ if field_path := field_path.strip():
129
+ get_excluded_from_items(stac_item, field_path)
130
+
131
+ return stac_item
132
+
124
133
 
125
134
  class CollectionSerializer(Serializer):
126
135
  """Serialization methods for STAC collections."""
@@ -178,3 +178,20 @@ def dict_deep_update(merge_to: Dict[str, Any], merge_from: Dict[str, Any]) -> No
178
178
  dict_deep_update(merge_to[k], merge_from[k])
179
179
  else:
180
180
  merge_to[k] = v
181
+
182
+
183
+ def get_excluded_from_items(obj: dict, field_path: str) -> None:
184
+ """Remove a field from items.
185
+
186
+ The field is removed in-place from the dictionary if it exists.
187
+ If any intermediate path does not exist or is not a dictionary,
188
+ the function returns without making any changes.
189
+ """
190
+ *path, final = field_path.split(".")
191
+ current = obj
192
+ for part in path:
193
+ current = current.get(part, {})
194
+ if not isinstance(current, dict):
195
+ return
196
+
197
+ current.pop(final, None)
@@ -1,2 +1,2 @@
1
1
  """library version."""
2
- __version__ = "6.7.2"
2
+ __version__ = "6.7.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stac_fastapi_core
3
- Version: 6.7.2
3
+ Version: 6.7.4
4
4
  Summary: Core library for the Elasticsearch and Opensearch stac-fastapi backends.
5
5
  Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
6
6
  License: MIT
@@ -2,15 +2,15 @@ stac_fastapi/core/__init__.py,sha256=8izV3IWRGdXmDOK1hIPQAanbWs9EI04PJCGgqG1ZGIs
2
2
  stac_fastapi/core/base_database_logic.py,sha256=3_XJ_j06ogQHE-Tcjkv5Vye_zNDn9OEU9lNYU03am1k,4618
3
3
  stac_fastapi/core/base_settings.py,sha256=R3_Sx7n5XpGMs3zAwFJD7y008WvGU_uI2xkaabm82Kg,239
4
4
  stac_fastapi/core/basic_auth.py,sha256=RhFv3RVSHF6OaqnaaU2DO4ncJ_S5nB1q8UNpnVJJsrk,2155
5
- stac_fastapi/core/core.py,sha256=kI_DP5kxgTWHQ5Y1X7PbhjVMF86v9pt6p9kH_QcmifA,50382
5
+ stac_fastapi/core/core.py,sha256=mmUP1da46EiON_TM2HYtxQxw8DHFg-2xEFoSg4P7UgU,50607
6
6
  stac_fastapi/core/datetime_utils.py,sha256=TrTgbU7AKNC-ic4a3HptfE5XAc9tHR7uJasZyhOuwnc,2633
7
7
  stac_fastapi/core/rate_limit.py,sha256=Gu8dAaJReGsj1L91U6m2tflU6RahpXDRs2-AYSKoybA,1318
8
- stac_fastapi/core/redis_utils.py,sha256=DRbvYWaBZA07d28PWeGOxZr_h6jH6F5cdcdr1ktr8YU,9251
8
+ stac_fastapi/core/redis_utils.py,sha256=ckfuIjOUk08ofG1ql1eGXcOPG60odzSA86rXGr6h_QA,9859
9
9
  stac_fastapi/core/route_dependencies.py,sha256=hdtuMkv-zY1vg0YxiCz1aKP0SbBcORqDGEKDGgEazW8,5482
10
- stac_fastapi/core/serializers.py,sha256=ZW5hPgq-mftk6zxJeZGur-1Qxn7YGc3fJYFLsd-SYwM,7619
10
+ stac_fastapi/core/serializers.py,sha256=HPA110RLZ17EnKrFf1rvVu5EwQHZto4V912Ofp_ypjA,7951
11
11
  stac_fastapi/core/session.py,sha256=aXqu4LXfVbAAsChMVXd9gAhczA2bZPne6HqPeklAwMY,474
12
- stac_fastapi/core/utilities.py,sha256=xXWO5oJCNDi7_C5jPYlHZD0B-DL-FN66eEUBUSW-cXw,7296
13
- stac_fastapi/core/version.py,sha256=H-rSs9N60FbjJQ3LVCd-stMghJbOR5tE16Afn_nnWVY,45
12
+ stac_fastapi/core/utilities.py,sha256=XR_9afK_j8wCydgoXj-CMtRyI8KqgIL3d4HZOE779dU,7807
13
+ stac_fastapi/core/version.py,sha256=Ao9na2IeAbio6N4Di9fhrhw069xIK8K8gKIrHf29u_Q,45
14
14
  stac_fastapi/core/extensions/__init__.py,sha256=zSIAqou8jnakWPbkh4Ddcx1-oazZVBOs7U2PAakAdU0,291
15
15
  stac_fastapi/core/extensions/aggregation.py,sha256=v1hUHqlYuMqfQ554g3cTp16pUyRYucQxPERbHPAFtf8,1878
16
16
  stac_fastapi/core/extensions/collections_search.py,sha256=xpv51nffMq5a8grNSaLbv2IzeI5JH_pqcoWRbWhzn6Y,14406
@@ -20,6 +20,6 @@ stac_fastapi/core/extensions/query.py,sha256=Xmo8pfZEZKPudZEjjozv3R0wLOP0ayjC9E6
20
20
  stac_fastapi/core/models/__init__.py,sha256=g-D1DiGfmC9Bg27DW9JzkN6fAvscv75wyhyiZ6NzvIk,48
21
21
  stac_fastapi/core/models/links.py,sha256=0dWSEMt3aa7NCISlHwo11zLBeIV1LwXG3JGjrXC3dZI,6672
22
22
  stac_fastapi/core/models/search.py,sha256=7SgAUyzHGXBXSqB4G6cwq9FMwoAS00momb7jvBkjyow,27
23
- stac_fastapi_core-6.7.2.dist-info/METADATA,sha256=2NmMCjA9Pw9CmOVi08Gy2ZEYwDMuud9z4cN8aYhQd2c,3494
24
- stac_fastapi_core-6.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
- stac_fastapi_core-6.7.2.dist-info/RECORD,,
23
+ stac_fastapi_core-6.7.4.dist-info/METADATA,sha256=-mSLWe1MTLsXHLvmifAmr9vW59AxdFX7kJMrMevmkRI,3494
24
+ stac_fastapi_core-6.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
25
+ stac_fastapi_core-6.7.4.dist-info/RECORD,,