File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -487,11 +487,11 @@ impl ApiClient {
487487
488488 return Ok ( GetUsageLimitsOutput :: builder ( )
489489 . limits ( mock_limits)
490- . usage_breakdown ( usage_breakdown)
491- . build ( ) ? ) ;
490+ . usage_breakdown_list ( usage_breakdown. clone ( ) )
491+ . build ( ) ) ;
492492 }
493493
494- // Currently we should only use AgenticRequest for this API
494+ // Currently for QDev we should only use AgenticRequest for this API
495495 self . client
496496 . get_usage_limits ( )
497497 . set_profile_arn ( self . profile . as_ref ( ) . map ( |p| p. arn . clone ( ) ) )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use amzn_codewhisperer_client::types::{
55 OverageStatus ,
66 ResourceType ,
77 SubscriptionType ,
8+ UsageBreakdown ,
89} ;
910use clap:: Args ;
1011use crossterm:: style:: {
@@ -191,7 +192,7 @@ impl UsageArgs {
191192 ) ) ,
192193 ) ?;
193194
194- match os. client . get_usage_limits ( Some ( ResourceType :: AgenticRequest ) ) . await {
195+ match os. client . get_usage_limits ( None ) . await {
195196 Ok ( resp) => {
196197 tracing:: debug!( ?resp, "Raw get_usage_limits response" ) ;
197198 // Subscription tier
@@ -212,7 +213,15 @@ impl UsageArgs {
212213 }
213214
214215 // Usage breakdown
215- if let Some ( ub) = resp. usage_breakdown ( ) {
216+ let list: & [ UsageBreakdown ] = resp. usage_breakdown_list ( ) ;
217+ if list. is_empty ( ) {
218+ queue ! ( session. stderr, style:: Print ( "\n Usage information unavailable\n \n " ) , ) ?;
219+ } else {
220+ let ub = list
221+ . iter ( )
222+ . find ( |b| matches ! ( b. resource_type( ) , Some ( ResourceType :: AgenticRequest ) ) )
223+ . unwrap_or_else ( || list. first ( ) . expect ( "UsageBreakdown list is not null" ) ) ;
224+
216225 let current = ub. current_usage ( ) ;
217226 let limit = ub. usage_limit ( ) ;
218227 let overage_charges = ub. overage_charges ( ) ;
@@ -246,8 +255,6 @@ impl UsageArgs {
246255 // Line 3: reset time
247256 style:: Print ( format!( "• Limits reset on {}\n \n " , reset_local) ) ,
248257 ) ?;
249- } else {
250- queue ! ( session. stderr, style:: Print ( "\n Usage information unavailable\n \n " ) , ) ?;
251258 }
252259 } ,
253260 Err ( e) => {
You can’t perform that action at this time.
0 commit comments