Skip to content

Commit 3d64523

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (googleapis#8501)
1 parent 8270b03 commit 3d64523

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

container/google/cloud/container_v1/gapic/cluster_manager_client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import warnings
2121

2222
from google.oauth2 import service_account
23+
import google.api_core.client_options
2324
import google.api_core.gapic_v1.client_info
2425
import google.api_core.gapic_v1.config
2526
import google.api_core.gapic_v1.method
@@ -77,6 +78,7 @@ def __init__(
7778
credentials=None,
7879
client_config=None,
7980
client_info=None,
81+
client_options=None,
8082
):
8183
"""Constructor.
8284
@@ -107,6 +109,9 @@ def __init__(
107109
API requests. If ``None``, then default info will be used.
108110
Generally, you only need to set this if you're developing
109111
your own client library.
112+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
113+
Client options used to set user options on the client. API Endpoint
114+
should be set through client_options.
110115
"""
111116
# Raise deprecation warnings for things we want to go away.
112117
if client_config is not None:
@@ -125,6 +130,15 @@ def __init__(
125130
stacklevel=2,
126131
)
127132

133+
api_endpoint = self.SERVICE_ADDRESS
134+
if client_options:
135+
if type(client_options) == dict:
136+
client_options = google.api_core.client_options.from_dict(
137+
client_options
138+
)
139+
if client_options.api_endpoint:
140+
api_endpoint = client_options.api_endpoint
141+
128142
# Instantiate the transport.
129143
# The transport is responsible for handling serialization and
130144
# deserialization and actually sending data to the service.
@@ -133,6 +147,7 @@ def __init__(
133147
self.transport = transport(
134148
credentials=credentials,
135149
default_class=cluster_manager_grpc_transport.ClusterManagerGrpcTransport,
150+
address=api_endpoint,
136151
)
137152
else:
138153
if credentials:
@@ -143,7 +158,7 @@ def __init__(
143158
self.transport = transport
144159
else:
145160
self.transport = cluster_manager_grpc_transport.ClusterManagerGrpcTransport(
146-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
161+
address=api_endpoint, channel=channel, credentials=credentials
147162
)
148163

149164
if client_info is None:

container/google/cloud/container_v1beta1/gapic/cluster_manager_client.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import warnings
2222

2323
from google.oauth2 import service_account
24+
import google.api_core.client_options
2425
import google.api_core.gapic_v1.client_info
2526
import google.api_core.gapic_v1.config
2627
import google.api_core.gapic_v1.method
@@ -81,6 +82,7 @@ def __init__(
8182
credentials=None,
8283
client_config=None,
8384
client_info=None,
85+
client_options=None,
8486
):
8587
"""Constructor.
8688
@@ -111,6 +113,9 @@ def __init__(
111113
API requests. If ``None``, then default info will be used.
112114
Generally, you only need to set this if you're developing
113115
your own client library.
116+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
117+
Client options used to set user options on the client. API Endpoint
118+
should be set through client_options.
114119
"""
115120
# Raise deprecation warnings for things we want to go away.
116121
if client_config is not None:
@@ -129,6 +134,15 @@ def __init__(
129134
stacklevel=2,
130135
)
131136

137+
api_endpoint = self.SERVICE_ADDRESS
138+
if client_options:
139+
if type(client_options) == dict:
140+
client_options = google.api_core.client_options.from_dict(
141+
client_options
142+
)
143+
if client_options.api_endpoint:
144+
api_endpoint = client_options.api_endpoint
145+
132146
# Instantiate the transport.
133147
# The transport is responsible for handling serialization and
134148
# deserialization and actually sending data to the service.
@@ -137,6 +151,7 @@ def __init__(
137151
self.transport = transport(
138152
credentials=credentials,
139153
default_class=cluster_manager_grpc_transport.ClusterManagerGrpcTransport,
154+
address=api_endpoint,
140155
)
141156
else:
142157
if credentials:
@@ -147,7 +162,7 @@ def __init__(
147162
self.transport = transport
148163
else:
149164
self.transport = cluster_manager_grpc_transport.ClusterManagerGrpcTransport(
150-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
165+
address=api_endpoint, channel=channel, credentials=credentials
151166
)
152167

153168
if client_info is None:
@@ -3264,10 +3279,10 @@ def list_usable_subnetworks(
32643279
that is provided to the method.
32653280
32663281
Returns:
3267-
A :class:`~google.gax.PageIterator` instance. By default, this
3268-
is an iterable of :class:`~google.cloud.container_v1beta1.types.UsableSubnetwork` instances.
3269-
This object can also be configured to iterate over the pages
3270-
of the response through the `options` parameter.
3282+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
3283+
An iterable of :class:`~google.cloud.container_v1beta1.types.UsableSubnetwork` instances.
3284+
You can also iterate over the pages of the response
3285+
using its `pages` property.
32713286
32723287
Raises:
32733288
google.api_core.exceptions.GoogleAPICallError: If the request

container/synth.metadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-06-19T21:23:40.101495Z",
2+
"updateTime": "2019-06-28T12:16:07.837065Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.28.0",
8-
"dockerImage": "googleapis/artman@sha256:6ced5a36b08b82a328c69844e629300d58c14067f25cadab47f52542bdef7daf"
7+
"version": "0.29.2",
8+
"dockerImage": "googleapis/artman@sha256:45263333b058a4b3c26a8b7680a2710f43eae3d250f791a6cb66423991dcb2df"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "45e125f9e30dc5d45b52752b3ab78dd4f6084f2d",
16-
"internalRef": "254026509"
15+
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
16+
"internalRef": "255474859"
1717
}
1818
},
1919
{

0 commit comments

Comments
 (0)