在 python 中创建 gcp 计算客户端的当前“标准”方法是什么?我都见过:
import googleapiclient.discovery
service = googleapiclient.discovery.build(
'container', 'v1', credentials=credentials)
body = {
"autoCreateSubnetworks": False,
"description": "",
"mtu": 1460.0,
"name": "test_network",
"routingConfig": {
"routingMode": "REGIONAL"
}
}
network = compute.networks().insert(project=project_id, body=body, requestId=str(uuid.uuid4())).execute()
和:
from google.cloud import compute_v1
compute = compute_v1.InstancesClient(credentials=credentials)
net = compute.Network()
net.auto_create_subnetworks = False
net.description = ""
net.mtu = 1460.0
net.name = "test_network"
net.routing_config = {
"routingMode": "REGIONAL"
}
request = InsertNetworkRequest()
request.project = project_id
request.request_id = str(uuid.uuid4())
request.network_resource = net
network = compute.NetworksClient().insert(request=request)
谷歌是否计划在未来某个地方只支持一个?