列出可用的 VMWare Engine 位置

输出在 VMWare Engine 中使用的可用位置列表。

代码示例

Python

如需向 VMware Engine 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

from google.cloud import vmwareengine_v1
from google.cloud.location.locations_pb2 import ListLocationsRequest


def list_locations(project_id: str) -> str:
    """
    Prints a list of available locations for use in VMWare Engine.

    Args:
        project_id: name of the project you want to use.

    Returns:
        String containing the list of all available locations.
    """
    client = vmwareengine_v1.VmwareEngineClient()
    request = ListLocationsRequest()
    request.name = f"projects/{project_id}"
    locations = client.list_locations(request)
    print(locations)
    return str(locations)

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器