Skip to content

Commit 7a7ca23

Browse files
authored
chore: add comment for handling the response in generated snippets (googleapis#1193)
1 parent 15c95d5 commit 7a7ca23

File tree

138 files changed

+570
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+570
-262
lines changed

gapic/samplegen_utils/snippet_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
CLIENT_INIT_RE = re.compile(r"^\s+# Create a client")
2626
REQUEST_INIT_RE = re.compile(r"^\s+# Initialize request argument\(s\)")
2727
REQUEST_EXEC_RE = re.compile(r"^\s+# Make the request")
28-
RESPONSE_HANDLING_RE = re.compile(r"^\s+# Handle response")
28+
RESPONSE_HANDLING_RE = re.compile(r"^\s+# Handle the response")
2929

3030

3131
class Snippet:

gapic/templates/examples/feature_fragments.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,19 +249,23 @@ client.{{ sample.rpc|snake_case }}({{ render_request_params_unary(sample.request
249249
response = {{ method_invocation_text|trim }}
250250

251251
{% if response_statements %}
252-
# Handle response
252+
# Handle the response
253253
{% for statement in response_statements %}
254254
{{ dispatch_statement(statement)|trim }}
255255
{% endfor %}
256256
{% endif %}
257257
{% elif calling_form == calling_form_enum.RequestPagedAll %}
258258
page_result = {{ method_invocation_text|trim }}
259+
260+
# Handle the response
259261
{% if transport == "grpc-async" %}async {% endif %}for response in page_result:
260262
{% for statement in response_statements %}
261263
{{ dispatch_statement(statement)|trim }}
262264
{% endfor %}
263265
{% elif calling_form == calling_form_enum.RequestPaged %}
264266
page_result = {{ method_invocation_text|trim }}
267+
268+
# Handle the response
265269
{% if transport == "grpc-async" %}async {% endif %}for page in page_result.pages():
266270
for response in page:
267271
{% for statement in response_statements %}
@@ -270,6 +274,8 @@ page_result = {{ method_invocation_text|trim }}
270274
{% elif calling_form in [calling_form_enum.RequestStreamingServer,
271275
calling_form_enum.RequestStreamingBidi] %}
272276
stream = {{ method_invocation_text|trim }}
277+
278+
# Handle the response
273279
{% if transport == "grpc-async" %}async {% endif %}for response in stream:
274280
{% for statement in response_statements %}
275281
{{ dispatch_statement(statement)|trim }}
@@ -280,6 +286,8 @@ operation = {{ method_invocation_text|trim }}
280286
print("Waiting for operation to complete...")
281287

282288
response = {% if transport == "grpc-async" %}await {% endif %}operation.result()
289+
290+
# Handle the response
283291
{% for statement in response_statements %}
284292
{{ dispatch_statement(statement)|trim }}
285293
{% endfor %}

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def sample_export_assets():
234234
print("Waiting for operation to complete...")
235235
236236
response = operation.result()
237+
238+
# Handle the response
237239
print(response)
238240
239241
Args:
@@ -321,6 +323,8 @@ def sample_list_assets():
321323
322324
# Make the request
323325
page_result = client.list_assets(request=request)
326+
327+
# Handle the response
324328
for response in page_result:
325329
print(response)
326330
@@ -434,7 +438,7 @@ def sample_batch_get_assets_history():
434438
# Make the request
435439
response = client.batch_get_assets_history(request=request)
436440
437-
# Handle response
441+
# Handle the response
438442
print(response)
439443
440444
Args:
@@ -521,7 +525,7 @@ def sample_create_feed():
521525
# Make the request
522526
response = client.create_feed(request=request)
523527
524-
# Handle response
528+
# Handle the response
525529
print(response)
526530
527531
Args:
@@ -626,7 +630,7 @@ def sample_get_feed():
626630
# Make the request
627631
response = client.get_feed(request=request)
628632
629-
# Handle response
633+
# Handle the response
630634
print(response)
631635
632636
Args:
@@ -735,7 +739,7 @@ def sample_list_feeds():
735739
# Make the request
736740
response = client.list_feeds(request=request)
737741
738-
# Handle response
742+
# Handle the response
739743
print(response)
740744
741745
Args:
@@ -840,7 +844,7 @@ def sample_update_feed():
840844
# Make the request
841845
response = client.update_feed(request=request)
842846
843-
# Handle response
847+
# Handle the response
844848
print(response)
845849
846850
Args:
@@ -1036,6 +1040,8 @@ def sample_search_all_resources():
10361040
10371041
# Make the request
10381042
page_result = client.search_all_resources(request=request)
1043+
1044+
# Handle the response
10391045
for response in page_result:
10401046
print(response)
10411047
@@ -1241,6 +1247,8 @@ def sample_search_all_iam_policies():
12411247
12421248
# Make the request
12431249
page_result = client.search_all_iam_policies(request=request)
1250+
1251+
# Handle the response
12441252
for response in page_result:
12451253
print(response)
12461254
@@ -1426,7 +1434,7 @@ def sample_analyze_iam_policy():
14261434
# Make the request
14271435
response = client.analyze_iam_policy(request=request)
14281436
1429-
# Handle response
1437+
# Handle the response
14301438
print(response)
14311439
14321440
Args:
@@ -1528,6 +1536,8 @@ def sample_analyze_iam_policy_longrunning():
15281536
print("Waiting for operation to complete...")
15291537
15301538
response = operation.result()
1539+
1540+
# Handle the response
15311541
print(response)
15321542
15331543
Args:

tests/integration/goldens/asset/google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def sample_export_assets():
431431
print("Waiting for operation to complete...")
432432
433433
response = operation.result()
434+
435+
# Handle the response
434436
print(response)
435437
436438
Args:
@@ -520,6 +522,8 @@ def sample_list_assets():
520522
521523
# Make the request
522524
page_result = client.list_assets(request=request)
525+
526+
# Handle the response
523527
for response in page_result:
524528
print(response)
525529
@@ -634,7 +638,7 @@ def sample_batch_get_assets_history():
634638
# Make the request
635639
response = client.batch_get_assets_history(request=request)
636640
637-
# Handle response
641+
# Handle the response
638642
print(response)
639643
640644
Args:
@@ -716,7 +720,7 @@ def sample_create_feed():
716720
# Make the request
717721
response = client.create_feed(request=request)
718722
719-
# Handle response
723+
# Handle the response
720724
print(response)
721725
722726
Args:
@@ -822,7 +826,7 @@ def sample_get_feed():
822826
# Make the request
823827
response = client.get_feed(request=request)
824828
825-
# Handle response
829+
# Handle the response
826830
print(response)
827831
828832
Args:
@@ -925,7 +929,7 @@ def sample_list_feeds():
925929
# Make the request
926930
response = client.list_feeds(request=request)
927931
928-
# Handle response
932+
# Handle the response
929933
print(response)
930934
931935
Args:
@@ -1024,7 +1028,7 @@ def sample_update_feed():
10241028
# Make the request
10251029
response = client.update_feed(request=request)
10261030
1027-
# Handle response
1031+
# Handle the response
10281032
print(response)
10291033
10301034
Args:
@@ -1215,6 +1219,8 @@ def sample_search_all_resources():
12151219
12161220
# Make the request
12171221
page_result = client.search_all_resources(request=request)
1222+
1223+
# Handle the response
12181224
for response in page_result:
12191225
print(response)
12201226
@@ -1414,6 +1420,8 @@ def sample_search_all_iam_policies():
14141420
14151421
# Make the request
14161422
page_result = client.search_all_iam_policies(request=request)
1423+
1424+
# Handle the response
14171425
for response in page_result:
14181426
print(response)
14191427
@@ -1593,7 +1601,7 @@ def sample_analyze_iam_policy():
15931601
# Make the request
15941602
response = client.analyze_iam_policy(request=request)
15951603
1596-
# Handle response
1604+
# Handle the response
15971605
print(response)
15981606
15991607
Args:
@@ -1691,6 +1699,8 @@ def sample_analyze_iam_policy_longrunning():
16911699
print("Waiting for operation to complete...")
16921700
16931701
response = operation.result()
1702+
1703+
# Handle the response
16941704
print(response)
16951705
16961706
Args:

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_analyze_iam_policy_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def sample_analyze_iam_policy():
4242
# Make the request
4343
response = await client.analyze_iam_policy(request=request)
4444

45-
# Handle response
45+
# Handle the response
4646
print(response)
4747

4848
# [END cloudasset_generated_asset_v1_AssetService_AnalyzeIamPolicy_async]

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_analyze_iam_policy_longrunning_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ async def sample_analyze_iam_policy_longrunning():
4949
print("Waiting for operation to complete...")
5050

5151
response = await operation.result()
52+
53+
# Handle the response
5254
print(response)
5355

5456
# [END cloudasset_generated_asset_v1_AssetService_AnalyzeIamPolicyLongrunning_async]

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_analyze_iam_policy_longrunning_sync.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def sample_analyze_iam_policy_longrunning():
4949
print("Waiting for operation to complete...")
5050

5151
response = operation.result()
52+
53+
# Handle the response
5254
print(response)
5355

5456
# [END cloudasset_generated_asset_v1_AssetService_AnalyzeIamPolicyLongrunning_sync]

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_analyze_iam_policy_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def sample_analyze_iam_policy():
4242
# Make the request
4343
response = client.analyze_iam_policy(request=request)
4444

45-
# Handle response
45+
# Handle the response
4646
print(response)
4747

4848
# [END cloudasset_generated_asset_v1_AssetService_AnalyzeIamPolicy_sync]

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_batch_get_assets_history_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def sample_batch_get_assets_history():
3939
# Make the request
4040
response = await client.batch_get_assets_history(request=request)
4141

42-
# Handle response
42+
# Handle the response
4343
print(response)
4444

4545
# [END cloudasset_generated_asset_v1_AssetService_BatchGetAssetsHistory_async]

tests/integration/goldens/asset/samples/generated_samples/cloudasset_generated_asset_v1_asset_service_batch_get_assets_history_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def sample_batch_get_assets_history():
3939
# Make the request
4040
response = client.batch_get_assets_history(request=request)
4141

42-
# Handle response
42+
# Handle the response
4343
print(response)
4444

4545
# [END cloudasset_generated_asset_v1_AssetService_BatchGetAssetsHistory_sync]

0 commit comments

Comments
 (0)