Skip to content

Commit

Permalink
fix: use async snippet in async client method docstring (#1280)
Browse files Browse the repository at this point in the history
* fix: use async snippet in async client method docstring

* update integration test golden files

* fix golden_update_script
  • Loading branch information
dizcology committed Apr 19, 2022
1 parent 2653d74 commit b72e1e0
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class {{ service.async_client_name }}:
{% endif %}
r"""{{ method.meta.doc|rst(width=72, indent=8)|trim }}

{% with snippet = snippet_index.get_snippet(service.name, method.name, sync=True) %}
{% with snippet = snippet_index.get_snippet(service.name, method.name, sync=False) %}
{% if snippet is not none %}
.. code-block:: python

Expand Down
4 changes: 2 additions & 2 deletions rules_python_gapic/test/integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def _overwrite_golden_impl(ctx):
golden_update_script_content = """
cd ${{BUILD_WORKSPACE_DIRECTORY}}
# Filename pattern-based removal is needed to preserve the BUILD.bazel file.
find tests/Integration/goldens/{api_name}/ -name \\*.py-type f -delete
find tests/Integration/goldens/{api_name}/ -name \\*.json -type f -delete
find tests/integration/goldens/{api_name}/ -name \\*.py-type f -delete
find tests/integration/goldens/{api_name}/ -name \\*.json -type f -delete
unzip -ao {goldens_output_zip} -d tests/integration/goldens/{api_name}
""".format(
goldens_output_zip = goldens_output_zip.path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ async def export_assets(self,
from google.cloud import asset_v1
def sample_export_assets():
async def sample_export_assets():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
output_config = asset_v1.OutputConfig()
Expand All @@ -232,7 +232,7 @@ def sample_export_assets():
print("Waiting for operation to complete...")
response = operation.result()
response = await operation.result()
# Handle the response
print(response)
Expand Down Expand Up @@ -310,9 +310,9 @@ async def list_assets(self,
from google.cloud import asset_v1
def sample_list_assets():
async def sample_list_assets():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.ListAssetsRequest(
Expand All @@ -323,7 +323,7 @@ def sample_list_assets():
page_result = client.list_assets(request=request)
# Handle the response
for response in page_result:
async for response in page_result:
print(response)
Args:
Expand Down Expand Up @@ -423,17 +423,17 @@ async def batch_get_assets_history(self,
from google.cloud import asset_v1
def sample_batch_get_assets_history():
async def sample_batch_get_assets_history():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.BatchGetAssetsHistoryRequest(
parent="parent_value",
)
# Make the request
response = client.batch_get_assets_history(request=request)
response = await client.batch_get_assets_history(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -504,9 +504,9 @@ async def create_feed(self,
from google.cloud import asset_v1
def sample_create_feed():
async def sample_create_feed():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
feed = asset_v1.Feed()
Expand All @@ -519,7 +519,7 @@ def sample_create_feed():
)
# Make the request
response = client.create_feed(request=request)
response = await client.create_feed(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -614,17 +614,17 @@ async def get_feed(self,
from google.cloud import asset_v1
def sample_get_feed():
async def sample_get_feed():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.GetFeedRequest(
name="name_value",
)
# Make the request
response = client.get_feed(request=request)
response = await client.get_feed(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -722,17 +722,17 @@ async def list_feeds(self,
from google.cloud import asset_v1
def sample_list_feeds():
async def sample_list_feeds():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.ListFeedsRequest(
parent="parent_value",
)
# Make the request
response = client.list_feeds(request=request)
response = await client.list_feeds(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -824,9 +824,9 @@ async def update_feed(self,
from google.cloud import asset_v1
def sample_update_feed():
async def sample_update_feed():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
feed = asset_v1.Feed()
Expand All @@ -837,7 +837,7 @@ def sample_update_feed():
)
# Make the request
response = client.update_feed(request=request)
response = await client.update_feed(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -928,17 +928,17 @@ async def delete_feed(self,
from google.cloud import asset_v1
def sample_delete_feed():
async def sample_delete_feed():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.DeleteFeedRequest(
name="name_value",
)
# Make the request
client.delete_feed(request=request)
await client.delete_feed(request=request)
Args:
request (Union[google.cloud.asset_v1.types.DeleteFeedRequest, dict]):
Expand Down Expand Up @@ -1023,9 +1023,9 @@ async def search_all_resources(self,
from google.cloud import asset_v1
def sample_search_all_resources():
async def sample_search_all_resources():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.SearchAllResourcesRequest(
Expand All @@ -1036,7 +1036,7 @@ def sample_search_all_resources():
page_result = client.search_all_resources(request=request)
# Handle the response
for response in page_result:
async for response in page_result:
print(response)
Args:
Expand Down Expand Up @@ -1229,9 +1229,9 @@ async def search_all_iam_policies(self,
from google.cloud import asset_v1
def sample_search_all_iam_policies():
async def sample_search_all_iam_policies():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
request = asset_v1.SearchAllIamPoliciesRequest(
Expand All @@ -1242,7 +1242,7 @@ def sample_search_all_iam_policies():
page_result = client.search_all_iam_policies(request=request)
# Handle the response
for response in page_result:
async for response in page_result:
print(response)
Args:
Expand Down Expand Up @@ -1411,9 +1411,9 @@ async def analyze_iam_policy(self,
from google.cloud import asset_v1
def sample_analyze_iam_policy():
async def sample_analyze_iam_policy():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
analysis_query = asset_v1.IamPolicyAnalysisQuery()
Expand All @@ -1424,7 +1424,7 @@ def sample_analyze_iam_policy():
)
# Make the request
response = client.analyze_iam_policy(request=request)
response = await client.analyze_iam_policy(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -1505,9 +1505,9 @@ async def analyze_iam_policy_longrunning(self,
from google.cloud import asset_v1
def sample_analyze_iam_policy_longrunning():
async def sample_analyze_iam_policy_longrunning():
# Create a client
client = asset_v1.AssetServiceClient()
client = asset_v1.AssetServiceAsyncClient()
# Initialize request argument(s)
analysis_query = asset_v1.IamPolicyAnalysisQuery()
Expand All @@ -1526,7 +1526,7 @@ def sample_analyze_iam_policy_longrunning():
print("Waiting for operation to complete...")
response = operation.result()
response = await operation.result()
# Handle the response
print(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ async def generate_access_token(self,
from google.iam import credentials_v1
def sample_generate_access_token():
async def sample_generate_access_token():
# Create a client
client = credentials_v1.IAMCredentialsClient()
client = credentials_v1.IAMCredentialsAsyncClient()
# Initialize request argument(s)
request = credentials_v1.GenerateAccessTokenRequest(
Expand All @@ -223,7 +223,7 @@ def sample_generate_access_token():
)
# Make the request
response = client.generate_access_token(request=request)
response = await client.generate_access_token(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -365,9 +365,9 @@ async def generate_id_token(self,
from google.iam import credentials_v1
def sample_generate_id_token():
async def sample_generate_id_token():
# Create a client
client = credentials_v1.IAMCredentialsClient()
client = credentials_v1.IAMCredentialsAsyncClient()
# Initialize request argument(s)
request = credentials_v1.GenerateIdTokenRequest(
Expand All @@ -376,7 +376,7 @@ def sample_generate_id_token():
)
# Make the request
response = client.generate_id_token(request=request)
response = await client.generate_id_token(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -511,9 +511,9 @@ async def sign_blob(self,
from google.iam import credentials_v1
def sample_sign_blob():
async def sample_sign_blob():
# Create a client
client = credentials_v1.IAMCredentialsClient()
client = credentials_v1.IAMCredentialsAsyncClient()
# Initialize request argument(s)
request = credentials_v1.SignBlobRequest(
Expand All @@ -522,7 +522,7 @@ def sample_sign_blob():
)
# Make the request
response = client.sign_blob(request=request)
response = await client.sign_blob(request=request)
# Handle the response
print(response)
Expand Down Expand Up @@ -644,9 +644,9 @@ async def sign_jwt(self,
from google.iam import credentials_v1
def sample_sign_jwt():
async def sample_sign_jwt():
# Create a client
client = credentials_v1.IAMCredentialsClient()
client = credentials_v1.IAMCredentialsAsyncClient()
# Initialize request argument(s)
request = credentials_v1.SignJwtRequest(
Expand All @@ -655,7 +655,7 @@ def sample_sign_jwt():
)
# Make the request
response = client.sign_jwt(request=request)
response = await client.sign_jwt(request=request)
# Handle the response
print(response)
Expand Down

0 comments on commit b72e1e0

Please sign in to comment.