@@ -247,36 +247,53 @@ def read_file_json(ctx, param, value):
247247@click .pass_context
248248@translate_exceptions
249249@coro
250- @click .option ('--name' , required = True )
251- @click .option ('--id' ,
252- 'ids' ,
253- help = 'One or more comma-separated item IDs' ,
254- type = click .STRING ,
255- callback = split_list_arg ,
256- required = True )
257- # @click.option('--ids_from_search',
258- # help='Embedded data search')
250+ @click .argument ("request" , default = "-" , required = False )
251+ @pretty
252+ async def create (ctx , request : str , pretty ):
253+ ''' Create an order.
254+
255+ This command creates an order from an order request.
256+ It outputs the created order description, optionally pretty-printed.
257+
258+ Arguments:
259+
260+ Order request as stdin, str, or file name. Full description of order
261+ to be created.
262+ '''
263+ request_json = json .load (click .open_file (request ))
264+
265+ async with orders_client (ctx ) as cl :
266+ order = await cl .create_order (request_json )
267+
268+ echo_json (order , pretty )
269+
270+
271+ @orders .command ()
272+ @click .pass_context
273+ @translate_exceptions
274+ @coro
275+ @click .option ('--name' ,
276+ required = True ,
277+ help = 'Order name. Does not need to be unique.' ,
278+ type = click .STRING )
259279@click .option (
260280 '--bundle' ,
261281 multiple = False ,
262282 required = True ,
263- help = 'Specify bundle' ,
283+ help = 'Product bundle. ' ,
264284 type = click .Choice (planet .specs .get_product_bundles (),
265285 case_sensitive = False ),
266286)
287+ @click .option ('--id' ,
288+ help = 'One or more comma-separated item IDs' ,
289+ type = click .STRING ,
290+ callback = split_list_arg ,
291+ required = True )
267292@click .option ('--item-type' ,
268293 multiple = False ,
269294 required = True ,
270295 help = 'Specify an item type' ,
271296 type = click .STRING )
272- @click .option ('--email' ,
273- default = False ,
274- is_flag = True ,
275- help = 'Send email notification when Order is complete' )
276- @click .option ('--cloudconfig' ,
277- help = 'Cloud delivery config json file.' ,
278- type = click .File ('rb' ),
279- callback = read_file_json )
280297@click .option ('--clip' ,
281298 help = 'Clip GeoJSON file.' ,
282299 type = click .File ('rb' ),
@@ -285,20 +302,35 @@ def read_file_json(ctx, param, value):
285302 help = 'Toolchain json file.' ,
286303 type = click .File ('rb' ),
287304 callback = read_file_json )
305+ @click .option ('--email' ,
306+ default = False ,
307+ is_flag = True ,
308+ help = 'Send email notification when Order is complete' )
309+ @click .option (
310+ '--cloudconfig' ,
311+ help = 'Credentials for cloud storage provider to enable cloud delivery'
312+ 'of data.' ,
313+ type = click .File ('rb' ),
314+ callback = read_file_json )
288315@pretty
289- async def create (ctx ,
290- name ,
291- ids ,
292- bundle ,
293- item_type ,
294- email ,
295- cloudconfig ,
296- clip ,
297- tools ,
298- pretty ):
299- '''Create an order.'''
316+ async def request (ctx ,
317+ name ,
318+ bundle ,
319+ id ,
320+ clip ,
321+ tools ,
322+ item_type ,
323+ email ,
324+ cloudconfig ,
325+ pretty ):
326+ """Generate an order request.
327+
328+ This command provides support for building an order description used
329+ in creating an order. It outputs the order request, optionally pretty-
330+ printed.
331+ """
300332 try :
301- product = planet .order_request .product (ids , bundle , item_type )
333+ product = planet .order_request .product (id , bundle , item_type )
302334 except planet .specs .SpecificationException as e :
303335 raise click .BadParameter (e )
304336
@@ -307,11 +339,6 @@ async def create(ctx,
307339 else :
308340 notifications = None
309341
310- if cloudconfig :
311- delivery = planet .order_request .delivery (cloud_config = cloudconfig )
312- else :
313- delivery = None
314-
315342 if clip and tools :
316343 raise click .BadParameter ("Specify only one of '--clip' or '--tools'" )
317344 elif clip :
@@ -322,13 +349,15 @@ async def create(ctx,
322349
323350 tools = [planet .order_request .clip_tool (clip )]
324351
352+ if cloudconfig :
353+ delivery = planet .order_request .delivery (cloud_config = cloudconfig )
354+ else :
355+ delivery = None
356+
325357 request = planet .order_request .build_request (name ,
326358 products = [product ],
327359 delivery = delivery ,
328360 notifications = notifications ,
329361 tools = tools )
330362
331- async with orders_client (ctx ) as cl :
332- order = await cl .create_order (request )
333-
334- echo_json (order , pretty )
363+ echo_json (request , pretty )
0 commit comments