1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- # [START managedkafka_update_cluster]
16- from google .api_core .exceptions import GoogleAPICallError
17- from google .cloud import managedkafka_v1
18- from google .protobuf import field_mask_pb2
19-
2015
2116def update_cluster (
2217 project_id : str , region : str , cluster_id : str , memory_bytes : int
2318) -> None :
2419 """
25- Update a Kafka cluster. For a list of editable fields, one can check https://cloud.google.com/managed-kafka/docs/create-cluster#properties.
20+ Update a Kafka cluster.
2621
2722 Args:
2823 project_id: Google Cloud project ID.
@@ -34,6 +29,16 @@ def update_cluster(
3429 This method will raise the exception if the operation errors or
3530 the timeout before the operation completes is reached.
3631 """
32+ # [START managedkafka_update_cluster]
33+ from google .api_core .exceptions import GoogleAPICallError
34+ from google .cloud import managedkafka_v1
35+ from google .protobuf import field_mask_pb2
36+
37+ # TODO(developer)
38+ # project_id = "my-project-id"
39+ # region = "us-central1"
40+ # cluster_id = "my-cluster"
41+ # memory_bytes = 4295000000
3742
3843 client = managedkafka_v1 .ManagedKafkaClient ()
3944
@@ -43,6 +48,7 @@ def update_cluster(
4348 update_mask = field_mask_pb2 .FieldMask ()
4449 update_mask .paths .append ("capacity_config.memory_bytes" )
4550
51+ # For a list of editable fields, one can check https://cloud.google.com/managed-kafka/docs/create-cluster#properties.
4652 request = managedkafka_v1 .UpdateClusterRequest (
4753 update_mask = update_mask ,
4854 cluster = cluster ,
@@ -53,7 +59,6 @@ def update_cluster(
5359 response = operation .result ()
5460 print ("Updated cluster:" , response )
5561 except GoogleAPICallError :
56- print (operation .operation .error )
57-
62+ print ("The operation failed with error:" , operation .operation .error )
5863
59- # [END managedkafka_update_cluster]
64+ # [END managedkafka_update_cluster]
0 commit comments