@@ -82,7 +82,7 @@ impl ListFields {
82
82
}
83
83
84
84
#[ derive( Clone , Copy , Debug , clap:: ValueEnum ) ]
85
- enum UsageFields {
85
+ enum UtilizationFields {
86
86
Directory ,
87
87
BytesUsed ,
88
88
BytesAvailable ,
@@ -91,9 +91,9 @@ enum UsageFields {
91
91
PctQuota ,
92
92
}
93
93
94
- impl std:: fmt:: Display for UsageFields {
94
+ impl std:: fmt:: Display for UtilizationFields {
95
95
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
96
- use UsageFields :: * ;
96
+ use UtilizationFields :: * ;
97
97
match self {
98
98
Directory => write ! ( f, "directory" ) ,
99
99
BytesUsed => write ! ( f, "bytes-used" ) ,
@@ -105,9 +105,9 @@ impl std::fmt::Display for UsageFields {
105
105
}
106
106
}
107
107
108
- impl UsageFields {
108
+ impl UtilizationFields {
109
109
fn all ( ) -> Vec < Self > {
110
- use UsageFields :: * ;
110
+ use UtilizationFields :: * ;
111
111
vec ! [
112
112
Directory ,
113
113
BytesUsed ,
@@ -178,14 +178,14 @@ enum Cmd {
178
178
/// Set parameters of the zone bundle cleanup context.
179
179
#[ clap( visible_alias = "set-context" ) ]
180
180
SetCleanupContext ( SetCleanupContextArgs ) ,
181
- /// Return the usage of the datasets allocated for zone bundles.
182
- Usage {
181
+ /// Return the utilization of the datasets allocated for zone bundles.
182
+ Utilization {
183
183
/// Generate parseable output.
184
184
#[ arg( long, short, default_value_t = false ) ]
185
185
parseable : bool ,
186
186
/// Fields to print.
187
- #[ arg( long, short = 'o' , default_values_t = UsageFields :: all( ) , value_delimiter = ',' ) ]
188
- fields : Vec < UsageFields > ,
187
+ #[ arg( long, short = 'o' , default_values_t = UtilizationFields :: all( ) , value_delimiter = ',' ) ]
188
+ fields : Vec < UtilizationFields > ,
189
189
} ,
190
190
/// Trigger an explicit request to cleanup low-priority zone bundles.
191
191
Cleanup ,
@@ -234,19 +234,10 @@ async fn main() -> anyhow::Result<()> {
234
234
}
235
235
Cmd :: List { filter, parseable, fields } => {
236
236
let bundles = client
237
- . zone_bundle_list_all ( )
237
+ . zone_bundle_list_all ( filter . as_deref ( ) )
238
238
. await
239
239
. context ( "failed to list zone bundles" ) ?
240
- . into_inner ( )
241
- . into_iter ( )
242
- . filter ( |bundle| {
243
- if let Some ( filter) = & filter {
244
- bundle. id . zone_name . contains ( filter)
245
- } else {
246
- true
247
- }
248
- } )
249
- . collect :: < Vec < _ > > ( ) ;
240
+ . into_inner ( ) ;
250
241
if bundles. is_empty ( ) {
251
242
return Ok ( ( ) ) ;
252
243
}
@@ -383,7 +374,6 @@ async fn main() -> anyhow::Result<()> {
383
374
. zone_bundle_cleanup_context ( )
384
375
. await
385
376
. context ( "failed to fetch cleanup context" ) ?;
386
- println ! ( "Storage directories: {:?}" , context. storage_dirs) ;
387
377
println ! ( "Period: {}s" , context. period. 0 . secs) ;
388
378
println ! ( "Priority: {:?}" , context. priority. 0 ) ;
389
379
println ! ( "Storage limit: {}%" , context. storage_limit. 0 ) ;
@@ -408,42 +398,44 @@ async fn main() -> anyhow::Result<()> {
408
398
. await
409
399
. context ( "failed to update zone bundle cleanup context" ) ?;
410
400
}
411
- Cmd :: Usage { parseable, fields } => {
412
- let usage_by_dir = client
413
- . zone_bundle_usage ( )
401
+ Cmd :: Utilization { parseable, fields } => {
402
+ let utilization_by_dir = client
403
+ . zone_bundle_utilization ( )
414
404
. await
415
- . context ( "failed to get zone bundle usage " ) ?;
405
+ . context ( "failed to get zone bundle utilization " ) ?;
416
406
const BYTES_USED_SIZE : usize = 16 ;
417
407
const BYTES_AVAIL_SIZE : usize = 16 ;
418
408
const QUOTA_SIZE : usize = 16 ;
419
409
const PCT_OF_AVAIL_SIZE : usize = 10 ;
420
410
const PCT_OF_QUOTA_SIZE : usize = 10 ;
421
- if !usage_by_dir . is_empty ( ) {
422
- use UsageFields :: * ;
411
+ if !utilization_by_dir . is_empty ( ) {
412
+ use UtilizationFields :: * ;
423
413
if parseable {
424
- for ( dir, usage ) in usage_by_dir . iter ( ) {
414
+ for ( dir, utilization ) in utilization_by_dir . iter ( ) {
425
415
for ( i, field) in fields. iter ( ) . enumerate ( ) {
426
416
match field {
427
417
Directory => print ! ( "{}" , dir) ,
428
- BytesUsed => print ! ( "{}" , usage. bytes_used) ,
418
+ BytesUsed => {
419
+ print ! ( "{}" , utilization. bytes_used)
420
+ }
429
421
BytesAvailable => {
430
- print ! ( "{}" , usage . bytes_available)
422
+ print ! ( "{}" , utilization . bytes_available)
431
423
}
432
424
DatasetQuota => {
433
- print ! ( "{}" , usage . dataset_quota)
425
+ print ! ( "{}" , utilization . dataset_quota)
434
426
}
435
427
PctAvailable => print ! (
436
428
"{}" ,
437
429
as_pct(
438
- usage . bytes_used,
439
- usage . bytes_available
430
+ utilization . bytes_used,
431
+ utilization . bytes_available
440
432
)
441
433
) ,
442
434
PctQuota => print ! (
443
435
"{}" ,
444
436
as_pct(
445
- usage . bytes_used,
446
- usage . dataset_quota
437
+ utilization . bytes_used,
438
+ utilization . dataset_quota
447
439
)
448
440
) ,
449
441
}
@@ -454,8 +446,11 @@ async fn main() -> anyhow::Result<()> {
454
446
println ! ( ) ;
455
447
}
456
448
} else {
457
- let dir_col_size =
458
- usage_by_dir. keys ( ) . map ( |d| d. len ( ) ) . max ( ) . unwrap ( ) ;
449
+ let dir_col_size = utilization_by_dir
450
+ . keys ( )
451
+ . map ( |d| d. len ( ) )
452
+ . max ( )
453
+ . unwrap ( ) ;
459
454
for field in fields. iter ( ) {
460
455
match field {
461
456
Directory => {
@@ -481,34 +476,34 @@ async fn main() -> anyhow::Result<()> {
481
476
print ! ( " " ) ;
482
477
}
483
478
println ! ( ) ;
484
- for ( dir, usage ) in usage_by_dir . iter ( ) {
479
+ for ( dir, utilization ) in utilization_by_dir . iter ( ) {
485
480
for field in fields. iter ( ) {
486
481
match field {
487
482
Directory => print ! ( "{:dir_col_size$}" , dir) ,
488
483
BytesUsed => print ! (
489
484
"{:BYTES_USED_SIZE$}" ,
490
- as_human_bytes( usage . bytes_used)
485
+ as_human_bytes( utilization . bytes_used)
491
486
) ,
492
487
BytesAvailable => print ! (
493
488
"{:BYTES_AVAIL_SIZE$}" ,
494
- as_human_bytes( usage . bytes_available)
489
+ as_human_bytes( utilization . bytes_available)
495
490
) ,
496
491
DatasetQuota => print ! (
497
492
"{:QUOTA_SIZE$}" ,
498
- as_human_bytes( usage . dataset_quota)
493
+ as_human_bytes( utilization . dataset_quota)
499
494
) ,
500
495
PctAvailable => print ! (
501
496
"{:PCT_OF_AVAIL_SIZE$}" ,
502
497
as_pct_str(
503
- usage . bytes_used,
504
- usage . bytes_available
498
+ utilization . bytes_used,
499
+ utilization . bytes_available
505
500
)
506
501
) ,
507
502
PctQuota => print ! (
508
503
"{:PCT_OF_QUOTA_SIZE$}" ,
509
504
as_pct_str(
510
- usage . bytes_used,
511
- usage . dataset_quota
505
+ utilization . bytes_used,
506
+ utilization . dataset_quota
512
507
)
513
508
) ,
514
509
}
0 commit comments