Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ async def enable_service(

from google.cloud import service_usage_v1

def sample_enable_service():
async def sample_enable_service():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.EnableServiceRequest(
Expand All @@ -234,7 +234,7 @@ def sample_enable_service():

print("Waiting for operation to complete...")

response = operation.result()
response = await operation.result()

# Handle the response
print(response)
Expand Down Expand Up @@ -316,9 +316,9 @@ async def disable_service(

from google.cloud import service_usage_v1

def sample_disable_service():
async def sample_disable_service():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.DisableServiceRequest(
Expand All @@ -329,7 +329,7 @@ def sample_disable_service():

print("Waiting for operation to complete...")

response = operation.result()
response = await operation.result()

# Handle the response
print(response)
Expand Down Expand Up @@ -405,16 +405,16 @@ async def get_service(

from google.cloud import service_usage_v1

def sample_get_service():
async def sample_get_service():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.GetServiceRequest(
)

# Make the request
response = client.get_service(request=request)
response = await client.get_service(request=request)

# Handle the response
print(response)
Expand Down Expand Up @@ -490,9 +490,9 @@ async def list_services(

from google.cloud import service_usage_v1

def sample_list_services():
async def sample_list_services():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.ListServicesRequest(
Expand All @@ -502,7 +502,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:
Expand Down Expand Up @@ -577,9 +577,9 @@ async def batch_enable_services(

from google.cloud import service_usage_v1

def sample_batch_enable_services():
async def sample_batch_enable_services():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.BatchEnableServicesRequest(
Expand All @@ -590,7 +590,7 @@ def sample_batch_enable_services():

print("Waiting for operation to complete...")

response = operation.result()
response = await operation.result()

# Handle the response
print(response)
Expand Down Expand Up @@ -666,16 +666,16 @@ async def batch_get_services(

from google.cloud import service_usage_v1

def sample_batch_get_services():
async def sample_batch_get_services():
# Create a client
client = service_usage_v1.ServiceUsageClient()
client = service_usage_v1.ServiceUsageAsyncClient()

# Initialize request argument(s)
request = service_usage_v1.BatchGetServicesRequest(
)

# Make the request
response = client.batch_get_services(request=request)
response = await client.batch_get_services(request=request)

# Handle the response
print(response)
Expand Down
50 changes: 25 additions & 25 deletions tests/unit/gapic/service_usage_v1/test_service_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def test_enable_service_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.EnableServiceRequest()

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.enable_service), "__call__") as call:
Expand All @@ -752,7 +752,7 @@ def test_enable_service_field_headers():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"name=name/value",
"name=name_value",
) in kw["metadata"]


Expand All @@ -766,7 +766,7 @@ async def test_enable_service_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.EnableServiceRequest()

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.enable_service), "__call__") as call:
Expand All @@ -784,7 +784,7 @@ async def test_enable_service_field_headers_async():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"name=name/value",
"name=name_value",
) in kw["metadata"]


Expand Down Expand Up @@ -880,7 +880,7 @@ def test_disable_service_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.DisableServiceRequest()

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.disable_service), "__call__") as call:
Expand All @@ -896,7 +896,7 @@ def test_disable_service_field_headers():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"name=name/value",
"name=name_value",
) in kw["metadata"]


Expand All @@ -910,7 +910,7 @@ async def test_disable_service_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.DisableServiceRequest()

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.disable_service), "__call__") as call:
Expand All @@ -928,7 +928,7 @@ async def test_disable_service_field_headers_async():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"name=name/value",
"name=name_value",
) in kw["metadata"]


Expand Down Expand Up @@ -1038,7 +1038,7 @@ def test_get_service_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.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:
Expand All @@ -1054,7 +1054,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"]


Expand All @@ -1068,7 +1068,7 @@ async def test_get_service_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.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:
Expand All @@ -1084,7 +1084,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"]


Expand Down Expand Up @@ -1186,7 +1186,7 @@ def test_list_services_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.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:
Expand All @@ -1202,7 +1202,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"]


Expand All @@ -1216,7 +1216,7 @@ async def test_list_services_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.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:
Expand All @@ -1234,7 +1234,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"]


Expand Down Expand Up @@ -1283,7 +1283,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, resources.Service) for i in results)

Expand Down Expand Up @@ -1525,7 +1525,7 @@ def test_batch_enable_services_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.BatchEnableServicesRequest()

request.parent = "parent/value"
request.parent = "parent_value"

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand All @@ -1543,7 +1543,7 @@ def test_batch_enable_services_field_headers():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"parent=parent/value",
"parent=parent_value",
) in kw["metadata"]


Expand All @@ -1557,7 +1557,7 @@ async def test_batch_enable_services_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.BatchEnableServicesRequest()

request.parent = "parent/value"
request.parent = "parent_value"

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand All @@ -1577,7 +1577,7 @@ async def test_batch_enable_services_field_headers_async():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"parent=parent/value",
"parent=parent_value",
) in kw["metadata"]


Expand Down Expand Up @@ -1679,7 +1679,7 @@ def test_batch_get_services_field_headers():
# a field header. Set these to a non-empty value.
request = serviceusage.BatchGetServicesRequest()

request.parent = "parent/value"
request.parent = "parent_value"

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand All @@ -1697,7 +1697,7 @@ def test_batch_get_services_field_headers():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"parent=parent/value",
"parent=parent_value",
) in kw["metadata"]


Expand All @@ -1711,7 +1711,7 @@ async def test_batch_get_services_field_headers_async():
# a field header. Set these to a non-empty value.
request = serviceusage.BatchGetServicesRequest()

request.parent = "parent/value"
request.parent = "parent_value"

# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
Expand All @@ -1731,7 +1731,7 @@ async def test_batch_get_services_field_headers_async():
_, _, kw = call.mock_calls[0]
assert (
"x-goog-request-params",
"parent=parent/value",
"parent=parent_value",
) in kw["metadata"]


Expand Down