1818from .cli import (
1919 cli ,
2020 clientv1 ,
21- analytics_client_v1
2221)
2322from .opts import (
2423 asset_type_option ,
@@ -364,7 +363,7 @@ def analytics():
364363@pretty
365364def health (pretty ):
366365 '''Check that we can connect to the API'''
367- cl = analytics_client_v1 ()
366+ cl = clientv1 ()
368367 click .echo ('Using base URL: {}' .format (cl .base_url ))
369368 response = cl .check_analytics_connection ()
370369 echo_json_response (response , pretty )
@@ -378,7 +377,7 @@ def conformance(pretty):
378377 :param pretty:
379378 :return:
380379 '''
381- cl = analytics_client_v1 ()
380+ cl = clientv1 ()
382381 response = cl .wfs_conformance ()
383382 echo_json_response (response , pretty )
384383
@@ -396,7 +395,7 @@ def feeds():
396395@pretty
397396def list_feeds (pretty , limit , stats ):
398397 '''List all subscriptions user has access to.'''
399- cl = analytics_client_v1 ()
398+ cl = clientv1 ()
400399 response = cl .list_analytic_feeds (stats )
401400 echo_json_response (response , pretty , limit )
402401
@@ -405,8 +404,8 @@ def list_feeds(pretty, limit, stats):
405404@click .argument ('feed_id' )
406405def get_mosaic_list_for_feed (feed_id ):
407406 '''List mosaics linked to feed'''
408- analytics_client = analytics_client_v1 ()
409- feed_info = analytics_client .get_feed_info (feed_id ).get ()
407+ cl = clientv1 ()
408+ feed_info = cl .get_feed_info (feed_id ).get ()
410409
411410 for type_ in ['target' , 'source' ]:
412411 feed_image_conf = feed_info .get (type_ )
@@ -418,8 +417,7 @@ def get_mosaic_list_for_feed(feed_id):
418417
419418 mosaic_series = feed_image_conf ['config' ]['series_id' ]
420419
421- client = clientv1 ()
422- mosaics = client .get_mosaics_for_series (mosaic_series )
420+ mosaics = cl .get_mosaics_for_series (mosaic_series )
423421
424422 click .echo ('{} mosaics:' .format (type_ ))
425423 for mosaic in mosaics .get ()['mosaics' ]:
@@ -431,7 +429,7 @@ def get_mosaic_list_for_feed(feed_id):
431429@pretty
432430def get_feed_info (feed_id , pretty ):
433431 '''Get metadata for specific feed.'''
434- cl = analytics_client_v1 ()
432+ cl = clientv1 ()
435433 feed_info = cl .get_feed_info (feed_id )
436434 echo_json_response (feed_info , pretty )
437435
@@ -450,7 +448,7 @@ def subscriptions():
450448@pretty
451449def list_subscriptions (pretty , limit , feed_id ):
452450 '''List all subscriptions user has access to.'''
453- cl = analytics_client_v1 ()
451+ cl = clientv1 ()
454452 response = cl .list_analytic_subscriptions (feed_id )
455453 echo_json_response (response , pretty , limit )
456454
@@ -459,9 +457,9 @@ def list_subscriptions(pretty, limit, feed_id):
459457@click .argument ('subscription_id' )
460458def get_mosaic_list_for_subscription (subscription_id ):
461459 '''List mosaics linked to feed'''
462- analytics_client = analytics_client_v1 ()
463- sub_info = analytics_client .get_subscription_info (subscription_id ).get ()
464- feed_info = analytics_client .get_feed_info (sub_info ['feedID' ]).get ()
460+ cl = clientv1 ()
461+ sub_info = cl .get_subscription_info (subscription_id ).get ()
462+ feed_info = cl .get_feed_info (sub_info ['feedID' ]).get ()
465463
466464 for type_ in ['target' , 'source' ]:
467465 feed_image_conf = feed_info .get (type_ )
@@ -473,8 +471,7 @@ def get_mosaic_list_for_subscription(subscription_id):
473471
474472 mosaic_series = feed_image_conf ['config' ]['series_id' ]
475473
476- client = clientv1 ()
477- mosaics = client .get_mosaics_for_series (mosaic_series )
474+ mosaics = cl .get_mosaics_for_series (mosaic_series )
478475
479476 click .echo ('{} mosaics:' .format (type_ ))
480477 for mosaic in mosaics .get ()['mosaics' ]:
@@ -486,7 +483,7 @@ def get_mosaic_list_for_subscription(subscription_id):
486483@pretty
487484def get_subscription_info (subscription_id , pretty ):
488485 '''Get metadata for specific subscription.'''
489- cl = analytics_client_v1 ()
486+ cl = clientv1 ()
490487 sub_info = cl .get_subscription_info (subscription_id )
491488 echo_json_response (sub_info , pretty )
492489
@@ -502,7 +499,7 @@ def collections():
502499@pretty
503500def list_collections (pretty , limit ):
504501 '''List all collections user has access to.'''
505- cl = analytics_client_v1 ()
502+ cl = clientv1 ()
506503 response = cl .list_analytic_collections ()
507504 echo_json_response (response , pretty , limit )
508505
@@ -511,9 +508,9 @@ def list_collections(pretty, limit):
511508@click .argument ('subscription_id' )
512509def get_mosaic_list_for_collection (subscription_id ):
513510 '''List mosaics linked to feed'''
514- analytics_client = analytics_client_v1 ()
515- sub_info = analytics_client .get_subscription_info (subscription_id ).get ()
516- feed_info = analytics_client .get_feed_info (sub_info ['feedID' ]).get ()
511+ cl = clientv1 ()
512+ sub_info = cl .get_subscription_info (subscription_id ).get ()
513+ feed_info = cl .get_feed_info (sub_info ['feedID' ]).get ()
517514
518515 for type_ in ['target' , 'source' ]:
519516 feed_image_conf = feed_info .get (type_ )
@@ -525,8 +522,7 @@ def get_mosaic_list_for_collection(subscription_id):
525522
526523 mosaic_series = feed_image_conf ['config' ]['series_id' ]
527524
528- client = clientv1 ()
529- mosaics = client .get_mosaics_for_series (mosaic_series )
525+ mosaics = cl .get_mosaics_for_series (mosaic_series )
530526
531527 click .echo ('{} mosaics:' .format (type_ ))
532528 for mosaic in mosaics .get ()['mosaics' ]:
@@ -538,7 +534,7 @@ def get_mosaic_list_for_collection(subscription_id):
538534@pretty
539535def get_collection_info (subscription_id , pretty ):
540536 '''Get metadata for specific collection.'''
541- cl = analytics_client_v1 ()
537+ cl = clientv1 ()
542538 sub_info = cl .get_collection_info (subscription_id )
543539 echo_json_response (sub_info , pretty )
544540
@@ -548,7 +544,7 @@ def get_collection_info(subscription_id, pretty):
548544@pretty
549545def get_resource_types (subscription_id , pretty ):
550546 '''Get available resource types.'''
551- cl = analytics_client_v1 ()
547+ cl = clientv1 ()
552548 # Assumes that all features in a collection have the same list of
553549 # associated resource types
554550 features = cl .list_collection_features (subscription_id ,
@@ -601,7 +597,7 @@ def features():
601597def list_features (subscription_id , pretty , limit , rbox , bbox , time_range ,
602598 before , after ):
603599 '''Request feature list for a particular subscription, 100 at a time.'''
604- cl = analytics_client_v1 ()
600+ cl = clientv1 ()
605601 bbox = bbox or rbox
606602 features = cl .list_collection_features (subscription_id , bbox , time_range ,
607603 before , after )
@@ -633,7 +629,7 @@ def list_features(subscription_id, pretty, limit, rbox, bbox, time_range,
633629def list_features_all (subscription_id , pretty , rbox , bbox , time_range , before ,
634630 after ):
635631 '''Return every available feature for a particular subscription'''
636- cl = analytics_client_v1 ()
632+ cl = clientv1 ()
637633 bbox = bbox or rbox
638634 features = cl .list_collection_features (subscription_id , bbox , time_range ,
639635 before , after )
@@ -653,10 +649,7 @@ def list_features_all(subscription_id, pretty, rbox, bbox, time_range, before,
653649def get_associated_resource (subscription_id , feature_id , resource_type , pretty ,
654650 dest ):
655651 '''Request resources for a particular subscription/feature combination.'''
656- # Note that this command will not work for a custom analytics URL, as the
657- # underlying API call is a redirect to the Data API and Mosaics API.
658- # See https://github.com/kennethreitz/requests/issues/2949 for more info.
659- cl = analytics_client_v1 ()
652+ cl = clientv1 ()
660653 if resource_type in ['target-quad' , 'source-quad' ]:
661654 msg_format = 'Requesting {} for {}/{}, destination directory is: {}'
662655 click .echo (msg_format .format (
0 commit comments