Skip to content

Commit 8594cc3

Browse files
yoshi-automationtseaver
authored andcommitted
Add 'client_options' support, update list method docstrings (via synth). (#8531)
1 parent 28fda6e commit 8594cc3

File tree

3 files changed

+69
-39
lines changed

3 files changed

+69
-39
lines changed

packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic/web_security_scanner_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
@@ -129,6 +130,7 @@ def __init__(
129130
credentials=None,
130131
client_config=None,
131132
client_info=None,
133+
client_options=None,
132134
):
133135
"""Constructor.
134136
@@ -159,6 +161,9 @@ def __init__(
159161
API requests. If ``None``, then default info will be used.
160162
Generally, you only need to set this if you're developing
161163
your own client library.
164+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
165+
Client options used to set user options on the client. API Endpoint
166+
should be set through client_options.
162167
"""
163168
# Raise deprecation warnings for things we want to go away.
164169
if client_config is not None:
@@ -177,6 +182,15 @@ def __init__(
177182
stacklevel=2,
178183
)
179184

185+
api_endpoint = self.SERVICE_ADDRESS
186+
if client_options:
187+
if type(client_options) == dict:
188+
client_options = google.api_core.client_options.from_dict(
189+
client_options
190+
)
191+
if client_options.api_endpoint:
192+
api_endpoint = client_options.api_endpoint
193+
180194
# Instantiate the transport.
181195
# The transport is responsible for handling serialization and
182196
# deserialization and actually sending data to the service.
@@ -185,6 +199,7 @@ def __init__(
185199
self.transport = transport(
186200
credentials=credentials,
187201
default_class=web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport,
202+
address=api_endpoint,
188203
)
189204
else:
190205
if credentials:
@@ -195,7 +210,7 @@ def __init__(
195210
self.transport = transport
196211
else:
197212
self.transport = web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport(
198-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
213+
address=api_endpoint, channel=channel, credentials=credentials
199214
)
200215

201216
if client_info is None:
@@ -493,10 +508,10 @@ def list_scan_configs(
493508
that is provided to the method.
494509
495510
Returns:
496-
A :class:`~google.gax.PageIterator` instance. By default, this
497-
is an iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instances.
498-
This object can also be configured to iterate over the pages
499-
of the response through the `options` parameter.
511+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
512+
An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instances.
513+
You can also iterate over the pages of the response
514+
using its `pages` property.
500515
501516
Raises:
502517
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -830,10 +845,10 @@ def list_scan_runs(
830845
that is provided to the method.
831846
832847
Returns:
833-
A :class:`~google.gax.PageIterator` instance. By default, this
834-
is an iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instances.
835-
This object can also be configured to iterate over the pages
836-
of the response through the `options` parameter.
848+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
849+
An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanRun` instances.
850+
You can also iterate over the pages of the response
851+
using its `pages` property.
837852
838853
Raises:
839854
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1008,10 +1023,10 @@ def list_crawled_urls(
10081023
that is provided to the method.
10091024
10101025
Returns:
1011-
A :class:`~google.gax.PageIterator` instance. By default, this
1012-
is an iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.CrawledUrl` instances.
1013-
This object can also be configured to iterate over the pages
1014-
of the response through the `options` parameter.
1026+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1027+
An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.CrawledUrl` instances.
1028+
You can also iterate over the pages of the response
1029+
using its `pages` property.
10151030
10161031
Raises:
10171032
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1192,10 +1207,10 @@ def list_findings(
11921207
that is provided to the method.
11931208
11941209
Returns:
1195-
A :class:`~google.gax.PageIterator` instance. By default, this
1196-
is an iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.Finding` instances.
1197-
This object can also be configured to iterate over the pages
1198-
of the response through the `options` parameter.
1210+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1211+
An iterable of :class:`~google.cloud.websecurityscanner_v1alpha.types.Finding` instances.
1212+
You can also iterate over the pages of the response
1213+
using its `pages` property.
11991214
12001215
Raises:
12011216
google.api_core.exceptions.GoogleAPICallError: If the request

packages/google-cloud-websecurityscanner/google/cloud/websecurityscanner_v1beta/gapic/web_security_scanner_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
@@ -129,6 +130,7 @@ def __init__(
129130
credentials=None,
130131
client_config=None,
131132
client_info=None,
133+
client_options=None,
132134
):
133135
"""Constructor.
134136
@@ -159,6 +161,9 @@ def __init__(
159161
API requests. If ``None``, then default info will be used.
160162
Generally, you only need to set this if you're developing
161163
your own client library.
164+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
165+
Client options used to set user options on the client. API Endpoint
166+
should be set through client_options.
162167
"""
163168
# Raise deprecation warnings for things we want to go away.
164169
if client_config is not None:
@@ -177,6 +182,15 @@ def __init__(
177182
stacklevel=2,
178183
)
179184

185+
api_endpoint = self.SERVICE_ADDRESS
186+
if client_options:
187+
if type(client_options) == dict:
188+
client_options = google.api_core.client_options.from_dict(
189+
client_options
190+
)
191+
if client_options.api_endpoint:
192+
api_endpoint = client_options.api_endpoint
193+
180194
# Instantiate the transport.
181195
# The transport is responsible for handling serialization and
182196
# deserialization and actually sending data to the service.
@@ -185,6 +199,7 @@ def __init__(
185199
self.transport = transport(
186200
credentials=credentials,
187201
default_class=web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport,
202+
address=api_endpoint,
188203
)
189204
else:
190205
if credentials:
@@ -195,7 +210,7 @@ def __init__(
195210
self.transport = transport
196211
else:
197212
self.transport = web_security_scanner_grpc_transport.WebSecurityScannerGrpcTransport(
198-
address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials
213+
address=api_endpoint, channel=channel, credentials=credentials
199214
)
200215

201216
if client_info is None:
@@ -493,10 +508,10 @@ def list_scan_configs(
493508
that is provided to the method.
494509
495510
Returns:
496-
A :class:`~google.gax.PageIterator` instance. By default, this
497-
is an iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instances.
498-
This object can also be configured to iterate over the pages
499-
of the response through the `options` parameter.
511+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
512+
An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanConfig` instances.
513+
You can also iterate over the pages of the response
514+
using its `pages` property.
500515
501516
Raises:
502517
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -830,10 +845,10 @@ def list_scan_runs(
830845
that is provided to the method.
831846
832847
Returns:
833-
A :class:`~google.gax.PageIterator` instance. By default, this
834-
is an iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instances.
835-
This object can also be configured to iterate over the pages
836-
of the response through the `options` parameter.
848+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
849+
An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.ScanRun` instances.
850+
You can also iterate over the pages of the response
851+
using its `pages` property.
837852
838853
Raises:
839854
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1008,10 +1023,10 @@ def list_crawled_urls(
10081023
that is provided to the method.
10091024
10101025
Returns:
1011-
A :class:`~google.gax.PageIterator` instance. By default, this
1012-
is an iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.CrawledUrl` instances.
1013-
This object can also be configured to iterate over the pages
1014-
of the response through the `options` parameter.
1026+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1027+
An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.CrawledUrl` instances.
1028+
You can also iterate over the pages of the response
1029+
using its `pages` property.
10151030
10161031
Raises:
10171032
google.api_core.exceptions.GoogleAPICallError: If the request
@@ -1192,10 +1207,10 @@ def list_findings(
11921207
that is provided to the method.
11931208
11941209
Returns:
1195-
A :class:`~google.gax.PageIterator` instance. By default, this
1196-
is an iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.Finding` instances.
1197-
This object can also be configured to iterate over the pages
1198-
of the response through the `options` parameter.
1210+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1211+
An iterable of :class:`~google.cloud.websecurityscanner_v1beta.types.Finding` instances.
1212+
You can also iterate over the pages of the response
1213+
using its `pages` property.
11991214
12001215
Raises:
12011216
google.api_core.exceptions.GoogleAPICallError: If the request

packages/google-cloud-websecurityscanner/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-18T12:38:54.142856Z",
2+
"updateTime": "2019-06-28T12:46:12.179287Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.27.0",
8-
"dockerImage": "googleapis/artman@sha256:b036a7f4278d9deb5796f065e5c7f608d47d75369985ca7ab5039998120e972d"
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": "384aa843867c4d17756d14a01f047b6368494d32",
16-
"internalRef": "253675319"
15+
"sha": "84c8ad4e52f8eec8f08a60636cfa597b86969b5c",
16+
"internalRef": "255474859"
1717
}
1818
},
1919
{

0 commit comments

Comments
 (0)