stac-fastapi.types 3.0.4__tar.gz → 4.0.0__tar.gz

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.
Files changed (24) hide show
  1. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/PKG-INFO +14 -4
  2. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/setup.py +1 -2
  3. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/core.py +4 -34
  4. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/search.py +50 -21
  5. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/version.py +1 -1
  6. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/PKG-INFO +14 -4
  7. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/README.md +0 -0
  8. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/setup.cfg +0 -0
  9. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/__init__.py +0 -0
  10. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/config.py +0 -0
  11. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/conformance.py +0 -0
  12. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/errors.py +0 -0
  13. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/extension.py +0 -0
  14. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/links.py +0 -0
  15. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/requests.py +0 -0
  16. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/rfc3339.py +0 -0
  17. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi/types/stac.py +0 -0
  18. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/SOURCES.txt +0 -0
  19. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/dependency_links.txt +0 -0
  20. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/not-zip-safe +0 -0
  21. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/requires.txt +0 -0
  22. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/stac_fastapi.types.egg-info/top_level.txt +0 -0
  23. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/tests/test_limit.py +0 -0
  24. {stac_fastapi_types-3.0.4 → stac_fastapi_types-4.0.0}/tests/test_rfc3339.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: stac-fastapi.types
3
- Version: 3.0.4
3
+ Version: 4.0.0
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -10,14 +10,13 @@ Keywords: STAC FastAPI COG
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Information Technology
12
12
  Classifier: Intended Audience :: Science/Research
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: License :: OSI Approved :: MIT License
20
- Requires-Python: >=3.8
19
+ Requires-Python: >=3.9
21
20
  Description-Content-Type: text/markdown
22
21
  Requires-Dist: fastapi>=0.109.0
23
22
  Requires-Dist: attrs>=23.2.0
@@ -34,3 +33,14 @@ Provides-Extra: docs
34
33
  Requires-Dist: mkdocs; extra == "docs"
35
34
  Requires-Dist: mkdocs-material; extra == "docs"
