# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/02_cli.ipynb (unless otherwise specified).

__all__ = ['geoget_ladsweb', 'geoget_order_manager']

# Cell
from pathlib import Path
from fastscript import call_parse, Param
import warnings
from time import sleep
from .download import *

# Cell
_repChoices=['ALBERS', 'GEO', 'LAMAZ', 'MERCAT', 'PS', 'ROBIN', 'SNSOID', 'TM', 'UTM']

@call_parse
def geoget_ladsweb(
    product:Param("Name of the product", str),
    collection:Param("Collection number", str),
    tstart:Param("Start of serach window yyyy-mm-dd HH:MM:SS", str),
    tend:Param("End of search windo yyyy-mm-dd HH:MM:SS", str),
    bbox:Param("Bounding box in format left bottom right top", list),
    path_save:Param("Path to save the outputs of the request", str),
    bands:Param("List of bands to download", list),
    coordsOrTiles:Param("coordsOrTiles parameter", str, choices=["coords", "tiles"])="coords",
    daynight:Param("Select images for Day, Night or both", str, choices=['D', 'N', 'DNB'])="DNB",
    repName:Param("Reprojection type", str, choices=_repChoices)='GEO',
    repPixSize:Param("Pixel size in units depending on the reprojection type", float)=0.01,
    repResample:Param("Resampling method", str, choices=['bilinear', 'nearest'])='bilinear',
    doMosaic:Param("",str)='False'):

    bbox = [int(s) for s in ''.join(bbox).split(' ')]
    bands = ''.join(bands).split(' ')
    kwargs = {key: value for key, value in locals().items()}
    kwargs['bands'] = bands
    kwargs['bbox'] = bbox
    lads = Ladsweb(**kwargs)
    lads_list = lads.split_times()
    print(f'Splitting request into {len(lads_list)} orders.')
    run_parallel(lads_list, path_save, email, auth)

# Cell
@call_parse
def geoget_order_manager(path_save:Param("Path where log file is saved.", str)):
    return order_manager(path_save)