Skip to content

Commit 5ff4e34

Browse files
yoshi-automationbusunkim96
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (googleapis#8505)
1 parent 0d14378 commit 5ff4e34

File tree

8 files changed

+145
-40
lines changed

8 files changed

+145
-40
lines changed

dataproc/google/cloud/dataproc_v1/gapic/cluster_controller_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
@@ -85,6 +86,7 @@ def __init__(
8586
credentials=None,
8687
client_config=None,
8788
client_info=None,
89+
client_options=None,
8890
):
8991
"""Constructor.
9092
@@ -115,6 +117,9 @@ def __init__(
115117
API requests. If ``None``, then default info will be used.
116118
Generally, you only need to set this if you're developing
117119
your own client library.
120+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
121+
Client options used to set user options on the client. API Endpoint
122+
should be set through client_options.
118123
"""
119124
# Raise deprecation warnings for things we want to go away.
120125
if client_config is not None:
@@ -133,6 +138,15 @@ def __init__(
133138
stacklevel=2,
134139
)
135140

141+
api_endpoint = self.SERVICE_ADDRESS
142+
if client_options:
143+
if type(client_options) == dict:
144+
client_options = google.api_core.client_options.from_dict(
145+
client_options
146+
)
147+
if client_options.api_endpoint:
148+
api_endpoint = client_options.api_endpoint
149+
136150
# Instantiate the transport.
137151
# The transport is responsible for handling serialization and
138152
# deserialization and actually sending data to the service.
@@ -141,6 +155,7 @@ def __init__(
141155
self.transport = transport(
142156
credentials=credentials,
143157
default_class=cluster_controller_grpc_transport.ClusterControllerGrpcTransport,
158+
address=api_endpoint,
144159
)
145160
else:
146161
if credentials:
@@ -151,7 +166,7 @@ def __init__(
151166
self.transport = transport
152167
else:
153168
self.transport = cluster_controller_grpc_transport.ClusterControllerGrpcTransport(
154-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
169+
address=api_endpoint, channel=channel, credentials=credentials
155170
)
156171

157172
if client_info is None:
@@ -713,10 +728,10 @@ def list_clusters(
713728
that is provided to the method.
714729
715730
Returns:
716-
A :class:`~google.gax.PageIterator` instance. By default, this
717-
is an iterable of :class:`~google.cloud.dataproc_v1.types.Cluster` instances.
718-
This object can also be configured to iterate over the pages
719-
of the response through the `options` parameter.
731+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
732+
An iterable of :class:`~google.cloud.dataproc_v1.types.Cluster` instances.
733+
You can also iterate over the pages of the response
734+
using its `pages` property.
720735
721736
Raises:
722737
google.api_core.exceptions.GoogleAPICallError: If the request

dataproc/google/cloud/dataproc_v1/gapic/job_controller_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
@@ -82,6 +83,7 @@ def __init__(
8283
credentials=None,
8384
client_config=None,
8485
client_info=None,
86+
client_options=None,
8587
):
8688
"""Constructor.
8789
@@ -112,6 +114,9 @@ def __init__(
112114
API requests. If ``None``, then default info will be used.
113115
Generally, you only need to set this if you're developing
114116
your own client library.
117+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
118+
Client options used to set user options on the client. API Endpoint
119+
should be set through client_options.
115120
"""
116121
# Raise deprecation warnings for things we want to go away.
117122
if client_config is not None:
@@ -130,6 +135,15 @@ def __init__(
130135
stacklevel=2,
131136
)
132137

138+
api_endpoint = self.SERVICE_ADDRESS
139+
if client_options:
140+
if type(client_options) == dict:
141+
client_options = google.api_core.client_options.from_dict(
142+
client_options
143+
)
144+
if client_options.api_endpoint:
145+
api_endpoint = client_options.api_endpoint
146+
133147
# Instantiate the transport.
134148
# The transport is responsible for handling serialization and
135149
# deserialization and actually sending data to the service.
@@ -138,6 +152,7 @@ def __init__(
138152
self.transport = transport(
139153
credentials=credentials,
140154
default_class=job_controller_grpc_transport.JobControllerGrpcTransport,
155+
address=api_endpoint,
141156
)
142157
else:
143158
if credentials:
@@ -148,7 +163,7 @@ def __init__(
148163
self.transport = transport
149164
else:
150165
self.transport = job_controller_grpc_transport.JobControllerGrpcTransport(
151-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
166+
address=api_endpoint, channel=channel, credentials=credentials
152167
)
153168

154169
if client_info is None:
@@ -407,10 +422,10 @@ def list_jobs(
407422
that is provided to the method.
408423
409424
Returns:
410-
A :class:`~google.gax.PageIterator` instance. By default, this
411-
is an iterable of :class:`~google.cloud.dataproc_v1.types.Job` instances.
412-
This object can also be configured to iterate over the pages
413-
of the response through the `options` parameter.
425+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
426+
An iterable of :class:`~google.cloud.dataproc_v1.types.Job` instances.
427+
You can also iterate over the pages of the response
428+
using its `pages` property.
414429
415430
Raises:
416431
google.api_core.exceptions.GoogleAPICallError: If the request

dataproc/google/cloud/dataproc_v1/gapic/workflow_template_service_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
@@ -110,6 +111,7 @@ def __init__(
110111
credentials=None,
111112
client_config=None,
112113
client_info=None,
114+
client_options=None,
113115
):
114116
"""Constructor.
115117
@@ -140,6 +142,9 @@ def __init__(
140142
API requests. If ``None``, then default info will be used.
141143
Generally, you only need to set this if you're developing
142144
your own client library.
145+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
146+
Client options used to set user options on the client. API Endpoint
147+
should be set through client_options.
143148
"""
144149
# Raise deprecation warnings for things we want to go away.
145150
if client_config is not None:
@@ -158,6 +163,15 @@ def __init__(
158163
stacklevel=2,
159164
)
160165

166+
api_endpoint = self.SERVICE_ADDRESS
167+
if client_options:
168+
if type(client_options) == dict:
169+
client_options = google.api_core.client_options.from_dict(
170+
client_options
171+
)
172+
if client_options.api_endpoint:
173+
api_endpoint = client_options.api_endpoint
174+
161175
# Instantiate the transport.
162176
# The transport is responsible for handling serialization and
163177
# deserialization and actually sending data to the service.
@@ -166,6 +180,7 @@ def __init__(
166180
self.transport = transport(
167181
credentials=credentials,
168182
default_class=workflow_template_service_grpc_transport.WorkflowTemplateServiceGrpcTransport,
183+
address=api_endpoint,
169184
)
170185
else:
171186
if credentials:
@@ -176,7 +191,7 @@ def __init__(
176191
self.transport = transport
177192
else:
178193
self.transport = workflow_template_service_grpc_transport.WorkflowTemplateServiceGrpcTransport(
179-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
194+
address=api_endpoint, channel=channel, credentials=credentials
180195
)
181196

182197
if client_info is None:
@@ -741,10 +756,10 @@ def list_workflow_templates(
741756
that is provided to the method.
742757
743758
Returns:
744-
A :class:`~google.gax.PageIterator` instance. By default, this
745-
is an iterable of :class:`~google.cloud.dataproc_v1.types.WorkflowTemplate` instances.
746-
This object can also be configured to iterate over the pages
747-
of the response through the `options` parameter.
759+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
760+
An iterable of :class:`~google.cloud.dataproc_v1.types.WorkflowTemplate` instances.
761+
You can also iterate over the pages of the response
762+
using its `pages` property.
748763
749764
Raises:
750765
google.api_core.exceptions.GoogleAPICallError: If the request

dataproc/google/cloud/dataproc_v1beta2/gapic/autoscaling_policy_service_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
@@ -100,6 +101,7 @@ def __init__(
100101
credentials=None,
101102
client_config=None,
102103
client_info=None,
104+
client_options=None,
103105
):
104106
"""Constructor.
105107
@@ -130,6 +132,9 @@ def __init__(
130132
API requests. If ``None``, then default info will be used.
131133
Generally, you only need to set this if you're developing
132134
your own client library.
135+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
136+
Client options used to set user options on the client. API Endpoint
137+
should be set through client_options.
133138
"""
134139
# Raise deprecation warnings for things we want to go away.
135140
if client_config is not None:
@@ -148,6 +153,15 @@ def __init__(
148153
stacklevel=2,
149154
)
150155

156+
api_endpoint = self.SERVICE_ADDRESS
157+
if client_options:
158+
if type(client_options) == dict:
159+
client_options = google.api_core.client_options.from_dict(
160+
client_options
161+
)
162+
if client_options.api_endpoint:
163+
api_endpoint = client_options.api_endpoint
164+
151165
# Instantiate the transport.
152166
# The transport is responsible for handling serialization and
153167
# deserialization and actually sending data to the service.
@@ -156,6 +170,7 @@ def __init__(
156170
self.transport = transport(
157171
credentials=credentials,
158172
default_class=autoscaling_policy_service_grpc_transport.AutoscalingPolicyServiceGrpcTransport,
173+
address=api_endpoint,
159174
)
160175
else:
161176
if credentials:
@@ -166,7 +181,7 @@ def __init__(
166181
self.transport = transport
167182
else:
168183
self.transport = autoscaling_policy_service_grpc_transport.AutoscalingPolicyServiceGrpcTransport(
169-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
184+
address=api_endpoint, channel=channel, credentials=credentials
170185
)
171186

172187
if client_info is None:
@@ -471,10 +486,10 @@ def list_autoscaling_policies(
471486
that is provided to the method.
472487
473488
Returns:
474-
A :class:`~google.gax.PageIterator` instance. By default, this
475-
is an iterable of :class:`~google.cloud.dataproc_v1beta2.types.AutoscalingPolicy` instances.
476-
This object can also be configured to iterate over the pages
477-
of the response through the `options` parameter.
489+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
490+
An iterable of :class:`~google.cloud.dataproc_v1beta2.types.AutoscalingPolicy` instances.
491+
You can also iterate over the pages of the response
492+
using its `pages` property.
478493
479494
Raises:
480495
google.api_core.exceptions.GoogleAPICallError: If the request

dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_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
@@ -89,6 +90,7 @@ def __init__(
8990
credentials=None,
9091
client_config=None,
9192
client_info=None,
93+
client_options=None,
9294
):
9395
"""Constructor.
9496
@@ -119,6 +121,9 @@ def __init__(
119121
API requests. If ``None``, then default info will be used.
120122
Generally, you only need to set this if you're developing
121123
your own client library.
124+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
125+
Client options used to set user options on the client. API Endpoint
126+
should be set through client_options.
122127
"""
123128
# Raise deprecation warnings for things we want to go away.
124129
if client_config is not None:
@@ -137,6 +142,15 @@ def __init__(
137142
stacklevel=2,
138143
)
139144

145+
api_endpoint = self.SERVICE_ADDRESS
146+
if client_options:
147+
if type(client_options) == dict:
148+
client_options = google.api_core.client_options.from_dict(
149+
client_options
150+
)
151+
if client_options.api_endpoint:
152+
api_endpoint = client_options.api_endpoint
153+
140154
# Instantiate the transport.
141155
# The transport is responsible for handling serialization and
142156
# deserialization and actually sending data to the service.
@@ -145,6 +159,7 @@ def __init__(
145159
self.transport = transport(
146160
credentials=credentials,
147161
default_class=cluster_controller_grpc_transport.ClusterControllerGrpcTransport,
162+
address=api_endpoint,
148163
)
149164
else:
150165
if credentials:
@@ -155,7 +170,7 @@ def __init__(
155170
self.transport = transport
156171
else:
157172
self.transport = cluster_controller_grpc_transport.ClusterControllerGrpcTransport(
158-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
173+
address=api_endpoint, channel=channel, credentials=credentials
159174
)
160175

161176
if client_info is None:
@@ -729,10 +744,10 @@ def list_clusters(
729744
that is provided to the method.
730745
731746
Returns:
732-
A :class:`~google.gax.PageIterator` instance. By default, this
733-
is an iterable of :class:`~google.cloud.dataproc_v1beta2.types.Cluster` instances.
734-
This object can also be configured to iterate over the pages
735-
of the response through the `options` parameter.
747+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
748+
An iterable of :class:`~google.cloud.dataproc_v1beta2.types.Cluster` instances.
749+
You can also iterate over the pages of the response
750+
using its `pages` property.
736751
737752
Raises:
738753
google.api_core.exceptions.GoogleAPICallError: If the request

0 commit comments

Comments
 (0)