@@ -495,11 +495,13 @@ enum SupportBundleCommands {
495
495
Create ,
496
496
/// Delete a support bundle
497
497
Delete ( SupportBundleDeleteArgs ) ,
498
+ /// Download an entire support bundle
499
+ Download ( SupportBundleDownloadArgs ) ,
498
500
/// Download the index of a support bundle
499
501
///
500
502
/// This is a "list of files", from which individual files can be accessed
501
503
GetIndex ( SupportBundleIndexArgs ) ,
502
- /// View a file within a support bundle
504
+ /// Download a single file within a support bundle
503
505
GetFile ( SupportBundleFileArgs ) ,
504
506
/// Creates a dashboard for viewing the contents of a support bundle
505
507
Inspect ( SupportBundleInspectArgs ) ,
@@ -510,6 +512,16 @@ struct SupportBundleDeleteArgs {
510
512
id : SupportBundleUuid ,
511
513
}
512
514
515
+ #[ derive( Debug , Args ) ]
516
+ struct SupportBundleDownloadArgs {
517
+ id : SupportBundleUuid ,
518
+
519
+ /// Optional output path where the file should be written,
520
+ /// instead of stdout.
521
+ #[ arg( short, long) ]
522
+ output : Option < Utf8PathBuf > ,
523
+ }
524
+
513
525
#[ derive( Debug , Args ) ]
514
526
struct SupportBundleIndexArgs {
515
527
id : SupportBundleUuid ,
@@ -750,6 +762,9 @@ impl NexusArgs {
750
762
let token = omdb. check_allow_destructive ( ) ?;
751
763
cmd_nexus_support_bundles_delete ( & client, args, token) . await
752
764
}
765
+ NexusCommands :: SupportBundles ( SupportBundleArgs {
766
+ command : SupportBundleCommands :: Download ( args) ,
767
+ } ) => cmd_nexus_support_bundles_download ( & client, args) . await ,
753
768
NexusCommands :: SupportBundles ( SupportBundleArgs {
754
769
command : SupportBundleCommands :: GetIndex ( args) ,
755
770
} ) => cmd_nexus_support_bundles_get_index ( & client, args) . await ,
@@ -3854,6 +3869,28 @@ async fn write_stream_to_sink(
3854
3869
Ok ( ( ) )
3855
3870
}
3856
3871
3872
+ /// Runs `omdb nexus support-bundles download`
3873
+ async fn cmd_nexus_support_bundles_download (
3874
+ client : & nexus_client:: Client ,
3875
+ args : & SupportBundleDownloadArgs ,
3876
+ ) -> Result < ( ) , anyhow:: Error > {
3877
+ let stream = client
3878
+ . support_bundle_download ( args. id . as_untyped_uuid ( ) )
3879
+ . await
3880
+ . with_context ( || format ! ( "downloading support bundle {}" , args. id) ) ?
3881
+ . into_inner_stream ( ) ;
3882
+
3883
+ let sink: Box < dyn std:: io:: Write > = match & args. output {
3884
+ Some ( path) => Box :: new ( std:: fs:: File :: create ( path) ?) ,
3885
+ None => Box :: new ( std:: io:: stdout ( ) ) ,
3886
+ } ;
3887
+
3888
+ write_stream_to_sink ( stream, sink)
3889
+ . await
3890
+ . with_context ( || format ! ( "streaming support bundle {}" , args. id) ) ?;
3891
+ Ok ( ( ) )
3892
+ }
3893
+
3857
3894
/// Runs `omdb nexus support-bundles get-index`
3858
3895
async fn cmd_nexus_support_bundles_get_index (
3859
3896
client : & nexus_client:: Client ,
0 commit comments