Skip to content

Commit 664e5cc

Browse files
authored
Merge branch 'master' into issue4340-readconsistency
2 parents 9605172 + 10ef028 commit 664e5cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4897
-234
lines changed

README.rst

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ Google Cloud Python Client
1515
.. _API Documentation: https://googlecloudplatform.github.io/google-cloud-python/latest/
1616
.. _Read The Docs Documentation: https://google-cloud-python.readthedocs.io/en/latest/
1717

18+
.. note::
19+
20+
These libraries currently do not run on Google App Engine Standard.
21+
We are actively working on adding this support.
22+
1823
The following client libraries have **GA** support:
1924

2025
- `Google Cloud Datastore`_ (`Datastore README`_)
26+
- `Google Cloud Natural Language`_ (`Natural Language README`_)
2127
- `Google Cloud Storage`_ (`Storage README`_)
2228
- `Google Cloud Translation`_ (`Translation README`_)
2329
- `Stackdriver Logging`_ (`Logging README`_)
@@ -29,11 +35,16 @@ of critical security issues) or with an extensive deprecation period.
2935
Issues and requests against GA libraries are addressed with the highest
3036
priority.
3137

38+
.. note::
39+
40+
Sub-components of GA libraries explicitly marked as beta in the
41+
import path (e.g. ``google.cloud.language_v1beta2``) should be considered
42+
to be beta.
43+
3244
The following client libraries have **beta** support:
3345

3446
- `Google BigQuery`_ (`BigQuery README`_)
3547
- `Google Cloud Firestore`_ (`Firestore README`_)
36-
- `Google Cloud Natural Language`_ (`Natural Language README`_)
3748
- `Google Cloud Pub/Sub`_ (`Pub/Sub README`_)
3849
- `Google Cloud Spanner`_ (`Spanner README`_)
3950
- `Google Cloud Speech`_ (`Speech README`_)

api_core/google/api_core/gapic_v1/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
from google.api_core.gapic_v1 import config
1616
from google.api_core.gapic_v1 import method
17+
from google.api_core.gapic_v1 import routing_header
1718

1819
__all__ = [
1920
'config',
2021
'method',
22+
'routing_header',
2123
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2017 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Helpers for constructing routing headers.
16+
17+
These headers are used by Google infrastructure to determine how to route
18+
requests, especially for services that are regional.
19+
20+
Generally, these headers are specified as gRPC metadata.
21+
"""
22+
23+
from six.moves.urllib.parse import urlencode
24+
25+
ROUTING_METADATA_KEY = 'x-goog-header-params'
26+
27+
28+
def to_routing_header(params):
29+
"""Returns a routing header string for the given request parameters.
30+
31+
Args:
32+
params (Mapping[str, Any]): A dictionary containing the request
33+
parameters used for routing.
34+
35+
Returns:
36+
str: The routing header string.
37+
"""
38+
return urlencode(params)
39+
40+
41+
def to_grpc_metadata(params):
42+
"""Returns the gRPC metadata containing the routing headers for the given
43+
request parameters.
44+
45+
Args:
46+
params (Mapping[str, Any]): A dictionary containing the request
47+
parameters used for routing.
48+
49+
Returns:
50+
Tuple(str, str): The gRPC metadata containing the routing header key
51+
and value.
52+
"""
53+
return (ROUTING_METADATA_KEY, to_routing_header(params))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2017 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
from google.api_core.gapic_v1 import routing_header
17+
18+
19+
def test_to_routing_header():
20+
params = [('name', 'meep'), ('book.read', '1')]
21+
value = routing_header.to_routing_header(params)
22+
assert value == "name=meep&book.read=1"
23+
24+
25+
def test_to_grpc_metadata():
26+
params = [('name', 'meep'), ('book.read', '1')]
27+
metadata = routing_header.to_grpc_metadata(params)
28+
assert metadata == (
29+
routing_header.ROUTING_METADATA_KEY, "name=meep&book.read=1")

bigquery/tests/unit/test_dataset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def _setUpConstants(self):
206206
self.DS_FULL_ID = '%s:%s' % (self.PROJECT, self.DS_ID)
207207
self.RESOURCE_URL = 'http://example.com/path/to/resource'
208208

209-
def _makeResource(self):
209+
def _make_resource(self):
210210
self._setUpConstants()
211211
USER_EMAIL = '[email protected]'
212212
GROUP_EMAIL = '[email protected]'
@@ -422,7 +422,7 @@ def test_from_api_repr_bare(self):
422422
self._verify_resource_properties(dataset, RESOURCE)
423423

424424
def test_from_api_repr_w_properties(self):
425-
RESOURCE = self._makeResource()
425+
RESOURCE = self._make_resource()
426426
klass = self._get_target_class()
427427
dataset = klass.from_api_repr(RESOURCE)
428428
self._verify_resource_properties(dataset, RESOURCE)

0 commit comments

Comments
 (0)