36
35
  Requires-Dist: pdocs; extra == "docs"
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description-content-type
40
+ Dynamic: home-page
41
+ Dynamic: keywords
42
+ Dynamic: license
43
+ Dynamic: provides-extra
44
+ Dynamic: requires-dist
45
+ Dynamic: requires-python
46
+ Dynamic: summary
@@ -30,12 +30,11 @@ setup(
30
30
  description="An implementation of STAC API based on the FastAPI framework.",
31
31
  long_description=desc,
32
32
  long_description_content_type="text/markdown",
33
- python_requires=">=3.8",
33
+ python_requires=">=3.9",
34
34
  classifiers=[
35
35
  "Intended Audience :: Developers",
36
36
  "Intended Audience :: Information Technology",
37
37
  "Intended Audience :: Science/Research",
38
- "Programming Language :: Python :: 3.8",
39
38
  "Programming Language :: Python :: 3.9",
40
39
  "Programming Language :: Python :: 3.10",
41
40
  "Programming Language :: Python :: 3.11",
@@ -1,7 +1,6 @@
1
1
  """Base clients."""
2
2
 
3
3
  import abc
4
- import warnings
5
4
  from typing import Any, Dict, List, Optional, Union
6
5
  from urllib.parse import urljoin
7
6
 
@@ -19,7 +18,6 @@ from stac_fastapi.types.config import ApiSettings
19
18
  from stac_fastapi.types.conformance import BASE_CONFORMANCE_CLASSES
20
19
  from stac_fastapi.types.extension import ApiExtension
21
20
  from stac_fastapi.types.requests import get_base_url
22
- from stac_fastapi.types.rfc3339 import DateTimeType
23
21
  from stac_fastapi.types.search import BaseSearchPostRequest
24
22
 
25
23
  __all__ = [
@@ -342,20 +340,6 @@ class BaseCoreClient(LandingPageMixin, abc.ABC):
342
340
  factory=lambda: BASE_CONFORMANCE_CLASSES
343
341
  )
344
342
  extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
345
- post_request_model = attr.ib(default=None)
346
-
347
- @post_request_model.validator
348
- def _deprecate_post_model(self, attribute, value):
349
- """Check and raise warning if `post_request_model` is set."""
350
- if value is not None:
351
- warnings.warn(
352
- "`post_request_model` attribute is deprecated and will be removed in 3.1",
353
- DeprecationWarning,
354
- )
355
-
356
- def __attrs_post_init__(self):
357
- """Set default value for post_request_model."""
358
- self.post_request_model = self.post_request_model or BaseSearchPostRequest
359
343
 
360
344
  def conformance_classes(self) -> List[str]:
361
345
  """Generate conformance classes by adding extension conformance to base
@@ -497,7 +481,7 @@ class BaseCoreClient(LandingPageMixin, abc.ABC):
497
481
  ids: Optional[List[str]] = None,
498
482
  bbox: Optional[BBox] = None,
499
483
  intersects: Optional[Geometry] = None,
500
- datetime: Optional[DateTimeType] = None,
484
+ datetime: Optional[str] = None,
501
485
  limit: Optional[int] = 10,
502
486
  **kwargs,
503
487
  ) -> stac.ItemCollection:
@@ -555,7 +539,7 @@ class BaseCoreClient(LandingPageMixin, abc.ABC):
555
539
  self,
556
540
  collection_id: str,
557
541
  bbox: Optional[BBox] = None,
558
- datetime: Optional[DateTimeType] = None,
542
+ datetime: Optional[str] = None,
559
543
  limit: int = 10,
560
544
  token: str = None,
561
545
  **kwargs,
@@ -587,20 +571,6 @@ class AsyncBaseCoreClient(LandingPageMixin, abc.ABC):
587
571
  factory=lambda: BASE_CONFORMANCE_CLASSES
588
572
  )
589
573
  extensions: List[ApiExtension] = attr.ib(default=attr.Factory(list))
590
- post_request_model = attr.ib(default=None)
591
-
592
- @post_request_model.validator
593
- def _deprecate_post_model(self, attribute, value):
594
- """Check and raise warning if `post_request_model` is set."""
595
- if value is not None:
596
- warnings.warn(
597
- "`post_request_model` attribute is deprecated and will be removed in 3.1",
598
- DeprecationWarning,
599
- )
600
-
601
- def __attrs_post_init__(self):
602
- """Set default value for post_request_model."""
603
- self.post_request_model = self.post_request_model or BaseSearchPostRequest
604
574
 
605
575
  def conformance_classes(self) -> List[str]:
606
576
  """Generate conformance classes by adding extension conformance to base
@@ -733,7 +703,7 @@ class AsyncBaseCoreClient(LandingPageMixin, abc.ABC):
733
703
  ids: Optional[List[str]] = None,
734
704
  bbox: Optional[BBox] = None,
735
705
  intersects: Optional[Geometry] = None,
736
- datetime: Optional[DateTimeType] = None,
706
+ datetime: Optional[str] = None,
737
707
  limit: Optional[int] = 10,
738
708
  **kwargs,
739
709
  ) -> stac.ItemCollection:
@@ -791,7 +761,7 @@ class AsyncBaseCoreClient(LandingPageMixin, abc.ABC):
791
761
  self,
792
762
  collection_id: str,
793
763
  bbox: Optional[BBox] = None,
794
- datetime: Optional[DateTimeType] = None,
764
+ datetime: Optional[str] = None,
795
765
  limit: int = 10,
796
766
  token: str = None,
797
767
  **kwargs,
@@ -1,7 +1,7 @@
1
1
  """stac_fastapi.types.search module.
2
2
 
3
3
  """
4
-
4
+ from datetime import datetime as dt
5
5
  from typing import Dict, List, Optional, Union
6
6
 
7
7
  import attr
@@ -83,22 +83,9 @@ def _bbox_converter(
83
83
  return str2bbox(val)
84
84
 
85
85
 
86
- def _datetime_converter(
87
- val: Annotated[
88
- Optional[str],
89
- Query(
90
- description="""Only return items that have a temporal property that intersects this value.\n
91
- Either a date-time or an interval, open or closed. Date and time expressions adhere to RFC 3339. Open intervals are expressed using double-dots.""", # noqa: E501
92
- openapi_examples={
93
- "datetime": {"value": "2018-02-12T23:20:50Z"},
94
- "closed-interval": {"value": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"},
95
- "open-interval-from": {"value": "2018-02-12T00:00:00Z/.."},
96
- "open-interval-to": {"value": "../2018-03-18T12:31:12Z"},
97
- },
98
- ),
99
- ] = None,
100
- ):
101
- return str_to_interval(val)
86
+ def _validate_datetime(instance, attribute, value):
87
+ """Validate Datetime."""
88
+ _ = str_to_interval(value)
102
89
 
103
90
 
104
91
  # Be careful: https://github.com/samuelcolvin/pydantic/issues/1423#issuecomment-642797287
@@ -106,6 +93,21 @@ NumType = Union[float, int]
106
93
  Limit = Annotated[PositiveInt, AfterValidator(crop)]
107
94
 
108
95
 
96
+ DateTimeQueryType = Annotated[
97
+ Optional[str],
98
+ Query(
99
+ description="""Only return items that have a temporal property that intersects this value.\n
100
+ Either a date-time or an interval, open or closed. Date and time expressions adhere to RFC 3339. Open intervals are expressed using double-dots.""", # noqa: E501
101
+ openapi_examples={
102
+ "datetime": {"value": "2018-02-12T23:20:50Z"},
103
+ "closed-interval": {"value": "2018-02-12T00:00:00Z/2018-03-18T12:31:12Z"},
104
+ "open-interval-from": {"value": "2018-02-12T00:00:00Z/.."},
105
+ "open-interval-to": {"value": "../2018-03-18T12:31:12Z"},
106
+ },
107
+ ),
108
+ ]
109
+
110
+
109
111
  @attr.s
110
112
  class APIRequest:
111
113
  """Generic API Request base class."""
@@ -117,7 +119,36 @@ class APIRequest:
117
119
 
118
120
 
119
121
  @attr.s
120
- class BaseSearchGetRequest(APIRequest):
122
+ class DatetimeMixin:
123
+ """Datetime Mixin."""
124
+
125
+ datetime: DateTimeQueryType = attr.ib(default=None, validator=_validate_datetime)
126
+
127
+ def parse_datetime(self) -> Optional[DateTimeType]:
128
+ """Return Datetime objects."""
129
+ return str_to_interval(self.datetime)
130
+
131
+ @property
132
+ def start_date(self) -> Optional[dt]:
133
+ """Start Date."""
134
+ parsed = self.parse_datetime()
135
+ if parsed is None:
136
+ return None
137
+
138
+ return parsed[0] if isinstance(parsed, tuple) else parsed
139
+
140
+ @property
141
+ def end_date(self) -> Optional[dt]:
142
+ """End Date."""
143
+ parsed = self.parse_datetime()
144
+ if parsed is None:
145
+ return None
146
+
147
+ return parsed[1] if isinstance(parsed, tuple) else None
148
+
149
+
150
+ @attr.s
151
+ class BaseSearchGetRequest(APIRequest, DatetimeMixin):
121
152
  """Base arguments for GET Request."""
122
153
 
123
154
  collections: Optional[List[str]] = attr.ib(
@@ -170,9 +201,7 @@ class BaseSearchGetRequest(APIRequest):
170
201
  },
171
202
  ),
172
203
  ] = attr.ib(default=None)
173
- datetime: Optional[DateTimeType] = attr.ib(
174
- default=None, converter=_datetime_converter
175
- )
204
+ datetime: DateTimeQueryType = attr.ib(default=None, validator=_validate_datetime)
176
205
  limit: Annotated[
177
206
  Optional[Limit],
178
207
  Query(
@@ -1,3 +1,3 @@
1
1
  """Library version."""
2
2
 
3
- __version__ = "3.0.4"
3
+ __version__ = "4.0.0"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: stac-fastapi.types
3
- Version: 3.0.4
3
+ Version: 4.0.0
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -10,14 +10,13 @@ Keywords: STAC FastAPI COG
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Intended Audience :: Information Technology
12
12
  Classifier: Intended Audience :: Science/Research
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
19
18
  Classifier: License :: OSI Approved :: MIT License
20
- Requires-Python: >=3.8
19
+ Requires-Python: >=3.9
21
20
  Description-Content-Type: text/markdown
22
21
  Requires-Dist: fastapi>=0.109.0
23
22
  Requires-Dist: attrs>=23.2.0
@@ -34,3 +33,14 @@ Provides-Extra: docs
34
33
  Requires-Dist: mkdocs; extra == "docs"
35
34
  Requires-Dist: mkdocs-material; extra == "docs"
36
35
  Requires-Dist: pdocs; extra == "docs"
36
+ Dynamic: author
37
+ Dynamic: author-email
38
+ Dynamic: classifier
39
+ Dynamic: description-content-type
40
+ Dynamic: home-page
41
+ Dynamic: keywords
42
+ Dynamic: license
43
+ Dynamic: provides-extra
44
+ Dynamic: requires-dist
45
+ Dynamic: requires-python
46
+ Dynamic: summary