Delete VMWare cluster

Delete a cluster from private cloud. Deleting a cluster is a long-running operation and it may take over an hour.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Python

To authenticate to VMware Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

from google.api_core import operation
from google.cloud import vmwareengine_v1


def delete_cluster(
    project_id: str, zone: str, private_cloud_name: str, cluster_name: str
) -> operation.Operation:
    """
    Delete a cluster from private cloud.

    Deleting a cluster is a long-running operation and it may take over an hour..

    Args:
        project_id: name of the project you want to use.
        zone: region in which your private cloud is located.
        private_cloud_name: name of the private cloud hosting the new cluster.
        cluster_name: name of the new cluster.

    Returns:
        An Operation object related to started cluster deletion operation.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    request = vmwareengine_v1.DeleteClusterRequest()
    request.name = (
        f"projects/{project_id}/locations/{zone}/privateClouds/{private_cloud_name}"
        f"/clusters/{cluster_name}"
    )
    return client.delete_cluster(request)

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.