Skip to content

Commit

Permalink
chore: update to the latest version of the generator (#170)
Browse files Browse the repository at this point in the history
* chore: update to the latest version of the generator

* update integration tests to reflect changes in the code

* update integration tests to reflect changes in the code

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* update samples to reflect changes in the code

* update samples to reflect changes in the code

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and dandhlee committed Nov 16, 2022
1 parent 2b1b8db commit 58202a1
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 29 deletions.
4 changes: 2 additions & 2 deletions compute/compute/snippets/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion compute/compute/snippets/sample_create_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compute/compute/snippets/sample_default_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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={}
)

Expand Down
10 changes: 7 additions & 3 deletions compute/compute/snippets/sample_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions compute/compute/snippets/sample_instance_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions compute/compute/snippets/sample_start_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions compute/compute/snippets/sample_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
16 changes: 10 additions & 6 deletions compute/compute/snippets/test_sample_create_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ 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:
disk = disk_client.get(project=PROJECT, zone=INSTANCE_ZONE, disk=disk.name)
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)


Expand All @@ -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,
Expand All @@ -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)


Expand All @@ -89,15 +93,15 @@ 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:
image = image_client.get(project=PROJECT, image=image.name)
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)


Expand Down
4 changes: 2 additions & 2 deletions compute/compute/snippets/test_sample_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ 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)

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions compute/compute/snippets/test_sample_start_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 58202a1

Please sign in to comment.