stac-fastapi-opensearch 4.2.0__py3-none-any.whl → 5.0.0__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.
@@ -11,14 +11,12 @@ from stac_fastapi.api.models import create_get_request_model, create_post_reques
11
11
  from stac_fastapi.core.core import (
12
12
  BulkTransactionsClient,
13
13
  CoreClient,
14
- EsAsyncBaseFiltersClient,
15
14
  TransactionsClient,
16
15
  )
17
16
  from stac_fastapi.core.extensions import QueryExtension
18
17
  from stac_fastapi.core.extensions.aggregation import (
19
18
  EsAggregationExtensionGetRequest,
20
19
  EsAggregationExtensionPostRequest,
21
- EsAsyncAggregationClient,
22
20
  )
23
21
  from stac_fastapi.core.extensions.fields import FieldsExtension
24
22
  from stac_fastapi.core.rate_limit import setup_rate_limit
@@ -33,6 +31,7 @@ from stac_fastapi.extensions.core import (
33
31
  TokenPaginationExtension,
34
32
  TransactionExtension,
35
33
  )
34
+ from stac_fastapi.extensions.core.filter import FilterConformanceClasses
36
35
  from stac_fastapi.extensions.third_party import BulkTransactionExtension
37
36
  from stac_fastapi.opensearch.config import OpensearchSettings
38
37
  from stac_fastapi.opensearch.database_logic import (
@@ -40,6 +39,8 @@ from stac_fastapi.opensearch.database_logic import (
40
39
  create_collection_index,
41
40
  create_index_templates,
42
41
  )
42
+ from stac_fastapi.sfeos_helpers.aggregation import EsAsyncBaseAggregationClient
43
+ from stac_fastapi.sfeos_helpers.filter import EsAsyncBaseFiltersClient
43
44
 
44
45
  logging.basicConfig(level=logging.INFO)
45
46
  logger = logging.getLogger(__name__)
@@ -56,11 +57,11 @@ filter_extension = FilterExtension(
56
57
  client=EsAsyncBaseFiltersClient(database=database_logic)
57
58
  )
58
59
  filter_extension.conformance_classes.append(
59
- "http://www.opengis.net/spec/cql2/1.0/conf/advanced-comparison-operators"
60
+ FilterConformanceClasses.ADVANCED_COMPARISON_OPERATORS
60
61
  )
61
62
 
62
63
  aggregation_extension = AggregationExtension(
63
- client=EsAsyncAggregationClient(
64
+ client=EsAsyncBaseAggregationClient(
64
65
  database=database_logic, session=session, settings=settings
65
66
  )
66
67
  )
@@ -104,22 +105,24 @@ database_logic.extensions = [type(ext).__name__ for ext in extensions]
104
105
 
105
106
  post_request_model = create_post_request_model(search_extensions)
106
107
 
107
- api = StacApi(
108
- title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-opensearch"),
109
- description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-opensearch"),
110
- api_version=os.getenv("STAC_FASTAPI_VERSION", "4.2.0"),
111
- settings=settings,
112
- extensions=extensions,
113
- client=CoreClient(
108
+ app_config = {
109
+ "title": os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-opensearch"),
110
+ "description": os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-opensearch"),
111
+ "api_version": os.getenv("STAC_FASTAPI_VERSION", "5.0.0"),
112
+ "settings": settings,
113
+ "extensions": extensions,
114
+ "client": CoreClient(
114
115
  database=database_logic,
115
116
  session=session,
116
117
  post_request_model=post_request_model,
117
118
  landing_page_id=os.getenv("STAC_FASTAPI_LANDING_PAGE_ID", "stac-fastapi"),
118
119
  ),
119
- search_get_request_model=create_get_request_model(search_extensions),
120
- search_post_request_model=post_request_model,
121
- route_dependencies=get_route_dependencies(),
122
- )
120
+ "search_get_request_model": create_get_request_model(search_extensions),
121
+ "search_post_request_model": post_request_model,
122
+ "route_dependencies": get_route_dependencies(),
123
+ }
124
+
125
+ api = StacApi(**app_config)
123
126
 
124
127
 
125
128
  @asynccontextmanager
@@ -8,7 +8,8 @@ import certifi
8
8
  from opensearchpy import AsyncOpenSearch, OpenSearch
9
9
 
10
10
  from stac_fastapi.core.base_settings import ApiBaseSettings
11
- from stac_fastapi.core.utilities import get_bool_env, validate_refresh
11
+ from stac_fastapi.core.utilities import get_bool_env
12
+ from stac_fastapi.sfeos_helpers.database import validate_refresh
12
13
  from stac_fastapi.types.config import ApiSettings
13
14
 
14
15
 
@@ -39,18 +40,6 @@ def _es_config() -> Dict[str, Any]:
39
40
  if http_compress:
40
41
  config["http_compress"] = True
41
42
 
42
- # Explicitly exclude SSL settings when not using SSL
43
- if not use_ssl:
44
- return config
45
-
46
- # Include SSL settings if using https
47
- config["ssl_version"] = ssl.PROTOCOL_SSLv23
48
- config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)
49
-
50
- # Include CA Certificates if verifying certs
51
- if config["verify_certs"]:
52
- config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())
53
-
54
43
  # Handle authentication
55
44
  if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
56
45
  config["http_auth"] = (u, p)
@@ -64,6 +53,18 @@ def _es_config() -> Dict[str, Any]:
64
53
 
65
54
  config["headers"] = headers
66
55
 
56
+ # Explicitly exclude SSL settings when not using SSL
57
+ if not use_ssl:
58
+ return config
59
+
60
+ # Include SSL settings if using https
61
+ config["ssl_version"] = ssl.PROTOCOL_SSLv23
62
+ config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)
63
+
64
+ # Include CA Certificates if verifying certs
65
+ if config["verify_certs"]:
66
+ config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())
67
+
67
68
  return config
68
69
 
69
70