@@ -182,45 +182,47 @@ def post(self) -> Any:
182182 return response
183183
184184
185- # TODO: re-add this and make use of it. This gives the swagger interface more
186- # information and helps to document the API.
187- # GET_LINKS_DOC: Final[frx.model.Model] = api.model(
188- # "get_links",
189- # {
190- # "cmr_request_params": frx.fields.String(
191- # description="CMR Request parameters as a string",
192- # example="provider=NSIDC_ECS&page_size=2000&sort_key[]=-start_date&sort_key[]=producer_granule_id&short_name=ATL06&version=6&version=06&version=006&temporal[]=2018-10-14T00:00:00Z,2025-02-19T20:51:37Z&bounding_box=-101.94,57.71,-90.21,61.13",
193- # required=True,
194- # ),
195- # "cursor": frx.fields.String(
196- # description="CMR search results cursor",
197- # example='1638327816913,"atl06_20211201030329_10641303_006_01.h5",2706594203',
198- # required=False,
199- # ),
200- # },
201- # )
185+ get_links_response_model = api .model (
186+ "GetLinksResponse" ,
187+ {
188+ "links" : frx .fields .List (
189+ frx .fields .String (
190+ example = "https://data.nsidc.earthdatacloud.nasa.gov/nsidc-cumulus-prod-protected/ATLAS/ATL06/006/2024/02/09/ATL06_20240209110944_08042201_006_01.h5"
191+ )
192+ ),
193+ "done" : frx .fields .Boolean (example = False ),
194+ "cursor" : frx .fields .String (
195+ example = '[1638327816913,"atl06_20211201030329_10641303_006_01.h5",2706594203]'
196+ ),
197+ },
198+ )
202199
203200
204201@api .route ("/api/get-links" )
205202class GetLinks (frx .Resource ): # type: ignore[misc]
206203
207- @api .response (200 , "Success" )
208- # @api.expect(GET_LINKS_DOC) # type: ignore
204+ @api .marshal_with (get_links_response_model , mask = False )
205+ @api .response (* RESPONSE_CODES [200 ])
206+ @api .response (* RESPONSE_CODES [500 ])
207+ @api .param (
208+ "cmr_request_params" ,
209+ description = "CMR Request parameters as a string" ,
210+ example = r"provider=NSIDC_CPRD&page_size=5&sort_key[]=-start_date&sort_key[]=producer_granule_id&short_name=ATL06&version=6&version=06&version=006&temporal[]=2018-10-14T00:00:00Z,2025-02-25T00:25:20Z&bounding_box=-180,-90,180,90&options[producer_granule_id][pattern]=true&producer_granule_id[]=\*ATL06_2024\*_0804\*_006_01.h5\*" ,
211+ required = True ,
212+ )
213+ @api .param (
214+ "cursor" ,
215+ description = "CMR search results cursor" ,
216+ example = '[1638327816913,"atl06_20211201030329_10641303_006_01.h5",2706594203]' ,
217+ required = False ,
218+ )
209219 def get (self ):
210- # cmr_request_params = api.payload["cmr_request_params"]
211- cmr_request_params = request .args .get ("cmr_request_params" )
220+ cmr_request_params = request .args ["cmr_request_params" ]
212221 cursor = request .args .get ("cursor" )
213- # cursor = api.payload.get("cursor")
214222 app .logger .info (
215223 f"get_links received successfully: { cmr_request_params = } { cursor = } "
216224 )
217225
218- # TODO: remove hard-coded params. We may need to break these out into
219- # individual args instead of just passing a query string...encoding this
220- # in a way that the earthdata downloader can pass the requests along is
221- # difficult. Not sure how to achieve yet.
222- cmr_request_params = "provider=NSIDC_CPRD&page_size=5&sort_key[]=-start_date&sort_key[]=producer_granule_id&short_name=ATL06&version=6&version=06&version=006&temporal[]=2018-10-14T00:00:00Z,2025-02-25T00:25:20Z&bounding_box=-180,-90,180,90&options[producer_granule_id][pattern]=true&producer_granule_id[]=*ATL06_2024*_0804*_006_01.h5*"
223-
224226 app .logger .info (f"get_links using { cursor = } " )
225227 links , cursor = get_links (
226228 cmr_request_params = cmr_request_params ,
@@ -326,7 +328,7 @@ def earthdata_token_exchange(authorization_code: Optional[str]) -> Dict[str, Any
326328
327329@api .route ("/api/earthdata/auth_callback" )
328330class EarthdataAuthCallback (frx .Resource ): # type: ignore[misc]
329- @api .response (* RESPONSE_CODES [302 ]) # type: ignore[misc]
331+ @api .response (* RESPONSE_CODES [200 ]) # type: ignore[misc]
330332 @api .response (* RESPONSE_CODES [500 ]) # type: ignore[misc]
331333 def get (self ) -> Response :
332334 # Perform token exchange
0 commit comments