Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions managedkafka/snippets/clusters/create_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def create_cluster(
)

try:
operation = client.create_cluster(request=request)
print(f"Waiting for operation {operation.operation.name} to complete...")
# The duration of this operation can vary considerably, typically taking 10-40 minutes.
# We can set a timeout of 3000s (50 minutes).
operation = client.create_cluster(request=request, timeout=3000)
print("Waiting for operation to finish...")
response = operation.result()
response = operation.result(timeout=3000)
print("Created cluster:", response)
except GoogleAPICallError:
print("The operation failed with error:", operation.operation.error)
except GoogleAPICallError as e:
print(f"The operation failed with error: {e.message}")

# [END managedkafka_create_cluster]
5 changes: 3 additions & 2 deletions managedkafka/snippets/clusters/delete_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ def delete_cluster(

try:
operation = client.delete_cluster(request=request)
print(f"Waiting for operation {operation.operation.name} to complete...")
operation.result()
print("Deleted cluster")
except GoogleAPICallError:
print("The operation failed with error:", operation.operation.error)
except GoogleAPICallError as e:
print(f"The operation failed with error: {e.message}")

# [END managedkafka_delete_cluster]
5 changes: 3 additions & 2 deletions managedkafka/snippets/clusters/update_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def update_cluster(

try:
operation = client.update_cluster(request=request)
print(f"Waiting for operation {operation.operation.name} to complete...")
response = operation.result()
print("Updated cluster:", response)
except GoogleAPICallError:
print("The operation failed with error:", operation.operation.error)
except GoogleAPICallError as e:
print(f"The operation failed with error: {e.message}")

# [END managedkafka_update_cluster]