Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ab78ae

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (googleapis#8529)
1 parent ff57c6d commit 2ab78ae

File tree

9 files changed

+181
-61
lines changed

9 files changed

+181
-61
lines changed

vision/google/cloud/vision_v1/gapic/image_annotator_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
@@ -80,6 +81,7 @@ def __init__(
8081
credentials=None,
8182
client_config=None,
8283
client_info=None,
84+
client_options=None,
8385
):
8486
"""Constructor.
8587
@@ -110,6 +112,9 @@ def __init__(
110112
API requests. If ``None``, then default info will be used.
111113
Generally, you only need to set this if you're developing
112114
your own client library.
115+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
116+
Client options used to set user options on the client. API Endpoint
117+
should be set through client_options.
113118
"""
114119
# Raise deprecation warnings for things we want to go away.
115120
if client_config is not None:
@@ -128,6 +133,15 @@ def __init__(
128133
stacklevel=2,
129134
)
130135

136+
api_endpoint = self.SERVICE_ADDRESS
137+
if client_options:
138+
if type(client_options) == dict:
139+
client_options = google.api_core.client_options.from_dict(
140+
client_options
141+
)
142+
if client_options.api_endpoint:
143+
api_endpoint = client_options.api_endpoint
144+
131145
# Instantiate the transport.
132146
# The transport is responsible for handling serialization and
133147
# deserialization and actually sending data to the service.
@@ -136,6 +150,7 @@ def __init__(
136150
self.transport = transport(
137151
credentials=credentials,
138152
default_class=image_annotator_grpc_transport.ImageAnnotatorGrpcTransport,
153+
address=api_endpoint,
139154
)
140155
else:
141156
if credentials:
@@ -146,7 +161,7 @@ def __init__(
146161
self.transport = transport
147162
else:
148163
self.transport = image_annotator_grpc_transport.ImageAnnotatorGrpcTransport(
149-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
164+
address=api_endpoint, channel=channel, credentials=credentials
150165
)
151166

152167
if client_info is None:

vision/google/cloud/vision_v1/gapic/product_search_client.py

Lines changed: 32 additions & 17 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
@@ -139,6 +140,7 @@ def __init__(
139140
credentials=None,
140141
client_config=None,
141142
client_info=None,
143+
client_options=None,
142144
):
143145
"""Constructor.
144146
@@ -169,6 +171,9 @@ def __init__(
169171
API requests. If ``None``, then default info will be used.
170172
Generally, you only need to set this if you're developing
171173
your own client library.
174+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
175+
Client options used to set user options on the client. API Endpoint
176+
should be set through client_options.
172177
"""
173178
# Raise deprecation warnings for things we want to go away.
174179
if client_config is not None:
@@ -187,6 +192,15 @@ def __init__(
187192
stacklevel=2,
188193
)
189194

195+
api_endpoint = self.SERVICE_ADDRESS
196+
if client_options:
197+
if type(client_options) == dict:
198+
client_options = google.api_core.client_options.from_dict(
199+
client_options
200+
)
201+
if client_options.api_endpoint:
202+
api_endpoint = client_options.api_endpoint
203+
190204
# Instantiate the transport.
191205
# The transport is responsible for handling serialization and
192206
# deserialization and actually sending data to the service.
@@ -195,6 +209,7 @@ def __init__(
195209
self.transport = transport(
196210
credentials=credentials,
197211
default_class=product_search_grpc_transport.ProductSearchGrpcTransport,
212+
address=api_endpoint,
198213
)
199214
else:
200215
if credentials:
@@ -205,7 +220,7 @@ def __init__(
205220
self.transport = transport
206221
else:
207222
self.transport = product_search_grpc_transport.ProductSearchGrpcTransport(
208-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
223+
address=api_endpoint, channel=channel, credentials=credentials
209224
)
210225

211226
if client_info is None:
@@ -378,10 +393,10 @@ def list_product_sets(
378393
that is provided to the method.
379394
380395
Returns:
381-
A :class:`~google.gax.PageIterator` instance. By default, this
382-
is an iterable of :class:`~google.cloud.vision_v1.types.ProductSet` instances.
383-
This object can also be configured to iterate over the pages
384-
of the response through the `options` parameter.
396+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
397+
An iterable of :class:`~google.cloud.vision_v1.types.ProductSet` instances.
398+
You can also iterate over the pages of the response
399+
using its `pages` property.
385400
386401
Raises:
387402
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -819,10 +834,10 @@ def list_products(
819834
that is provided to the method.
820835
821836
Returns:
822-
A :class:`~google.gax.PageIterator` instance. By default, this
823-
is an iterable of :class:`~google.cloud.vision_v1.types.Product` instances.
824-
This object can also be configured to iterate over the pages
825-
of the response through the `options` parameter.
837+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
838+
An iterable of :class:`~google.cloud.vision_v1.types.Product` instances.
839+
You can also iterate over the pages of the response
840+
using its `pages` property.
826841
827842
Raises:
828843
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1359,10 +1374,10 @@ def list_reference_images(
13591374
that is provided to the method.
13601375
13611376
Returns:
1362-
A :class:`~google.gax.PageIterator` instance. By default, this
1363-
is an iterable of :class:`~google.cloud.vision_v1.types.ReferenceImage` instances.
1364-
This object can also be configured to iterate over the pages
1365-
of the response through the `options` parameter.
1377+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1378+
An iterable of :class:`~google.cloud.vision_v1.types.ReferenceImage` instances.
1379+
You can also iterate over the pages of the response
1380+
using its `pages` property.
13661381
13671382
Raises:
13681383
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1710,10 +1725,10 @@ def list_products_in_product_set(
17101725
that is provided to the method.
17111726
17121727
Returns:
1713-
A :class:`~google.gax.PageIterator` instance. By default, this
1714-
is an iterable of :class:`~google.cloud.vision_v1.types.Product` instances.
1715-
This object can also be configured to iterate over the pages
1716-
of the response through the `options` parameter.
1728+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1729+
An iterable of :class:`~google.cloud.vision_v1.types.Product` instances.
1730+
You can also iterate over the pages of the response
1731+
using its `pages` property.
17171732
17181733
Raises:
17191734
google.api_core.exceptions.GoogleAPICallError: If the request

vision/google/cloud/vision_v1p1beta1/gapic/image_annotator_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
@@ -79,6 +80,7 @@ def __init__(
7980
credentials=None,
8081
client_config=None,
8182
client_info=None,
83+
client_options=None,
8284
):
8385
"""Constructor.
8486
@@ -109,6 +111,9 @@ def __init__(
109111
API requests. If ``None``, then default info will be used.
110112
Generally, you only need to set this if you're developing
111113
your own client library.
114+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
115+
Client options used to set user options on the client. API Endpoint
116+
should be set through client_options.
112117
"""
113118
# Raise deprecation warnings for things we want to go away.
114119
if client_config is not None:
@@ -127,6 +132,15 @@ def __init__(
127132
stacklevel=2,
128133
)
129134

135+
api_endpoint = self.SERVICE_ADDRESS
136+
if client_options:
137+
if type(client_options) == dict:
138+
client_options = google.api_core.client_options.from_dict(
139+
client_options
140+
)
141+
if client_options.api_endpoint:
142+
api_endpoint = client_options.api_endpoint
143+
130144
# Instantiate the transport.
131145
# The transport is responsible for handling serialization and
132146
# deserialization and actually sending data to the service.
@@ -135,6 +149,7 @@ def __init__(
135149
self.transport = transport(
136150
credentials=credentials,
137151
default_class=image_annotator_grpc_transport.ImageAnnotatorGrpcTransport,
152+
address=api_endpoint,
138153
)
139154
else:
140155
if credentials:
@@ -145,7 +160,7 @@ def __init__(
145160
self.transport = transport
146161
else:
147162
self.transport = image_annotator_grpc_transport.ImageAnnotatorGrpcTransport(
148-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
163+
address=api_endpoint, channel=channel, credentials=credentials
149164
)
150165

151166
if client_info is None:

vision/google/cloud/vision_v1p2beta1/gapic/image_annotator_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
@@ -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=image_annotator_grpc_transport.ImageAnnotatorGrpcTransport,
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 = image_annotator_grpc_transport.ImageAnnotatorGrpcTransport(
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:

vision/google/cloud/vision_v1p3beta1/gapic/image_annotator_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
@@ -86,6 +87,7 @@ def __init__(
8687
credentials=None,
8788
client_config=None,
8889
client_info=None,
90+
client_options=None,
8991
):
9092
"""Constructor.
9193
@@ -116,6 +118,9 @@ def __init__(
116118
API requests. If ``None``, then default info will be used.
117119
Generally, you only need to set this if you're developing
118120
your own client library.
121+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
122+
Client options used to set user options on the client. API Endpoint
123+
should be set through client_options.
119124
"""
120125
# Raise deprecation warnings for things we want to go away.
121126
if client_config is not None:
@@ -134,6 +139,15 @@ def __init__(
134139
stacklevel=2,
135140
)
136141

142+
api_endpoint = self.SERVICE_ADDRESS
143+
if client_options:
144+
if type(client_options) == dict:
145+
client_options = google.api_core.client_options.from_dict(
146+
client_options
147+
)
148+
if client_options.api_endpoint:
149+
api_endpoint = client_options.api_endpoint
150+
137151
# Instantiate the transport.
138152
# The transport is responsible for handling serialization and
139153
# deserialization and actually sending data to the service.
@@ -142,6 +156,7 @@ def __init__(
142156
self.transport = transport(
143157
credentials=credentials,
144158
default_class=image_annotator_grpc_transport.ImageAnnotatorGrpcTransport,
159+
address=api_endpoint,
145160
)
146161
else:
147162
if credentials:
@@ -152,7 +167,7 @@ def __init__(
152167
self.transport = transport
153168
else:
154169
self.transport = image_annotator_grpc_transport.ImageAnnotatorGrpcTransport(
155-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
170+
address=api_endpoint, channel=channel, credentials=credentials
156171
)
157172

158173
if client_info is None:

0 commit comments

Comments
 (0)