@@ -71,8 +71,8 @@ def assets_to_filter(ctx, param, assets: List[str]) -> Optional[dict]:
7171
7272
7373def check_item_types (ctx , param , item_types ) -> Optional [List [dict ]]:
74- '''Validates the item type by comparing the inputted item type to all
75- supported item types.'''
74+ '''Validates each item types provided by comparing them to all supported
75+ item types.'''
7676 try :
7777 for item_type in item_types :
7878 validate_item_type (item_type )
@@ -81,6 +81,17 @@ def check_item_types(ctx, param, item_types) -> Optional[List[dict]]:
8181 raise click .BadParameter (str (e ))
8282
8383
84+ def check_item_type (ctx , param , item_type ) -> Optional [List [dict ]]:
85+ '''Validates the item type provided by comparing it to all supported
86+ item types.'''
87+ try :
88+ validate_item_type (item_type )
89+ except SpecificationException as e :
90+ raise click .BadParameter (str (e ))
91+
92+ return item_type
93+
94+
8495def check_search_id (ctx , param , search_id ) -> str :
8596 '''Ensure search id is a valix hex string'''
8697 try :
@@ -487,11 +498,9 @@ async def search_update(ctx,
487498@click .pass_context
488499@translate_exceptions
489500@coro
490- @click .argument ("item_type" ,
491- type = types .CommaSeparatedString (),
492- callback = check_item_types )
501+ @click .argument ("item_type" , type = str , callback = check_item_type )
493502@click .argument ("item_id" )
494- @click .argument ("asset_type_id " )
503+ @click .argument ("asset_type " )
495504@click .option ('--directory' ,
496505 default = '.' ,
497506 help = ('Base directory for file download.' ),
@@ -514,7 +523,7 @@ async def search_update(ctx,
514523async def asset_download (ctx ,
515524 item_type ,
516525 item_id ,
517- asset_type_id ,
526+ asset_type ,
518527 directory ,
519528 filename ,
520529 overwrite ,
@@ -537,7 +546,7 @@ async def asset_download(ctx,
537546 """
538547 quiet = ctx .obj ['QUIET' ]
539548 async with data_client (ctx ) as cl :
540- asset = await cl .get_asset (item_type . pop () , item_id , asset_type_id )
549+ asset = await cl .get_asset (item_type , item_id , asset_type )
541550 path = await cl .download_asset (asset = asset ,
542551 filename = filename ,
543552 directory = Path (directory ),
@@ -551,27 +560,23 @@ async def asset_download(ctx,
551560@click .pass_context
552561@translate_exceptions
553562@coro
554- @click .argument ("item_type" ,
555- type = types .CommaSeparatedString (),
556- callback = check_item_types )
563+ @click .argument ("item_type" , type = str , callback = check_item_type )
557564@click .argument ("item_id" )
558- @click .argument ("asset_type_id " )
559- async def asset_activate (ctx , item_type , item_id , asset_type_id ):
565+ @click .argument ("asset_type " )
566+ async def asset_activate (ctx , item_type , item_id , asset_type ):
560567 '''Activate an asset.'''
561568 async with data_client (ctx ) as cl :
562- asset = await cl .get_asset (item_type . pop () , item_id , asset_type_id )
569+ asset = await cl .get_asset (item_type , item_id , asset_type )
563570 await cl .activate_asset (asset )
564571
565572
566573@data .command ()
567574@click .pass_context
568575@translate_exceptions
569576@coro
570- @click .argument ("item_type" ,
571- type = types .CommaSeparatedString (),
572- callback = check_item_types )
577+ @click .argument ("item_type" , type = str , callback = check_item_type )
573578@click .argument ("item_id" )
574- @click .argument ("asset_type_id " )
579+ @click .argument ("asset_type " )
575580@click .option ('--delay' ,
576581 type = int ,
577582 default = 5 ,
@@ -581,21 +586,16 @@ async def asset_activate(ctx, item_type, item_id, asset_type_id):
581586 default = 200 ,
582587 show_default = True ,
583588 help = 'Maximum number of polls. Set to zero for no limit.' )
584- async def asset_wait (ctx ,
585- item_type ,
586- item_id ,
587- asset_type_id ,
588- delay ,
589- max_attempts ):
589+ async def asset_wait (ctx , item_type , item_id , asset_type , delay , max_attempts ):
590590 '''Wait for an asset to be activated.
591591
592592 Returns when the asset status has reached "activated" and the asset is
593593 available.
594594 '''
595595 quiet = ctx .obj ['QUIET' ]
596596 async with data_client (ctx ) as cl :
597- asset = await cl .get_asset (item_type . pop () , item_id , asset_type_id )
598- with AssetStatusBar (item_type , item_id , asset_type_id ,
597+ asset = await cl .get_asset (item_type , item_id , asset_type )
598+ with AssetStatusBar (item_type , item_id , asset_type ,
599599 disable = quiet ) as bar :
600600 status = await cl .wait_asset (asset ,
601601 delay ,
0 commit comments