列出區域中的網路

擷取指定區域中定義的 VMware Engine 網路清單。

程式碼範例

Python

如要向 VMware Engine 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

from typing import Iterable

from google.cloud import vmwareengine_v1


def list_networks(
    project_id: str, region: str
) -> Iterable[vmwareengine_v1.VmwareEngineNetwork]:
    """
    Retrieves a list of VMware Engine networks defined in given region.

    Args:
        project_id: name of the project you want to use.
        region: name of the region for which you want to list networks.

    Returns:
        An iterable collection containing the VMWareEngineNetworks.
    """
    client = vmwareengine_v1.VmwareEngineClient()

    return client.list_vmware_engine_networks(
        parent=f"projects/{project_id}/locations/{region}"
    )

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽器