aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-08-20 15:45:37 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-08-20 15:45:37 -0700
commite0b8f9b5f376af72b638905e03b3ac69b7db4107 (patch)
treebb50b2476df0d3f3cf36c9cbdd2b1983d793f4d9
parentf214c6c61a4ce9f15eac6a5a8d41b25a4084a46d (diff)
parent9116956505e39e92f60c2937069f74bae2213157 (diff)
downloadgoogle-api-python-client-e0b8f9b5f376af72b638905e03b3ac69b7db4107.tar.gz
Upgrade python/google-api-python-client to v1.7.11 am: ae3aef9b32 am: 5ce1951571 am: 9950092412 am: 73d326679b
am: 9116956505 Change-Id: I4cf9cb5e1b81182aa8742550fef1f5fc91bfdec6
-rw-r--r--CHANGELOG12
-rw-r--r--METADATA6
-rw-r--r--docs/oauth.md4
-rw-r--r--googleapiclient/__init__.py2
-rw-r--r--googleapiclient/model.py9
-rw-r--r--tests/test_http.py18
-rw-r--r--tests/test_json_model.py19
7 files changed, 50 insertions, 20 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 35944a910..a57d60c4c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,15 @@
+v1.7.11
+ Version 1.7.11
+
+ Bugfix release
+
+ Implementation Changes
+ - Pass library and Python version in x-goog-api-client header ([#734](https://github.com/googleapis/google-api-python-client/pull/734))
+
+ Documentation
+ - Fix typo in filename used in 'docs/auth.md' ([#736](https://github.com/googleapis/google-api-python-client/pull/736))
+
+
v1.7.10
Version 1.7.10
diff --git a/METADATA b/METADATA
index 236facd8b..8762d8db0 100644
--- a/METADATA
+++ b/METADATA
@@ -9,10 +9,10 @@ third_party {
type: GIT
value: "https://github.com/google/google-api-python-client"
}
- version: "v1.7.10"
+ version: "v1.7.11"
last_upgrade_date {
year: 2019
- month: 7
- day: 24
+ month: 8
+ day: 19
}
}
diff --git a/docs/oauth.md b/docs/oauth.md
index 947c4ac9d..71874c968 100644
--- a/docs/oauth.md
+++ b/docs/oauth.md
@@ -33,7 +33,7 @@ The purpose of a `Flow` class is to acquire credentials that authorize your appl
### flow_from_clientsecrets()
-The [oauth2client.client.flow_from_clientsecrets()](http://oauth2client.readthedocs.org/en/latest/source/oauth2client.client.html#oauth2client.client.flow_from_clientsecrets) method creates a `Flow` object from a [client_secrets.json](client_secrets.md) file. This [JSON](http://www.json.org/) formatted file stores your client ID, client secret, and other OAuth 2.0 parameters.
+The [oauth2client.client.flow_from_clientsecrets()](http://oauth2client.readthedocs.org/en/latest/source/oauth2client.client.html#oauth2client.client.flow_from_clientsecrets) method creates a `Flow` object from a [client_secrets.json](client-secrets.md) file. This [JSON](http://www.json.org/) formatted file stores your client ID, client secret, and other OAuth 2.0 parameters.
The following shows how you can use `flow_from_clientsecrets()` to create a `Flow` object:
@@ -177,4 +177,4 @@ parser = argparse.ArgumentParser(parents=[tools.argparser])
flags = parser.parse_args()
...
credentials = tools.run_flow(flow, storage, flags)
-``` \ No newline at end of file
+```
diff --git a/googleapiclient/__init__.py b/googleapiclient/__init__.py
index 4cc3a6a5b..feba5ce0a 100644
--- a/googleapiclient/__init__.py
+++ b/googleapiclient/__init__.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "1.7.10"
+__version__ = "1.7.11"
# Set default logging handler to avoid "No handler found" warnings.
import logging
diff --git a/googleapiclient/model.py b/googleapiclient/model.py
index dded04ea3..7ab80e97c 100644
--- a/googleapiclient/model.py
+++ b/googleapiclient/model.py
@@ -26,12 +26,14 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
import json
import logging
+import platform
from six.moves.urllib.parse import urlencode
from googleapiclient import __version__
from googleapiclient.errors import HttpError
+_PY_VERSION = platform.python_version()
LOGGER = logging.getLogger(__name__)
@@ -144,7 +146,12 @@ class BaseModel(Model):
headers['user-agent'] += ' '
else:
headers['user-agent'] = ''
- headers['user-agent'] += 'google-api-python-client/%s (gzip)' % __version__
+ headers['user-agent'] += '(gzip)'
+ if 'x-goog-api-client' in headers:
+ headers['x-goog-api-client'] += ' '
+ else:
+ headers['x-goog-api-client'] = ''
+ headers['x-goog-api-client'] += 'gdcl/%s gl-python/%s' % (__version__, _PY_VERSION)
if body_value is not None:
headers['content-type'] = self.content_type
diff --git a/tests/test_http.py b/tests/test_http.py
index 5aaada68a..b92e63fcd 100644
--- a/tests/test_http.py
+++ b/tests/test_http.py
@@ -485,26 +485,22 @@ class TestMediaIoBaseDownload(unittest.TestCase):
download = MediaIoBaseDownload(
fd=self.fd, request=self.request, chunksize=3)
- self.assertEqual(download._headers, {'Cache-Control':'no-store'})
+ self.assertEqual(download._headers.get('Cache-Control'), 'no-store')
status, done = download.next_chunk()
- result = self.fd.getvalue().decode('utf-8')
+ result = json.loads(self.fd.getvalue().decode('utf-8'))
- # we abuse the internals of the object we're testing, pay no attention
- # to the actual bytes= values here; we are just asserting that the
- # header we added to the original request is sent up to the server
- # on each call to next_chunk
+ # assert that that the header we added to the original request is
+ # sent up to the server on each call to next_chunk
- self.assertEqual(json.loads(result),
- {"Cache-Control": "no-store", "range": "bytes=0-3"})
+ self.assertEqual(result.get("Cache-Control"), "no-store")
download._fd = self.fd = BytesIO()
status, done = download.next_chunk()
- result = self.fd.getvalue().decode('utf-8')
- self.assertEqual(json.loads(result),
- {"Cache-Control": "no-store", "range": "bytes=51-54"})
+ result = json.loads(self.fd.getvalue().decode('utf-8'))
+ self.assertEqual(result.get("Cache-Control"), "no-store")
def test_media_io_base_download_handle_redirects(self):
self.request.http = HttpMockSequence([
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index 0d1f283f8..006eb47dc 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -26,6 +26,7 @@ __author__ = 'jcgregorio@google.com (Joe Gregorio)'
import copy
import json
import os
+import platform
import unittest2 as unittest
import httplib2
import googleapiclient.model
@@ -143,8 +144,22 @@ class Model(unittest.TestCase):
headers, path_params, query_params, body)
self.assertEqual(headers['user-agent'],
- 'my-test-app/1.23.4 google-api-python-client/' + __version__ +
- ' (gzip)')
+ 'my-test-app/1.23.4 (gzip)')
+
+ def test_x_goog_api_client(self):
+ model = JsonModel(data_wrapper=False)
+
+ # test header composition for cloud clients that wrap discovery
+ headers = {'x-goog-api-client': 'gccl/1.23.4'}
+ path_params = {}
+ query_params = {}
+ body = {}
+
+ headers, unused_params, unused_query, body = model.request(
+ headers, path_params, query_params, body)
+
+ self.assertEqual(headers['x-goog-api-client'],
+ 'gccl/1.23.4' + ' gdcl/' + __version__ + ' gl-python/' + platform.python_version())
def test_bad_response(self):
model = JsonModel(data_wrapper=False)