Skip to content

Commit

Permalink
Add 'client_options' support, update list method docstrings (via synt…
Browse files Browse the repository at this point in the history
…h). (#8501)
  • Loading branch information
yoshi-automation authored and tseaver committed Jun 28, 2019
1 parent ab09e4d commit d0e658a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
Expand Up @@ -20,6 +20,7 @@
import warnings

from google.oauth2 import service_account
import google.api_core.client_options
import google.api_core.gapic_v1.client_info
import google.api_core.gapic_v1.config
import google.api_core.gapic_v1.method
Expand Down Expand Up @@ -77,6 +78,7 @@ def __init__(
credentials=None,
client_config=None,
client_info=None,
client_options=None,
):
"""Constructor.
Expand Down Expand Up @@ -107,6 +109,9 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
Client options used to set user options on the client. API Endpoint
should be set through client_options.
"""
# Raise deprecation warnings for things we want to go away.
if client_config is not None:
Expand All @@ -125,6 +130,15 @@ def __init__(
stacklevel=2,
)

api_endpoint = self.SERVICE_ADDRESS
if client_options:
if type(client_options) == dict:
client_options = google.api_core.client_options.from_dict(
client_options
)
if client_options.api_endpoint:
api_endpoint = client_options.api_endpoint

# Instantiate the transport.
# The transport is responsible for handling serialization and
# deserialization and actually sending data to the service.
Expand All @@ -133,6 +147,7 @@ def __init__(
self.transport = transport(
credentials=credentials,
default_class=cluster_manager_grpc_transport.ClusterManagerGrpcTransport,
address=api_endpoint,
)
else:
if credentials:
Expand All @@ -143,7 +158,7 @@ def __init__(
self.transport = transport
else:
self.transport = cluster_manager_grpc_transport.ClusterManagerGrpcTransport(
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
address=api_endpoint, channel=channel, credentials=credentials
)

if client_info is None:
Expand Down
Expand Up @@ -21,6 +21,7 @@
import warnings

from google.oauth2 import service_account
import google.api_core.client_options
import google.api_core.gapic_v1.client_info
import google.api_core.gapic_v1.config
import google.api_core.gapic_v1.method
Expand Down Expand Up @@ -81,6 +82,7 @@ def __init__(
credentials=None,
client_config=None,
client_info=None,
client_options=None,
):
"""Constructor.
Expand Down Expand Up @@ -111,6 +113,9 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
Client options used to set user options on the client. API Endpoint
should be set through client_options.
"""
# Raise deprecation warnings for things we want to go away.
if client_config is not None:
Expand All @@ -129,6 +134,15 @@ def __init__(
stacklevel=2,
)

api_endpoint = self.SERVICE_ADDRESS
if client_options:
if type(client_options) == dict:
client_options = google.api_core.client_options.from_dict(
client_options
)
if client_options.api_endpoint:
api_endpoint = client_options.api_endpoint

# Instantiate the transport.
# The transport is responsible for handling serialization and
# deserialization and actually sending data to the service.
Expand All @@ -137,6 +151,7 @@ def __init__(
self.transport = transport(
credentials=credentials,
default_class=cluster_manager_grpc_transport.ClusterManagerGrpcTransport,
address=api_endpoint,
)
else:
if credentials:
Expand All @@ -147,7 +162,7 @@ def __init__(
self.transport = transport
else:
self.transport = cluster_manager_grpc_transport.ClusterManagerGrpcTransport(
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
address=api_endpoint, channel=channel, credentials=credentials
)

if client_info is None:
Expand Down Expand Up @@ -3264,10 +3279,10 @@ def list_usable_subnetworks(
that is provided to the method.
Returns:
A :class:`~google.gax.PageIterator` instance. By default, this
is an iterable of :class:`~google.cloud.container_v1beta1.types.UsableSubnetwork` instances.
This object can also be configured to iterate over the pages
of the response through the `options` parameter.
A :class:`~google.api_core.page_iterator.PageIterator` instance.
An iterable of :class:`~google.cloud.container_v1beta1.types.UsableSubnetwork` instances.
You can also iterate over the pages of the response
using its `pages` property.
Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-container/synth.metadata
@@ -1,19 +1,19 @@
{
"updateTime": "2019-06-19T21:23:40.101495Z",
"updateTime": "2019-06-28T12:16:07.837065Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.28.0",
"dockerImage": "googleapis/artman@sha256:6ced5a36b08b82a328c69844e629300d58c14067f25cadab47f52542bdef7daf"
"version": "0.29.2",
"dockerImage": "googleapis/artman@sha256:45263333b058a4b3c26a8b7680a2710f43eae3d250f791a6cb66423991dcb2df"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "45e125f9e30dc5d45b52752b3ab78dd4f6084f2d",
"internalRef": "254026509"
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
"internalRef": "255474859"
}
},
{
Expand Down

0 comments on commit d0e658a

Please sign in to comment.