diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/base.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/base.py.j2 index 0570b93093..728961464d 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/base.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/base.py.j2 @@ -6,6 +6,9 @@ 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 @@ -33,6 +36,12 @@ 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() diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 index afb296aeaf..2961172ace 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/transports/rest.py.j2 @@ -208,8 +208,11 @@ class {{ service.name }}RestTransport({{ service.name }}Transport): url += '?{}'.format('&'.join(query_params)).replace(' ', '+') # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' response = self._session.{{ method.http_opt['verb'] }}( url, + headers=headers, {% if 'body' in method.http_opt %} data=body, {% endif %} diff --git a/gapic/templates/setup.py.j2 b/gapic/templates/setup.py.j2 index 07d9535c6a..2dc389be2c 100644 --- a/gapic/templates/setup.py.j2 +++ b/gapic/templates/setup.py.j2 @@ -27,7 +27,7 @@ setuptools.setup( platforms='Posix; MacOS X; Windows', include_package_data=True, install_requires=( - 'google-api-core[grpc] >= 1.26.0, < 2.0.0dev', + 'google-api-core[grpc] >= 1.27.0, < 2.0.0dev', 'libcst >= 0.2.5', 'proto-plus >= 1.15.0', 'packaging >= 14.3',