Skip to content

Commit

Permalink
fix: add a separate DEFAULT_CLIENT_INFO for rest clients (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslynnwu authored Sep 10, 2021
1 parent 630bff1 commit 22ac400
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources
{% if 'rest' in opts.transport %}
from requests import __version__ as requests_version
{% endif %}

import google.auth # type: ignore
import google.api_core # type: ignore
Expand Down Expand Up @@ -37,12 +34,6 @@ try:
gapic_version=pkg_resources.get_distribution(
'{{ api.naming.warehouse_package_name }}',
).version,
{% if 'grpc' not in opts.transport %}
grpc_version=None,
{% endif %}
{% if 'rest' in opts.transport %}
rest_version=requests_version,
{% endif %}
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import warnings
from typing import Callable, Dict, Optional, Sequence, Tuple
from requests import __version__ as requests_version

{% if service.has_lro %}
from google.api_core import operations_v1
Expand All @@ -30,9 +31,15 @@ from google.iam.v1 import policy_pb2 # type: ignore
{% endif %}
{% endfilter %}

from .base import {{ service.name }}Transport, DEFAULT_CLIENT_INFO
from .base import {{ service.name }}Transport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO


DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
grpc_version=None,
rest_version=requests_version,
)

class {{ service.name }}RestTransport({{ service.name }}Transport):
"""REST backend transport for {{ service.name }}.

Expand Down

0 comments on commit 22ac400

Please sign in to comment.