@@ -203,6 +203,60 @@ async def create_subscription_cmd(ctx, request, pretty, **kwargs):
203
203
echo_json (sub , pretty )
204
204
205
205
206
+ @subscriptions .command (name = "bulk-create" ) # type: ignore
207
+ @click .argument ("request" , type = types .JSON ())
208
+ @click .option (
209
+ "--hosting" ,
210
+ type = click .Choice ([
211
+ "sentinel_hub" ,
212
+ ]),
213
+ default = None ,
214
+ help = 'Hosting type. Currently, only "sentinel_hub" is supported.' ,
215
+ )
216
+ @click .option ("--collection-id" ,
217
+ default = None ,
218
+ help = 'Collection ID for Sentinel Hub hosting. '
219
+ 'If omitted, a new collection will be created.' )
220
+ @click .option (
221
+ '--create-configuration' ,
222
+ is_flag = True ,
223
+ help = 'Automatically create a layer configuration for your collection. '
224
+ 'If omitted, no configuration will be created.' )
225
+ @pretty
226
+ @click .pass_context
227
+ @translate_exceptions
228
+ @coro
229
+ async def bulk_create_subscription_cmd (ctx , request , pretty , ** kwargs ):
230
+ """Bulk create subscriptions.
231
+
232
+ Submits a bulk subscription request for creation and prints a link to list
233
+ the resulting subscriptions.
234
+
235
+ REQUEST is the full description of the subscription to be created. It must
236
+ be JSON and can be specified a json string, filename, or '-' for stdin.
237
+
238
+ Other flag options are hosting, collection_id, and create_configuration.
239
+ The hosting flag specifies the hosting type, the collection_id flag specifies the
240
+ collection ID for Sentinel Hub, and the create_configuration flag specifies
241
+ whether or not to create a layer configuration for your collection. If the
242
+ collection_id is omitted, a new collection will be created. If the
243
+ create_configuration flag is omitted, no configuration will be created. The
244
+ collection_id flag and create_configuration flag cannot be used together.
245
+ """
246
+ hosting = kwargs .get ("hosting" , None )
247
+ collection_id = kwargs .get ("collection_id" , None )
248
+ create_configuration = kwargs .get ('create_configuration' , False )
249
+
250
+ if hosting == "sentinel_hub" :
251
+ hosting_info = sentinel_hub (collection_id , create_configuration )
252
+ request ["hosting" ] = hosting_info
253
+
254
+ async with subscriptions_client (ctx ) as client :
255
+ links = await client .bulk_create_subscriptions ([request ])
256
+ # Bulk create returns just a link to an endpoint to list created subscriptions.
257
+ echo_json (links , pretty )
258
+
259
+
206
260
@subscriptions .command (name = 'cancel' ) # type: ignore
207
261
@click .argument ('subscription_id' )
208
262
@pretty
0 commit comments