File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717from stac_pydantic .links import Link
1818from stac_pydantic .shared import Provider
1919
20+
2021Geometry = Union [
2122 Point ,
2223 MultiPoint ,
@@ -106,8 +107,7 @@ def to_json(self, **kwargs: Any) -> str:
106107class Search (BaseModel ):
107108 geometry : Optional [Geometry ]
108109
109- # Slash separated date time range
110- datetime : str
110+ datetime : str = Field (description = "Slash separated datetime range." )
111111 product_id : Optional [str ]
112112 constraints : Optional [Dict [str , Any ]] = None
113113 limit : int = 10
Original file line number Diff line number Diff line change @@ -46,6 +46,29 @@ async def get_products(
4646 )
4747
4848
49+
50+ @app .get ("/products/{id}/opportunities" , response_model = OpportunityCollection )
51+ async def get_product_opportunities (
52+ id : str ,
53+ request : Request ,
54+ search : Search | None = None ,
55+ ):
56+ """Get opportunities for a given product
57+
58+ Example: /products/landsat-c2-l2/opportunities
59+ """
60+ if search is None :
61+ start_datetime = datetime .now ()
62+ end_datetime = start_datetime + timedelta (days = 40 )
63+ search = Search (
64+ geometry = Point (coordinates = (45 , 45 )),
65+ datetime = f"{ start_datetime .isoformat ()} /{ end_datetime .isoformat ()} " ,
66+ limit = 10 ,
67+ )
68+ search .product_id = id
69+
70+ return await post_opportunities (request , search )
71+
4972@app .get ("/opportunities" , response_model = OpportunityCollection )
5073async def get_opportunities (
5174 request : Request ,
You can’t perform that action at this time.
0 commit comments