33#![ allow( dead_code) ]
44
55use crate :: cli:: { CloudFixedDatabaseCommands , OutputFormat } ;
6+ use crate :: commands:: cloud:: async_utils:: handle_async_response;
67use crate :: commands:: cloud:: utils:: {
78 confirm_action, handle_output, print_formatted_output, read_file_input,
89} ;
@@ -83,6 +84,7 @@ pub async fn handle_fixed_database_command(
8384 CloudFixedDatabaseCommands :: Create {
8485 subscription_id,
8586 file,
87+ async_ops,
8688 } => {
8789 let json_string = read_file_input ( file) ?;
8890 let request: FixedDatabaseCreateRequest =
@@ -93,23 +95,26 @@ pub async fn handle_fixed_database_command(
9395 . await
9496 . context ( "Failed to create fixed database" ) ?;
9597
96- // Check if response contains a task ID
9798 let json_result =
9899 serde_json:: to_value ( & result) . context ( "Failed to serialize response" ) ?;
99- if let Some ( task_id) = json_result. get ( "taskId" ) . and_then ( |v| v. as_str ( ) ) {
100- eprintln ! ( "Fixed database creation initiated. Task ID: {}" , task_id) ;
101- eprintln ! (
102- "Use 'redisctl cloud task wait {}' to monitor progress" ,
103- task_id
104- ) ;
105- }
106100
107- let data = handle_output ( json_result, output_format, query) ?;
108- print_formatted_output ( data, output_format) ?;
109- Ok ( ( ) )
101+ handle_async_response (
102+ conn_mgr,
103+ profile_name,
104+ json_result,
105+ async_ops,
106+ output_format,
107+ query,
108+ "Fixed database created successfully" ,
109+ )
110+ . await
110111 }
111112
112- CloudFixedDatabaseCommands :: Update { id, file } => {
113+ CloudFixedDatabaseCommands :: Update {
114+ id,
115+ file,
116+ async_ops,
117+ } => {
113118 let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
114119 let json_string = read_file_input ( file) ?;
115120 let request: FixedDatabaseUpdateRequest =
@@ -120,23 +125,22 @@ pub async fn handle_fixed_database_command(
120125 . await
121126 . context ( "Failed to update fixed database" ) ?;
122127
123- // Check if response contains a task ID
124128 let json_result =
125129 serde_json:: to_value ( & result) . context ( "Failed to serialize response" ) ?;
126- if let Some ( task_id) = json_result. get ( "taskId" ) . and_then ( |v| v. as_str ( ) ) {
127- eprintln ! ( "Fixed database update initiated. Task ID: {}" , task_id) ;
128- eprintln ! (
129- "Use 'redisctl cloud task wait {}' to monitor progress" ,
130- task_id
131- ) ;
132- }
133130
134- let data = handle_output ( json_result, output_format, query) ?;
135- print_formatted_output ( data, output_format) ?;
136- Ok ( ( ) )
131+ handle_async_response (
132+ conn_mgr,
133+ profile_name,
134+ json_result,
135+ async_ops,
136+ output_format,
137+ query,
138+ "Fixed database updated successfully" ,
139+ )
140+ . await
137141 }
138142
139- CloudFixedDatabaseCommands :: Delete { id, yes } => {
143+ CloudFixedDatabaseCommands :: Delete { id, yes, async_ops } => {
140144 let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
141145
142146 if !yes {
@@ -152,22 +156,19 @@ pub async fn handle_fixed_database_command(
152156 . await
153157 . context ( "Failed to delete fixed database" ) ?;
154158
155- // Check if response contains a task ID
156159 let json_result =
157160 serde_json:: to_value ( & result) . context ( "Failed to serialize response" ) ?;
158- if let Some ( task_id) = json_result. get ( "taskId" ) . and_then ( |v| v. as_str ( ) ) {
159- eprintln ! ( "Fixed database deletion initiated. Task ID: {}" , task_id) ;
160- eprintln ! (
161- "Use 'redisctl cloud task wait {}' to monitor progress" ,
162- task_id
163- ) ;
164- } else {
165- eprintln ! ( "Fixed database deleted successfully" ) ;
166- }
167161
168- let data = handle_output ( json_result, output_format, query) ?;
169- print_formatted_output ( data, output_format) ?;
170- Ok ( ( ) )
162+ handle_async_response (
163+ conn_mgr,
164+ profile_name,
165+ json_result,
166+ async_ops,
167+ output_format,
168+ query,
169+ "Fixed database deleted successfully" ,
170+ )
171+ . await
171172 }
172173
173174 CloudFixedDatabaseCommands :: BackupStatus { id } => {
@@ -184,7 +185,7 @@ pub async fn handle_fixed_database_command(
184185 Ok ( ( ) )
185186 }
186187
187- CloudFixedDatabaseCommands :: Backup { id } => {
188+ CloudFixedDatabaseCommands :: Backup { id, async_ops } => {
188189 let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
189190
190191 // Create a minimal backup request - most fields are optional
@@ -201,20 +202,19 @@ pub async fn handle_fixed_database_command(
201202 . await
202203 . context ( "Failed to initiate backup" ) ?;
203204
204- // Check if response contains a task ID
205205 let json_result =
206206 serde_json:: to_value ( & result) . context ( "Failed to serialize response" ) ?;
207- if let Some ( task_id) = json_result. get ( "taskId" ) . and_then ( |v| v. as_str ( ) ) {
208- eprintln ! ( "Backup initiated. Task ID: {}" , task_id) ;
209- eprintln ! (
210- "Use 'redisctl cloud task wait {}' to monitor progress" ,
211- task_id
212- ) ;
213- }
214207
215- let data = handle_output ( json_result, output_format, query) ?;
216- print_formatted_output ( data, output_format) ?;
217- Ok ( ( ) )
208+ handle_async_response (
209+ conn_mgr,
210+ profile_name,
211+ json_result,
212+ async_ops,
213+ output_format,
214+ query,
215+ "Backup initiated successfully" ,
216+ )
217+ . await
218218 }
219219
220220 CloudFixedDatabaseCommands :: ImportStatus { id } => {
@@ -231,7 +231,11 @@ pub async fn handle_fixed_database_command(
231231 Ok ( ( ) )
232232 }
233233
234- CloudFixedDatabaseCommands :: Import { id, file } => {
234+ CloudFixedDatabaseCommands :: Import {
235+ id,
236+ file,
237+ async_ops,
238+ } => {
235239 let ( subscription_id, database_id) = parse_fixed_database_id ( id) ?;
236240 let json_string = read_file_input ( file) ?;
237241 let request: FixedDatabaseImportRequest =
@@ -242,20 +246,19 @@ pub async fn handle_fixed_database_command(
242246 . await
243247 . context ( "Failed to initiate import" ) ?;
244248
245- // Check if response contains a task ID
246249 let json_result =
247250 serde_json:: to_value ( & result) . context ( "Failed to serialize response" ) ?;
248- if let Some ( task_id) = json_result. get ( "taskId" ) . and_then ( |v| v. as_str ( ) ) {
249- eprintln ! ( "Import initiated. Task ID: {}" , task_id) ;
250- eprintln ! (
251- "Use 'redisctl cloud task wait {}' to monitor progress" ,
252- task_id
253- ) ;
254- }
255251
256- let data = handle_output ( json_result, output_format, query) ?;
257- print_formatted_output ( data, output_format) ?;
258- Ok ( ( ) )
252+ handle_async_response (
253+ conn_mgr,
254+ profile_name,
255+ json_result,
256+ async_ops,
257+ output_format,
258+ query,
259+ "Import initiated successfully" ,
260+ )
261+ . await
259262 }
260263
261264 CloudFixedDatabaseCommands :: SlowLog {
0 commit comments