列出可用的 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 範例瀏覽器