diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py index 1f4e6cc36c21..480fcb020e54 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/revisions/async_client.py @@ -229,9 +229,9 @@ async def get_revision( from google.cloud import run_v2 - def sample_get_revision(): + async def sample_get_revision(): # Create a client - client = run_v2.RevisionsClient() + client = run_v2.RevisionsAsyncClient() # Initialize request argument(s) request = run_v2.GetRevisionRequest( @@ -239,7 +239,7 @@ def sample_get_revision(): ) # Make the request - response = client.get_revision(request=request) + response = await client.get_revision(request=request) # Handle the response print(response) @@ -329,9 +329,9 @@ async def list_revisions( from google.cloud import run_v2 - def sample_list_revisions(): + async def sample_list_revisions(): # Create a client - client = run_v2.RevisionsClient() + client = run_v2.RevisionsAsyncClient() # Initialize request argument(s) request = run_v2.ListRevisionsRequest( @@ -342,7 +342,7 @@ def sample_list_revisions(): page_result = client.list_revisions(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -440,9 +440,9 @@ async def delete_revision( from google.cloud import run_v2 - def sample_delete_revision(): + async def sample_delete_revision(): # Create a client - client = run_v2.RevisionsClient() + client = run_v2.RevisionsAsyncClient() # Initialize request argument(s) request = run_v2.DeleteRevisionRequest( @@ -454,7 +454,7 @@ def sample_delete_revision(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) diff --git a/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py b/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py index c1d5c9251f35..e2cccd8b9e1e 100644 --- a/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py +++ b/packages/google-cloud-run/google/cloud/run_v2/services/services/async_client.py @@ -234,9 +234,9 @@ async def create_service( from google.cloud import run_v2 - def sample_create_service(): + async def sample_create_service(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = run_v2.CreateServiceRequest( @@ -249,7 +249,7 @@ def sample_create_service(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -370,9 +370,9 @@ async def get_service( from google.cloud import run_v2 - def sample_get_service(): + async def sample_get_service(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = run_v2.GetServiceRequest( @@ -380,7 +380,7 @@ def sample_get_service(): ) # Make the request - response = client.get_service(request=request) + response = await client.get_service(request=request) # Handle the response print(response) @@ -482,9 +482,9 @@ async def list_services( from google.cloud import run_v2 - def sample_list_services(): + async def sample_list_services(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = run_v2.ListServicesRequest( @@ -495,7 +495,7 @@ def sample_list_services(): page_result = client.list_services(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -603,9 +603,9 @@ async def update_service( from google.cloud import run_v2 - def sample_update_service(): + async def sample_update_service(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = run_v2.UpdateServiceRequest( @@ -616,7 +616,7 @@ def sample_update_service(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -725,9 +725,9 @@ async def delete_service( from google.cloud import run_v2 - def sample_delete_service(): + async def sample_delete_service(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = run_v2.DeleteServiceRequest( @@ -739,7 +739,7 @@ def sample_delete_service(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -842,9 +842,9 @@ async def get_iam_policy( from google.cloud import run_v2 from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.GetIamPolicyRequest( @@ -852,7 +852,7 @@ def sample_get_iam_policy(): ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -979,9 +979,9 @@ async def set_iam_policy( from google.cloud import run_v2 from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.SetIamPolicyRequest( @@ -989,7 +989,7 @@ def sample_set_iam_policy(): ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -1118,9 +1118,9 @@ async def test_iam_permissions( from google.cloud import run_v2 from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = run_v2.ServicesClient() + client = run_v2.ServicesAsyncClient() # Initialize request argument(s) request = iam_policy_pb2.TestIamPermissionsRequest( @@ -1129,7 +1129,7 @@ def sample_test_iam_permissions(): ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py index 7a67476b0236..659cc58d9204 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_revisions.py @@ -785,7 +785,7 @@ def test_get_revision_field_headers(): # a field header. Set these to a non-empty value. request = revision.GetRevisionRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_revision), "__call__") as call: @@ -801,7 +801,7 @@ def test_get_revision_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -815,7 +815,7 @@ async def test_get_revision_field_headers_async(): # a field header. Set these to a non-empty value. request = revision.GetRevisionRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_revision), "__call__") as call: @@ -831,7 +831,7 @@ async def test_get_revision_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1013,7 +1013,7 @@ def test_list_revisions_field_headers(): # a field header. Set these to a non-empty value. request = revision.ListRevisionsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: @@ -1029,7 +1029,7 @@ def test_list_revisions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1043,7 +1043,7 @@ async def test_list_revisions_field_headers_async(): # a field header. Set these to a non-empty value. request = revision.ListRevisionsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_revisions), "__call__") as call: @@ -1061,7 +1061,7 @@ async def test_list_revisions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1192,7 +1192,7 @@ def test_list_revisions_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, revision.Revision) for i in results) @@ -1427,7 +1427,7 @@ def test_delete_revision_field_headers(): # a field header. Set these to a non-empty value. request = revision.DeleteRevisionRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_revision), "__call__") as call: @@ -1443,7 +1443,7 @@ def test_delete_revision_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1457,7 +1457,7 @@ async def test_delete_revision_field_headers_async(): # a field header. Set these to a non-empty value. request = revision.DeleteRevisionRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_revision), "__call__") as call: @@ -1475,7 +1475,7 @@ async def test_delete_revision_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] diff --git a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py index 79098db0865b..80d7445bd1cb 100644 --- a/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py +++ b/packages/google-cloud-run/tests/unit/gapic/run_v2/test_services.py @@ -721,7 +721,7 @@ def test_create_service_field_headers(): # a field header. Set these to a non-empty value. request = gcr_service.CreateServiceRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_service), "__call__") as call: @@ -737,7 +737,7 @@ def test_create_service_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -751,7 +751,7 @@ async def test_create_service_field_headers_async(): # a field header. Set these to a non-empty value. request = gcr_service.CreateServiceRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_service), "__call__") as call: @@ -769,7 +769,7 @@ async def test_create_service_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1033,7 +1033,7 @@ def test_get_service_field_headers(): # a field header. Set these to a non-empty value. request = service.GetServiceRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_service), "__call__") as call: @@ -1049,7 +1049,7 @@ def test_get_service_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1063,7 +1063,7 @@ async def test_get_service_field_headers_async(): # a field header. Set these to a non-empty value. request = service.GetServiceRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_service), "__call__") as call: @@ -1079,7 +1079,7 @@ async def test_get_service_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1261,7 +1261,7 @@ def test_list_services_field_headers(): # a field header. Set these to a non-empty value. request = service.ListServicesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -1277,7 +1277,7 @@ def test_list_services_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1291,7 +1291,7 @@ async def test_list_services_field_headers_async(): # a field header. Set these to a non-empty value. request = service.ListServicesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -1309,7 +1309,7 @@ async def test_list_services_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "parent=parent/value", + "parent=parent_value", ) in kw["metadata"] @@ -1440,7 +1440,7 @@ def test_list_services_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, service.Service) for i in results) @@ -1675,7 +1675,7 @@ def test_update_service_field_headers(): # a field header. Set these to a non-empty value. request = gcr_service.UpdateServiceRequest() - request.service.name = "service.name/value" + request.service.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_service), "__call__") as call: @@ -1691,7 +1691,7 @@ def test_update_service_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "service.name=service.name/value", + "service.name=name_value", ) in kw["metadata"] @@ -1705,7 +1705,7 @@ async def test_update_service_field_headers_async(): # a field header. Set these to a non-empty value. request = gcr_service.UpdateServiceRequest() - request.service.name = "service.name/value" + request.service.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_service), "__call__") as call: @@ -1723,7 +1723,7 @@ async def test_update_service_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "service.name=service.name/value", + "service.name=name_value", ) in kw["metadata"] @@ -1911,7 +1911,7 @@ def test_delete_service_field_headers(): # a field header. Set these to a non-empty value. request = service.DeleteServiceRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_service), "__call__") as call: @@ -1927,7 +1927,7 @@ def test_delete_service_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -1941,7 +1941,7 @@ async def test_delete_service_field_headers_async(): # a field header. Set these to a non-empty value. request = service.DeleteServiceRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_service), "__call__") as call: @@ -1959,7 +1959,7 @@ async def test_delete_service_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "name=name/value", + "name=name_value", ) in kw["metadata"] @@ -2147,7 +2147,7 @@ def test_get_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2163,7 +2163,7 @@ def test_get_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -2177,7 +2177,7 @@ async def test_get_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2193,7 +2193,7 @@ async def test_get_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -2316,7 +2316,7 @@ def test_set_iam_policy_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2332,7 +2332,7 @@ def test_set_iam_policy_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -2346,7 +2346,7 @@ async def test_set_iam_policy_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2362,7 +2362,7 @@ async def test_set_iam_policy_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -2489,7 +2489,7 @@ def test_test_iam_permissions_field_headers(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2507,7 +2507,7 @@ def test_test_iam_permissions_field_headers(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"] @@ -2521,7 +2521,7 @@ async def test_test_iam_permissions_field_headers_async(): # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2541,7 +2541,7 @@ async def test_test_iam_permissions_field_headers_async(): _, _, kw = call.mock_calls[0] assert ( "x-goog-request-params", - "resource=resource/value", + "resource=resource_value", ) in kw["metadata"]