1111from .session import CliSession
1212from planet .clients .subscriptions import SubscriptionsClient
1313from .. import subscription_request
14+ from ..subscription_request import sentinel_hub
1415from ..specs import get_item_types , validate_item_type , SpecificationException
1516
1617ALL_ITEM_TYPES = get_item_types ()
@@ -87,21 +88,46 @@ async def list_subscriptions_cmd(ctx, status, limit, pretty):
8788 echo_json (sub , pretty )
8889
8990
90- @subscriptions .command (name = 'create' ) # type: ignore
91- @click .argument ('request' , type = types .JSON ())
91+ @subscriptions .command (name = "create" ) # type: ignore
92+ @click .argument ("request" , type = types .JSON ())
93+ @click .option (
94+ "--hosting" ,
95+ type = click .Choice ([
96+ "sentinel_hub" ,
97+ ]),
98+ default = None ,
99+ help = 'Hosting type. Currently, only "sentinel_hub" is supported.' ,
100+ )
101+ @click .option ("--collection-id" ,
102+ default = None ,
103+ help = 'Collection ID for Sentinel Hub.'
104+ 'If omitted, a new collection will be created.' )
92105@pretty
93106@click .pass_context
94107@translate_exceptions
95108@coro
96- async def create_subscription_cmd (ctx , request , pretty ):
109+ async def create_subscription_cmd (ctx , request , pretty , ** kwargs ):
97110 """Create a subscription.
98111
99112 Submits a subscription request for creation and prints the created
100113 subscription description, optionally pretty-printed.
101114
102115 REQUEST is the full description of the subscription to be created. It must
103116 be JSON and can be specified a json string, filename, or '-' for stdin.
117+
118+ Other flag options are hosting and collection_id. The hosting flag
119+ specifies the hosting type, and the collection_id flag specifies the
120+ collection ID for Sentinel Hub. If the collection_id is omitted, a new
121+ collection will be created.
104122 """
123+
124+ hosting = kwargs .get ("hosting" , None )
125+ collection_id = kwargs .get ("collection_id" , None )
126+
127+ if hosting == "sentinel_hub" :
128+ hosting_info = sentinel_hub (collection_id )
129+ request ["hosting" ] = hosting_info
130+
105131 async with subscriptions_client (ctx ) as client :
106132 sub = await client .create_subscription (request )
107133 echo_json (sub , pretty )
@@ -263,20 +289,28 @@ async def list_subscription_results_cmd(ctx,
263289 help = 'Toolchain JSON. Can be a string, filename, or - for stdin.' )
264290@click .option (
265291 '--hosting' ,
266- type = types .JSON (),
267- help = 'Hosting JSON. Can be a string, a filename, or - for stdin.' )
292+ default = None ,
293+ type = click .Choice ([
294+ "sentinel_hub" ,
295+ ]),
296+ help = 'Hosting configuration. Can be JSON, "sentinel_hub", or omitted.' )
268297@click .option (
269298 '--clip-to-source' ,
270299 is_flag = True ,
271300 default = False ,
272301 help = "Clip to the source geometry without specifying a clip tool." )
302+ @click .option ("--collection-id" ,
303+ default = None ,
304+ help = 'Collection ID for Sentinel Hub.'
305+ 'If omitted, a new collection will be created.' )
273306@pretty
274307def request (name ,
275308 source ,
276309 delivery ,
277310 notifications ,
278311 tools ,
279312 hosting ,
313+ collection_id ,
280314 clip_to_source ,
281315 pretty ):
282316 """Generate a subscriptions request.
@@ -286,12 +320,14 @@ def request(name,
286320 --clip-to-source option is a preview of the next API version's
287321 default behavior.
288322 """
323+
289324 res = subscription_request .build_request (name ,
290325 source ,
291326 delivery ,
292327 notifications = notifications ,
293328 tools = tools ,
294329 hosting = hosting ,
330+ collection_id = collection_id ,
295331 clip_to_source = clip_to_source )
296332 echo_json (res , pretty )
297333
@@ -349,6 +385,7 @@ def request_catalog(item_types,
349385 time_range_type ,
350386 pretty ):
351387 """Generate a subscriptions request catalog source description."""
388+
352389 res = subscription_request .catalog_source (
353390 item_types ,
354391 asset_types ,
@@ -373,7 +410,8 @@ def request_catalog(item_types,
373410 "land_surface_temperature" ,
374411 "soil_water_content" ,
375412 "vegetation_optical_depth" ,
376- "forest_carbon_diligence_30m"
413+ "forest_carbon_diligence_30m" ,
414+ "field_boundaries_sentinel_2_p1m"
377415 ]),
378416)
379417@click .option ('--var-id' , required = True , help = 'Planetary variable id.' )
0 commit comments