File tree Expand file tree Collapse file tree 4 files changed +122
-0
lines changed
Expand file tree Collapse file tree 4 files changed +122
-0
lines changed Original file line number Diff line number Diff line change @@ -1218,4 +1218,45 @@ impl FixedDatabaseHandler {
12181218 ) )
12191219 . await
12201220 }
1221+
1222+ /// Get Essentials database version upgrade status
1223+ /// Gets information on the latest upgrade attempt for this Essentials database.
1224+ ///
1225+ /// GET /fixed/subscriptions/{subscriptionId}/databases/{databaseId}/upgrade
1226+ pub async fn get_upgrade_status (
1227+ & self ,
1228+ subscription_id : i32 ,
1229+ database_id : i32 ,
1230+ ) -> Result < Value > {
1231+ self . client
1232+ . get_raw ( & format ! (
1233+ "/fixed/subscriptions/{}/databases/{}/upgrade" ,
1234+ subscription_id, database_id
1235+ ) )
1236+ . await
1237+ }
1238+
1239+ /// Upgrade Essentials database Redis version
1240+ /// Upgrades the specified Essentials database to a later Redis version.
1241+ ///
1242+ /// POST /fixed/subscriptions/{subscriptionId}/databases/{databaseId}/upgrade
1243+ pub async fn upgrade_redis_version (
1244+ & self ,
1245+ subscription_id : i32 ,
1246+ database_id : i32 ,
1247+ target_version : & str ,
1248+ ) -> Result < Value > {
1249+ let request = serde_json:: json!( {
1250+ "targetVersion" : target_version
1251+ } ) ;
1252+ self . client
1253+ . post_raw (
1254+ & format ! (
1255+ "/fixed/subscriptions/{}/databases/{}/upgrade" ,
1256+ subscription_id, database_id
1257+ ) ,
1258+ request,
1259+ )
1260+ . await
1261+ }
12211262}
Original file line number Diff line number Diff line change @@ -656,6 +656,24 @@ pub enum CloudFixedDatabaseCommands {
656656 /// Database ID (format: subscription_id:database_id)
657657 id : String ,
658658 } ,
659+ /// Get Redis version upgrade status
660+ #[ command( name = "upgrade-status" ) ]
661+ UpgradeStatus {
662+ /// Database ID (format: subscription_id:database_id)
663+ id : String ,
664+ } ,
665+ /// Upgrade Redis version
666+ #[ command( name = "upgrade-redis" ) ]
667+ UpgradeRedis {
668+ /// Database ID (format: subscription_id:database_id)
669+ id : String ,
670+ /// Target Redis version
671+ #[ arg( long) ]
672+ version : String ,
673+ /// Async operation options
674+ #[ command( flatten) ]
675+ async_ops : crate :: commands:: cloud:: async_utils:: AsyncOperationArgs ,
676+ } ,
659677}
660678
661679/// Cloud Fixed Subscription Commands
Original file line number Diff line number Diff line change @@ -400,6 +400,7 @@ pub async fn handle_fixed_database_command(
400400 eprintln ! ( "Tag '{}' deleted successfully" , key) ;
401401 Ok ( ( ) )
402402 }
403+
403404 CloudFixedDatabaseCommands :: AvailableVersions { id } => {
404405 let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
405406
@@ -412,5 +413,41 @@ pub async fn handle_fixed_database_command(
412413 print_formatted_output ( data, output_format) ?;
413414 Ok ( ( ) )
414415 }
416+
417+ CloudFixedDatabaseCommands :: UpgradeStatus { id } => {
418+ let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
419+ let result = handler
420+ . get_upgrade_status ( subscription_id, database_id)
421+ . await
422+ . context ( "Failed to get upgrade status" ) ?;
423+
424+ let data = handle_output ( result, output_format, query) ?;
425+ print_formatted_output ( data, output_format) ?;
426+ Ok ( ( ) )
427+ }
428+
429+ CloudFixedDatabaseCommands :: UpgradeRedis {
430+ id,
431+ version,
432+ async_ops,
433+ } => {
434+ let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
435+
436+ let result = handler
437+ . upgrade_redis_version ( subscription_id, database_id, version)
438+ . await
439+ . context ( "Failed to upgrade Redis version" ) ?;
440+
441+ handle_async_response (
442+ conn_mgr,
443+ profile_name,
444+ result,
445+ async_ops,
446+ output_format,
447+ query,
448+ "Redis version upgrade initiated" ,
449+ )
450+ . await
451+ }
415452 }
416453}
Original file line number Diff line number Diff line change @@ -2782,3 +2782,29 @@ fn test_cloud_database_update_tag_help() {
27822782 . stdout ( predicate:: str:: contains ( "--key" ) )
27832783 . stdout ( predicate:: str:: contains ( "--value" ) ) ;
27842784}
2785+
2786+ #[ test]
2787+ fn test_cloud_fixed_database_upgrade_status_help ( ) {
2788+ redisctl ( )
2789+ . arg ( "cloud" )
2790+ . arg ( "fixed-database" )
2791+ . arg ( "upgrade-status" )
2792+ . arg ( "--help" )
2793+ . assert ( )
2794+ . success ( )
2795+ . stdout ( predicate:: str:: contains ( "upgrade status" ) )
2796+ . stdout ( predicate:: str:: contains ( "subscription_id:database_id" ) ) ;
2797+ }
2798+
2799+ #[ test]
2800+ fn test_cloud_fixed_database_upgrade_redis_help ( ) {
2801+ redisctl ( )
2802+ . arg ( "cloud" )
2803+ . arg ( "fixed-database" )
2804+ . arg ( "upgrade-redis" )
2805+ . arg ( "--help" )
2806+ . assert ( )
2807+ . success ( )
2808+ . stdout ( predicate:: str:: contains ( "Upgrade Redis version" ) )
2809+ . stdout ( predicate:: str:: contains ( "--version" ) ) ;
2810+ }
You can’t perform that action at this time.
0 commit comments