Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix typing issue with gRPC metadata when key ends in -bin #2251

Merged
merged 7 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion gapic/samplegen/samplegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ def _fill_sample_metadata(sample: dict, api_schema: api.API):
parameters.append(snippet_metadata_pb2.ClientMethod.Parameter( # type: ignore
name="timeout", type="float"))
parameters.append(snippet_metadata_pb2.ClientMethod.Parameter( # type: ignore
name="metadata", type="Sequence[Tuple[str, str]"))
name="metadata", type="Sequence[Tuple[str, Union[str, bytes]]]"))

return snippet_metadata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,10 @@ class _{{ name }}(_Base{{ service.name }}RestTransport._Base{{name}}, {{ async_m

{% macro client_method_metadata_argument() %}metadata: {{ client_method_metadata_type() }}{% endmacro %}

{% macro client_method_metadata_type() %}Sequence[Tuple[str, str]]{% endmacro %}
{% macro client_method_metadata_type() %}Sequence[Tuple[str, Union[str, bytes]]]{% endmacro %}

{% macro client_method_metadata_default_value() %}(){% endmacro %}

{% macro client_method_metadata_argument_doc() %}metadata ({{ client_method_metadata_type() }}): Strings which should be
sent along with the request as metadata.{% endmacro %}
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.{% endmacro %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.{% endmacro %}
Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type `string`, but for metadata keys ending with the
suffix `-bin`, the corresponding values must be of type `bytes`.{% endmacro %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -65,8 +65,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.ListAssetsRequest(request)
Expand Down Expand Up @@ -118,7 +119,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -131,8 +132,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.ListAssetsRequest(request)
Expand Down Expand Up @@ -187,7 +189,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -200,8 +202,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.SearchAllResourcesRequest(request)
Expand Down Expand Up @@ -253,7 +256,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -266,8 +269,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.SearchAllResourcesRequest(request)
Expand Down Expand Up @@ -322,7 +326,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -335,8 +339,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.SearchAllIamPoliciesRequest(request)
Expand Down Expand Up @@ -388,7 +393,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -401,8 +406,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.SearchAllIamPoliciesRequest(request)
Expand Down Expand Up @@ -457,7 +463,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -470,8 +476,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.ListSavedQueriesRequest(request)
Expand Down Expand Up @@ -523,7 +530,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -536,8 +543,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.ListSavedQueriesRequest(request)
Expand Down Expand Up @@ -592,7 +600,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -605,8 +613,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPoliciesRequest(request)
Expand Down Expand Up @@ -658,7 +667,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -671,8 +680,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPoliciesRequest(request)
Expand Down Expand Up @@ -727,7 +737,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -740,8 +750,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPolicyGovernedContainersRequest(request)
Expand Down Expand Up @@ -793,7 +804,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -806,8 +817,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPolicyGovernedContainersRequest(request)
Expand Down Expand Up @@ -862,7 +874,7 @@ def __init__(self,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiate the pager.

Args:
Expand All @@ -875,8 +887,9 @@ def __init__(self,
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPolicyGovernedAssetsRequest(request)
Expand Down Expand Up @@ -928,7 +941,7 @@ def __init__(self,
*,
retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = ()):
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()):
"""Instantiates the pager.

Args:
Expand All @@ -941,8 +954,9 @@ def __init__(self,
retry (google.api_core.retry.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Strings which should be
sent along with the request as metadata. If the metadata key has
suffix `-bin`, the value must be bytes.
"""
self._method = method
self._request = asset_service.AnalyzeOrgPolicyGovernedAssetsRequest(request)
Expand Down
Loading