File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
managedkafka/snippets/clusters Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,13 @@ def create_cluster(
6868 )
6969
7070 try :
71+ operation = client .create_cluster (request = request )
72+ print (f"Waiting for operation { operation .operation .name } to complete..." )
7173 # The duration of this operation can vary considerably, typically taking 10-40 minutes.
7274 # We can set a timeout of 3000s (50 minutes).
73- operation = client .create_cluster (request = request , timeout = 3000 )
74- print ("Waiting for operation to finish..." )
75- response = operation .result ()
75+ response = operation .result (timeout = 3000 )
7676 print ("Created cluster:" , response )
77- except GoogleAPICallError :
78- print ("The operation failed with error:" , operation . operation . error )
77+ except GoogleAPICallError as e :
78+ print (f "The operation failed with error: { e . message } " )
7979
8080 # [END managedkafka_create_cluster]
Original file line number Diff line number Diff line change @@ -47,9 +47,10 @@ def delete_cluster(
4747
4848 try :
4949 operation = client .delete_cluster (request = request )
50+ print (f"Waiting for operation { operation .operation .name } to complete..." )
5051 operation .result ()
5152 print ("Deleted cluster" )
52- except GoogleAPICallError :
53- print ("The operation failed with error:" , operation . operation . error )
53+ except GoogleAPICallError as e :
54+ print (f "The operation failed with error: { e . message } " )
5455
5556 # [END managedkafka_delete_cluster]
Original file line number Diff line number Diff line change @@ -56,9 +56,10 @@ def update_cluster(
5656
5757 try :
5858 operation = client .update_cluster (request = request )
59+ print (f"Waiting for operation { operation .operation .name } to complete..." )
5960 response = operation .result ()
6061 print ("Updated cluster:" , response )
61- except GoogleAPICallError :
62- print ("The operation failed with error:" , operation . operation . error )
62+ except GoogleAPICallError as e :
63+ print (f "The operation failed with error: { e . message } " )
6364
6465 # [END managedkafka_update_cluster]
You can’t perform that action at this time.
0 commit comments