Skip to content

Commit 32f49fb

Browse files
authored
chore: clean up fixup scripts (#963)
Incorporate changes from googleapis/python-dialogflow#351 in templated fixup script files
1 parent 240fb4e commit 32f49fb

File tree

6 files changed

+67
-67
lines changed

6 files changed

+67
-67
lines changed

packages/gapic-generator/gapic/ads-templates/scripts/fixup_%name_%version_keywords.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class {{ api.naming.module_name }}CallTransformer(cst.CSTTransformer):
3232
{% endfor %}{% endfor %}
3333
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
3434
{% for method in all_methods|sort(attribute='name')|unique(attribute='name') %}
35-
'{{ method.name|snake_case }}': ({% for field in method.legacy_flattened_fields.values() %}'{{ field.name }}', {% endfor %}),
35+
'{{ method.name|snake_case }}': ({% for field in method.legacy_flattened_fields.values() %}'{{ field.name }}', {% endfor %}),
3636
{% endfor %}
3737
}
3838
{% endwith %}
@@ -54,7 +54,7 @@ class {{ api.naming.module_name }}CallTransformer(cst.CSTTransformer):
5454
return updated
5555

5656
kwargs, ctrl_kwargs = partition(
57-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
57+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
5858
kwargs
5959
)
6060

packages/gapic-generator/gapic/templates/scripts/fixup_%name_%version_keywords.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class {{ api.naming.module_name }}CallTransformer(cst.CSTTransformer):
3232
{% endfor %}{% endfor %}
3333
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
3434
{% for method in all_methods|sort(attribute='name')|unique(attribute='name') %}
35-
'{{ method.name|snake_case }}': ({% for field in method.legacy_flattened_fields.values() %}'{{ field.name }}', {% endfor %}),
35+
'{{ method.name|snake_case }}': ({% for field in method.legacy_flattened_fields.values() %}'{{ field.name }}', {% endfor %}),
3636
{% endfor %}
3737
{% if opts.add_iam_methods %}
3838
'get_iam_policy': ('resource', 'options', ),
@@ -59,7 +59,7 @@ class {{ api.naming.module_name }}CallTransformer(cst.CSTTransformer):
5959
return updated
6060

6161
kwargs, ctrl_kwargs = partition(
62-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
62+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
6363
kwargs
6464
)
6565

packages/gapic-generator/tests/integration/goldens/asset/scripts/fixup_asset_v1_keywords.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ def partition(
3939
class assetCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'analyze_iam_policy': ('analysis_query', 'execution_timeout', ),
43-
'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ),
44-
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', ),
45-
'create_feed': ('parent', 'feed_id', 'feed', ),
46-
'delete_feed': ('name', ),
47-
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', ),
48-
'get_feed': ('name', ),
49-
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', ),
50-
'list_feeds': ('parent', ),
51-
'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ),
52-
'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', ),
53-
'update_feed': ('feed', 'update_mask', ),
42+
'analyze_iam_policy': ('analysis_query', 'execution_timeout', ),
43+
'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ),
44+
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', ),
45+
'create_feed': ('parent', 'feed_id', 'feed', ),
46+
'delete_feed': ('name', ),
47+
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', ),
48+
'get_feed': ('name', ),
49+
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', ),
50+
'list_feeds': ('parent', ),
51+
'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ),
52+
'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', ),
53+
'update_feed': ('feed', 'update_mask', ),
5454
}
5555

5656
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
@@ -69,7 +69,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
6969
return updated
7070

7171
kwargs, ctrl_kwargs = partition(
72-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
72+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
7373
kwargs
7474
)
7575

packages/gapic-generator/tests/integration/goldens/credentials/scripts/fixup_credentials_v1_keywords.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def partition(
3939
class credentialsCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'generate_access_token': ('name', 'scope', 'delegates', 'lifetime', ),
43-
'generate_id_token': ('name', 'audience', 'delegates', 'include_email', ),
44-
'sign_blob': ('name', 'payload', 'delegates', ),
45-
'sign_jwt': ('name', 'payload', 'delegates', ),
42+
'generate_access_token': ('name', 'scope', 'delegates', 'lifetime', ),
43+
'generate_id_token': ('name', 'audience', 'delegates', 'include_email', ),
44+
'sign_blob': ('name', 'payload', 'delegates', ),
45+
'sign_jwt': ('name', 'payload', 'delegates', ),
4646
}
4747

4848
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
@@ -61,7 +61,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
6161
return updated
6262

6363
kwargs, ctrl_kwargs = partition(
64-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
64+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
6565
kwargs
6666
)
6767

packages/gapic-generator/tests/integration/goldens/logging/scripts/fixup_logging_v2_keywords.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,40 @@ def partition(
3939
class loggingCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'create_bucket': ('parent', 'bucket_id', 'bucket', ),
43-
'create_exclusion': ('parent', 'exclusion', ),
44-
'create_log_metric': ('parent', 'metric', ),
45-
'create_sink': ('parent', 'sink', 'unique_writer_identity', ),
46-
'create_view': ('parent', 'view_id', 'view', ),
47-
'delete_bucket': ('name', ),
48-
'delete_exclusion': ('name', ),
49-
'delete_log': ('log_name', ),
50-
'delete_log_metric': ('metric_name', ),
51-
'delete_sink': ('sink_name', ),
52-
'delete_view': ('name', ),
53-
'get_bucket': ('name', ),
54-
'get_cmek_settings': ('name', ),
55-
'get_exclusion': ('name', ),
56-
'get_log_metric': ('metric_name', ),
57-
'get_sink': ('sink_name', ),
58-
'get_view': ('name', ),
59-
'list_buckets': ('parent', 'page_token', 'page_size', ),
60-
'list_exclusions': ('parent', 'page_token', 'page_size', ),
61-
'list_log_entries': ('resource_names', 'filter', 'order_by', 'page_size', 'page_token', ),
62-
'list_log_metrics': ('parent', 'page_token', 'page_size', ),
63-
'list_logs': ('parent', 'page_size', 'page_token', 'resource_names', ),
64-
'list_monitored_resource_descriptors': ('page_size', 'page_token', ),
65-
'list_sinks': ('parent', 'page_token', 'page_size', ),
66-
'list_views': ('parent', 'page_token', 'page_size', ),
67-
'tail_log_entries': ('resource_names', 'filter', 'buffer_window', ),
68-
'undelete_bucket': ('name', ),
69-
'update_bucket': ('name', 'bucket', 'update_mask', ),
70-
'update_cmek_settings': ('name', 'cmek_settings', 'update_mask', ),
71-
'update_exclusion': ('name', 'exclusion', 'update_mask', ),
72-
'update_log_metric': ('metric_name', 'metric', ),
73-
'update_sink': ('sink_name', 'sink', 'unique_writer_identity', 'update_mask', ),
74-
'update_view': ('name', 'view', 'update_mask', ),
75-
'write_log_entries': ('entries', 'log_name', 'resource', 'labels', 'partial_success', 'dry_run', ),
42+
'create_bucket': ('parent', 'bucket_id', 'bucket', ),
43+
'create_exclusion': ('parent', 'exclusion', ),
44+
'create_log_metric': ('parent', 'metric', ),
45+
'create_sink': ('parent', 'sink', 'unique_writer_identity', ),
46+
'create_view': ('parent', 'view_id', 'view', ),
47+
'delete_bucket': ('name', ),
48+
'delete_exclusion': ('name', ),
49+
'delete_log': ('log_name', ),
50+
'delete_log_metric': ('metric_name', ),
51+
'delete_sink': ('sink_name', ),
52+
'delete_view': ('name', ),
53+
'get_bucket': ('name', ),
54+
'get_cmek_settings': ('name', ),
55+
'get_exclusion': ('name', ),
56+
'get_log_metric': ('metric_name', ),
57+
'get_sink': ('sink_name', ),
58+
'get_view': ('name', ),
59+
'list_buckets': ('parent', 'page_token', 'page_size', ),
60+
'list_exclusions': ('parent', 'page_token', 'page_size', ),
61+
'list_log_entries': ('resource_names', 'filter', 'order_by', 'page_size', 'page_token', ),
62+
'list_log_metrics': ('parent', 'page_token', 'page_size', ),
63+
'list_logs': ('parent', 'page_size', 'page_token', 'resource_names', ),
64+
'list_monitored_resource_descriptors': ('page_size', 'page_token', ),
65+
'list_sinks': ('parent', 'page_token', 'page_size', ),
66+
'list_views': ('parent', 'page_token', 'page_size', ),
67+
'tail_log_entries': ('resource_names', 'filter', 'buffer_window', ),
68+
'undelete_bucket': ('name', ),
69+
'update_bucket': ('name', 'bucket', 'update_mask', ),
70+
'update_cmek_settings': ('name', 'cmek_settings', 'update_mask', ),
71+
'update_exclusion': ('name', 'exclusion', 'update_mask', ),
72+
'update_log_metric': ('metric_name', 'metric', ),
73+
'update_sink': ('sink_name', 'sink', 'unique_writer_identity', 'update_mask', ),
74+
'update_view': ('name', 'view', 'update_mask', ),
75+
'write_log_entries': ('entries', 'log_name', 'resource', 'labels', 'partial_success', 'dry_run', ),
7676
}
7777

7878
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
@@ -91,7 +91,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
9191
return updated
9292

9393
kwargs, ctrl_kwargs = partition(
94-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
94+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
9595
kwargs
9696
)
9797

packages/gapic-generator/tests/integration/goldens/redis/scripts/fixup_redis_v1_keywords.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ def partition(
3939
class redisCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'create_instance': ('parent', 'instance_id', 'instance', ),
43-
'delete_instance': ('name', ),
44-
'export_instance': ('name', 'output_config', ),
45-
'failover_instance': ('name', 'data_protection_mode', ),
46-
'get_instance': ('name', ),
47-
'import_instance': ('name', 'input_config', ),
48-
'list_instances': ('parent', 'page_size', 'page_token', ),
49-
'update_instance': ('update_mask', 'instance', ),
50-
'upgrade_instance': ('name', 'redis_version', ),
42+
'create_instance': ('parent', 'instance_id', 'instance', ),
43+
'delete_instance': ('name', ),
44+
'export_instance': ('name', 'output_config', ),
45+
'failover_instance': ('name', 'data_protection_mode', ),
46+
'get_instance': ('name', ),
47+
'import_instance': ('name', 'input_config', ),
48+
'list_instances': ('parent', 'page_size', 'page_token', ),
49+
'update_instance': ('update_mask', 'instance', ),
50+
'upgrade_instance': ('name', 'redis_version', ),
5151
}
5252

5353
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
@@ -66,7 +66,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
6666
return updated
6767

6868
kwargs, ctrl_kwargs = partition(
69-
lambda a: not a.keyword.value in self.CTRL_PARAMS,
69+
lambda a: a.keyword.value not in self.CTRL_PARAMS,
7070
kwargs
7171
)
7272

0 commit comments

Comments
 (0)