diff --git a/compute/compute/snippets/quickstart.py b/compute/compute/snippets/quickstart.py index fa481f8c9bed..bdbdf4fc1352 100644 --- a/compute/compute/snippets/quickstart.py +++ b/compute/compute/snippets/quickstart.py @@ -161,7 +161,7 @@ def create_instance( # Wait for the create operation to complete. print(f"Creating the {instance_name} instance in {zone}...") - operation = instance_client.insert(request=request) + operation = instance_client.insert_unary(request=request) while operation.status != compute_v1.Operation.Status.DONE: operation = operation_client.wait( operation=operation.name, zone=zone, project=project_id @@ -191,7 +191,7 @@ def delete_instance(project_id: str, zone: str, machine_name: str) -> None: operation_client = compute_v1.ZoneOperationsClient() print(f"Deleting {machine_name} from {zone}...") - operation = instance_client.delete( + operation = instance_client.delete_unary( project=project_id, zone=zone, instance=machine_name ) while operation.status != compute_v1.Operation.Status.DONE: diff --git a/compute/compute/snippets/sample_create_vm.py b/compute/compute/snippets/sample_create_vm.py index 21021e010dfd..e1ba3907a510 100644 --- a/compute/compute/snippets/sample_create_vm.py +++ b/compute/compute/snippets/sample_create_vm.py @@ -214,7 +214,7 @@ def create_with_disks( # Wait for the create operation to complete. print(f"Creating the {instance_name} instance in {zone}...") - operation = instance_client.insert(request=request) + operation = instance_client.insert_unary(request=request) while operation.status != compute_v1.Operation.Status.DONE: operation = operation_client.wait( operation=operation.name, zone=zone, project=project_id diff --git a/compute/compute/snippets/sample_default_values.py b/compute/compute/snippets/sample_default_values.py index 705a81d0b7b2..35148795279f 100644 --- a/compute/compute/snippets/sample_default_values.py +++ b/compute/compute/snippets/sample_default_values.py @@ -58,7 +58,7 @@ def set_usage_export_bucket( ) projects_client = compute_v1.ProjectsClient() - operation = projects_client.set_usage_export_bucket( + operation = projects_client.set_usage_export_bucket_unary( project=project_id, usage_export_location_resource=usage_export_location ) @@ -121,7 +121,7 @@ def disable_usage_export(project_id: str) -> None: # Setting `usage_export_location_resource` to an # empty object will disable the usage report generation. - operation = projects_client.set_usage_export_bucket( + operation = projects_client.set_usage_export_bucket_unary( project=project_id, usage_export_location_resource={} ) diff --git a/compute/compute/snippets/sample_firewall.py b/compute/compute/snippets/sample_firewall.py index b9a0d3d2f99e..c2bdd3fa75ae 100644 --- a/compute/compute/snippets/sample_firewall.py +++ b/compute/compute/snippets/sample_firewall.py @@ -95,7 +95,9 @@ def create_firewall_rule( # firewall_rule.priority = 0 firewall_client = compute_v1.FirewallsClient() - op = firewall_client.insert(project=project_id, firewall_resource=firewall_rule) + op = firewall_client.insert_unary( + project=project_id, firewall_resource=firewall_rule + ) op_client = compute_v1.GlobalOperationsClient() op_client.wait(project=project_id, operation=op.name) @@ -122,7 +124,7 @@ def patch_firewall_priority(project_id: str, firewall_rule_name: str, priority: # The patch operation doesn't require the full definition of a Firewall object. It will only update # the values that were set in it, in this case it will only change the priority. firewall_client = compute_v1.FirewallsClient() - operation = firewall_client.patch( + operation = firewall_client.patch_unary( project=project_id, firewall=firewall_rule_name, firewall_resource=firewall_rule ) @@ -144,7 +146,9 @@ def delete_firewall_rule(project_id: str, firewall_rule_name: str): firewall_rule_name: name of the firewall rule you want to delete. """ firewall_client = compute_v1.FirewallsClient() - operation = firewall_client.delete(project=project_id, firewall=firewall_rule_name) + operation = firewall_client.delete_unary( + project=project_id, firewall=firewall_rule_name + ) operation_client = compute_v1.GlobalOperationsClient() operation_client.wait(project=project_id, operation=operation.name) diff --git a/compute/compute/snippets/sample_instance_from_template.py b/compute/compute/snippets/sample_instance_from_template.py index 5c3e03935c65..30ef65dbae31 100644 --- a/compute/compute/snippets/sample_instance_from_template.py +++ b/compute/compute/snippets/sample_instance_from_template.py @@ -48,7 +48,7 @@ def create_instance_from_template( instance_insert_request.source_instance_template = instance_template_url instance_insert_request.instance_resource.name = instance_name - op = instance_client.insert(instance_insert_request) + op = instance_client.insert_unary(instance_insert_request) operation_client.wait(project=project_id, zone=zone, operation=op.name) return instance_client.get(project=project_id, zone=zone, instance=instance_name) @@ -127,7 +127,7 @@ def create_instance_from_template_with_overrides( instance_insert_request.instance_resource = instance instance_insert_request.source_instance_template = instance_template.self_link - op = instance_client.insert(instance_insert_request) + op = instance_client.insert_unary(instance_insert_request) operation_client.wait(project=project_id, zone=zone, operation=op.name) return instance_client.get(project=project_id, zone=zone, instance=instance_name) diff --git a/compute/compute/snippets/sample_start_stop.py b/compute/compute/snippets/sample_start_stop.py index cce524fad871..1637ee778488 100644 --- a/compute/compute/snippets/sample_start_stop.py +++ b/compute/compute/snippets/sample_start_stop.py @@ -85,7 +85,7 @@ def start_instance_with_encryption_key( enc_data = compute_v1.InstancesStartWithEncryptionKeyRequest() enc_data.disks = [disk_data] - op = instance_client.start_with_encryption_key( + op = instance_client.start_with_encryption_key_unary( project=project_id, zone=zone, instance=instance_name, @@ -113,7 +113,9 @@ def stop_instance(project_id: str, zone: str, instance_name: str): instance_client = compute_v1.InstancesClient() op_client = compute_v1.ZoneOperationsClient() - op = instance_client.stop(project=project_id, zone=zone, instance=instance_name) + op = instance_client.stop_unary( + project=project_id, zone=zone, instance=instance_name + ) while op.status != compute_v1.Operation.Status.DONE: op = op_client.wait(operation=op.name, zone=zone, project=project_id) @@ -136,7 +138,9 @@ def reset_instance(project_id: str, zone: str, instance_name: str): instance_client = compute_v1.InstancesClient() op_client = compute_v1.ZoneOperationsClient() - op = instance_client.reset(project=project_id, zone=zone, instance=instance_name) + op = instance_client.reset_unary( + project=project_id, zone=zone, instance=instance_name + ) while op.status != compute_v1.Operation.Status.DONE: op = op_client.wait(operation=op.name, zone=zone, project=project_id) diff --git a/compute/compute/snippets/sample_templates.py b/compute/compute/snippets/sample_templates.py index 3ec1600bf131..ddea063770a4 100644 --- a/compute/compute/snippets/sample_templates.py +++ b/compute/compute/snippets/sample_templates.py @@ -118,7 +118,9 @@ def create_template(project_id: str, template_name: str) -> compute_v1.InstanceT template_client = compute_v1.InstanceTemplatesClient() operation_client = compute_v1.GlobalOperationsClient() - op = template_client.insert(project=project_id, instance_template_resource=template) + op = template_client.insert_unary( + project=project_id, instance_template_resource=template + ) operation_client.wait(project=project_id, operation=op.name) return template_client.get(project=project_id, instance_template=template_name) @@ -162,7 +164,9 @@ def create_template_from_instance( template_client = compute_v1.InstanceTemplatesClient() operation_client = compute_v1.GlobalOperationsClient() - op = template_client.insert(project=project_id, instance_template_resource=template) + op = template_client.insert_unary( + project=project_id, instance_template_resource=template + ) operation_client.wait(project=project_id, operation=op.name) return template_client.get(project=project_id, instance_template=template_name) @@ -215,7 +219,9 @@ def create_template_with_subnet( template_client = compute_v1.InstanceTemplatesClient() operation_client = compute_v1.GlobalOperationsClient() - op = template_client.insert(project=project_id, instance_template_resource=template) + op = template_client.insert_unary( + project=project_id, instance_template_resource=template + ) operation_client.wait(project=project_id, operation=op.name) return template_client.get(project=project_id, instance_template=template_name) @@ -235,7 +241,9 @@ def delete_instance_template(project_id: str, template_name: str): """ template_client = compute_v1.InstanceTemplatesClient() operation_client = compute_v1.GlobalOperationsClient() - op = template_client.delete(project=project_id, instance_template=template_name) + op = template_client.delete_unary( + project=project_id, instance_template=template_name + ) operation_client.wait(project=project_id, operation=op.name) return diff --git a/compute/compute/snippets/test_sample_create_vm.py b/compute/compute/snippets/test_sample_create_vm.py index 2b6d69fa3f04..3e3189d904a1 100644 --- a/compute/compute/snippets/test_sample_create_vm.py +++ b/compute/compute/snippets/test_sample_create_vm.py @@ -46,7 +46,9 @@ def src_disk(request): disk = compute_v1.Disk() disk.source_image = get_active_debian().self_link disk.name = "test-disk-" + uuid.uuid4().hex[:10] - op = disk_client.insert(project=PROJECT, zone=INSTANCE_ZONE, disk_resource=disk) + op = disk_client.insert_unary( + project=PROJECT, zone=INSTANCE_ZONE, disk_resource=disk + ) wait_for_operation(op, PROJECT) try: @@ -54,7 +56,9 @@ def src_disk(request): request.cls.disk = disk yield disk finally: - op = disk_client.delete(project=PROJECT, zone=INSTANCE_ZONE, disk=disk.name) + op = disk_client.delete_unary( + project=PROJECT, zone=INSTANCE_ZONE, disk=disk.name + ) wait_for_operation(op, PROJECT) @@ -64,7 +68,7 @@ def snapshot(request, src_disk): snapshot = compute_v1.Snapshot() snapshot.name = "test-snap-" + uuid.uuid4().hex[:10] disk_client = compute_v1.DisksClient() - op = disk_client.create_snapshot( + op = disk_client.create_snapshot_unary( project=PROJECT, zone=INSTANCE_ZONE, disk=src_disk.name, @@ -79,7 +83,7 @@ def snapshot(request, src_disk): yield snapshot finally: - op = snapshot_client.delete(project=PROJECT, snapshot=snapshot.name) + op = snapshot_client.delete_unary(project=PROJECT, snapshot=snapshot.name) wait_for_operation(op, PROJECT) @@ -89,7 +93,7 @@ def image(request, src_disk): image = compute_v1.Image() image.source_disk = src_disk.self_link image.name = "test-image-" + uuid.uuid4().hex[:10] - op = image_client.insert(project=PROJECT, image_resource=image) + op = image_client.insert_unary(project=PROJECT, image_resource=image) wait_for_operation(op, PROJECT) try: @@ -97,7 +101,7 @@ def image(request, src_disk): request.cls.image = image yield image finally: - op = image_client.delete(project=PROJECT, image=image.name) + op = image_client.delete_unary(project=PROJECT, image=image.name) wait_for_operation(op, PROJECT) diff --git a/compute/compute/snippets/test_sample_firewall.py b/compute/compute/snippets/test_sample_firewall.py index d7bd68b952ae..1bb63cfd8f0d 100644 --- a/compute/compute/snippets/test_sample_firewall.py +++ b/compute/compute/snippets/test_sample_firewall.py @@ -46,7 +46,7 @@ def firewall_rule(): firewall_rule.target_tags = ["web"] firewall_client = compute_v1.FirewallsClient() - op = firewall_client.insert(project=PROJECT, firewall_resource=firewall_rule) + op = firewall_client.insert_unary(project=PROJECT, firewall_resource=firewall_rule) op_client = compute_v1.GlobalOperationsClient() op_client.wait(project=PROJECT, operation=op.name) @@ -54,7 +54,7 @@ def firewall_rule(): yield firewall_client.get(project=PROJECT, firewall=firewall_rule.name) try: - op = firewall_client.delete(project=PROJECT, firewall=firewall_rule.name) + op = firewall_client.delete_unary(project=PROJECT, firewall=firewall_rule.name) op_client.wait(project=PROJECT, operation=op.name) except google.api_core.exceptions.BadRequest as err: if err.code == 400 and "is not ready" in err.message: diff --git a/compute/compute/snippets/test_sample_instance_from_template.py b/compute/compute/snippets/test_sample_instance_from_template.py index 5728c2c476aa..6b17220fd3a7 100644 --- a/compute/compute/snippets/test_sample_instance_from_template.py +++ b/compute/compute/snippets/test_sample_instance_from_template.py @@ -51,14 +51,16 @@ def instance_template(): template_client = compute_v1.InstanceTemplatesClient() operation_client = compute_v1.GlobalOperationsClient() - op = template_client.insert(project=PROJECT, instance_template_resource=template) + op = template_client.insert_unary( + project=PROJECT, instance_template_resource=template + ) operation_client.wait(project=PROJECT, operation=op.name) template = template_client.get(project=PROJECT, instance_template=template.name) yield template - op = template_client.delete(project=PROJECT, instance_template=template.name) + op = template_client.delete_unary(project=PROJECT, instance_template=template.name) operation_client.wait(project=PROJECT, operation=op.name) diff --git a/compute/compute/snippets/test_sample_start_stop.py b/compute/compute/snippets/test_sample_start_stop.py index 734589be1093..bcf249f22ddb 100644 --- a/compute/compute/snippets/test_sample_start_stop.py +++ b/compute/compute/snippets/test_sample_start_stop.py @@ -83,7 +83,7 @@ def _create_instance(request: compute_v1.InsertInstanceRequest): instance_client = compute_v1.InstancesClient() operation_client = compute_v1.ZoneOperationsClient() - operation = instance_client.insert(request=request) + operation = instance_client.insert_unary(request=request) while operation.status != compute_v1.Operation.Status.DONE: operation = operation_client.wait( operation=operation.name, zone=INSTANCE_ZONE, project=PROJECT @@ -98,7 +98,7 @@ def _delete_instance(instance: compute_v1.Instance): instance_client = compute_v1.InstancesClient() operation_client = compute_v1.ZoneOperationsClient() - operation = instance_client.delete( + operation = instance_client.delete_unary( project=PROJECT, zone=INSTANCE_ZONE, instance=instance.name ) while operation.status != compute_v1.Operation.Status.DONE: