Get VCenter credentials

Retrieves VCenter credentials for a Private Cloud.

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.cloud import vmwareengine_v1


def get_vcenter_credentials(
    project_id: str, zone: str, private_cloud_name: str
) -> vmwareengine_v1.Credentials:
    """
    Retrieves VCenter credentials for a Private Cloud.

    Args:
        project_id: name of the project hosting the private cloud.
        zone: name of the zone hosting the private cloud.
        private_cloud_name: name of the private cloud.

    Returns:
        A Credentials object.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    credentials = client.show_vcenter_credentials(
        private_cloud=f"projects/{project_id}/locations/{zone}/privateClouds/{private_cloud_name}"
    )
    return credentials

What's next

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