Skip to content

Commit 0423540

Browse files
authored
Websecurityscanner: add 'synth.py'. (googleapis#6087)
Closes googleapis#6076.
1 parent a89f27c commit 0423540

File tree

5 files changed

+562
-174
lines changed

5 files changed

+562
-174
lines changed

websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic/enums.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
#
13
# Copyright 2018 Google LLC
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,9 +15,11 @@
1315
# limitations under the License.
1416
"""Wrappers for protocol buffer enum types."""
1517

18+
import enum
19+
1620

1721
class Finding(object):
18-
class FindingType(object):
22+
class FindingType(enum.IntEnum):
1923
"""
2024
Types of Findings.
2125
@@ -60,7 +64,7 @@ class FindingType(object):
6064

6165

6266
class ScanConfig(object):
63-
class UserAgent(object):
67+
class UserAgent(enum.IntEnum):
6468
"""
6569
Type of user agents used for scanning.
6670
@@ -75,7 +79,7 @@ class UserAgent(object):
7579
CHROME_ANDROID = 2
7680
SAFARI_IPHONE = 3
7781

78-
class TargetPlatform(object):
82+
class TargetPlatform(enum.IntEnum):
7983
"""
8084
Cloud platforms supported by Cloud Web Security Scanner.
8185
@@ -91,7 +95,7 @@ class TargetPlatform(object):
9195

9296

9397
class ScanRun(object):
94-
class ExecutionState(object):
98+
class ExecutionState(enum.IntEnum):
9599
"""
96100
Types of ScanRun execution state.
97101
@@ -107,7 +111,7 @@ class ExecutionState(object):
107111
SCANNING = 2
108112
FINISHED = 3
109113

110-
class ResultState(object):
114+
class ResultState(enum.IntEnum):
111115
"""
112116
Types of ScanRun result state.
113117

websecurityscanner/google/cloud/websecurityscanner_v1alpha/gapic/transports/__init__.py

Whitespace-only changes.
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2018 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import google.api_core.grpc_helpers
18+
19+
from google.cloud.websecurityscanner_v1alpha.proto import web_security_scanner_pb2_grpc
20+
21+
22+
class WebSecurityScannerGrpcTransport(object):
23+
"""gRPC transport class providing stubs for
24+
google.cloud.websecurityscanner.v1alpha WebSecurityScanner API.
25+
26+
The transport provides access to the raw gRPC stubs,
27+
which can be used to take advantage of advanced
28+
features of gRPC.
29+
"""
30+
# The scopes needed to make gRPC calls to all of the methods defined
31+
# in this service.
32+
_OAUTH_SCOPES = ('https://www.googleapis.com/auth/cloud-platform', )
33+
34+
def __init__(self,
35+
channel=None,
36+
credentials=None,
37+
address='websecurityscanner.googleapis.com:443'):
38+
"""Instantiate the transport class.
39+
40+
Args:
41+
channel (grpc.Channel): A ``Channel`` instance through
42+
which to make calls. This argument is mutually exclusive
43+
with ``credentials``; providing both will raise an exception.
44+
credentials (google.auth.credentials.Credentials): The
45+
authorization credentials to attach to requests. These
46+
credentials identify this application to the service. If none
47+
are specified, the client will attempt to ascertain the
48+
credentials from the environment.
49+
address (str): The address where the service is hosted.
50+
"""
51+
# If both `channel` and `credentials` are specified, raise an
52+
# exception (channels come with credentials baked in already).
53+
if channel is not None and credentials is not None:
54+
raise ValueError(
55+
'The `channel` and `credentials` arguments are mutually '
56+
'exclusive.', )
57+
58+
# Create the channel.
59+
if channel is None:
60+
channel = self.create_channel(
61+
address=address,
62+
credentials=credentials,
63+
)
64+
65+
# gRPC uses objects called "stubs" that are bound to the
66+
# channel and provide a basic method for each RPC.
67+
self._stubs = {
68+
'web_security_scanner_stub':
69+
web_security_scanner_pb2_grpc.WebSecurityScannerStub(channel),
70+
}
71+
72+
@classmethod
73+
def create_channel(cls,
74+
address='websecurityscanner.googleapis.com:443',
75+
credentials=None):
76+
"""Create and return a gRPC channel object.
77+
78+
Args:
79+
address (str): The host for the channel to use.
80+
credentials (~.Credentials): The
81+
authorization credentials to attach to requests. These
82+
credentials identify this application to the service. If
83+
none are specified, the client will attempt to ascertain
84+
the credentials from the environment.
85+
86+
Returns:
87+
grpc.Channel: A gRPC channel object.
88+
"""
89+
return google.api_core.grpc_helpers.create_channel(
90+
address,
91+
credentials=credentials,
92+
scopes=cls._OAUTH_SCOPES,
93+
)
94+
95+
@property
96+
def create_scan_config(self):
97+
"""Return the gRPC stub for {$apiMethod.name}.
98+
99+
Creates a new ScanConfig.
100+
101+
Returns:
102+
Callable: A callable which accepts the appropriate
103+
deserialized request object and returns a
104+
deserialized response object.
105+
"""
106+
return self._stubs['web_security_scanner_stub'].CreateScanConfig
107+
108+
@property
109+
def delete_scan_config(self):
110+
"""Return the gRPC stub for {$apiMethod.name}.
111+
112+
Deletes an existing ScanConfig and its child resources.
113+
114+
Returns:
115+
Callable: A callable which accepts the appropriate
116+
deserialized request object and returns a
117+
deserialized response object.
118+
"""
119+
return self._stubs['web_security_scanner_stub'].DeleteScanConfig
120+
121+
@property
122+
def get_scan_config(self):
123+
"""Return the gRPC stub for {$apiMethod.name}.
124+
125+
Gets a ScanConfig.
126+
127+
Returns:
128+
Callable: A callable which accepts the appropriate
129+
deserialized request object and returns a
130+
deserialized response object.
131+
"""
132+
return self._stubs['web_security_scanner_stub'].GetScanConfig
133+
134+
@property
135+
def list_scan_configs(self):
136+
"""Return the gRPC stub for {$apiMethod.name}.
137+
138+
Lists ScanConfigs under a given project.
139+
140+
Returns:
141+
Callable: A callable which accepts the appropriate
142+
deserialized request object and returns a
143+
deserialized response object.
144+
"""
145+
return self._stubs['web_security_scanner_stub'].ListScanConfigs
146+
147+
@property
148+
def update_scan_config(self):
149+
"""Return the gRPC stub for {$apiMethod.name}.
150+
151+
Updates a ScanConfig. This method support partial update of a ScanConfig.
152+
153+
Returns:
154+
Callable: A callable which accepts the appropriate
155+
deserialized request object and returns a
156+
deserialized response object.
157+
"""
158+
return self._stubs['web_security_scanner_stub'].UpdateScanConfig
159+
160+
@property
161+
def start_scan_run(self):
162+
"""Return the gRPC stub for {$apiMethod.name}.
163+
164+
Start a ScanRun according to the given ScanConfig.
165+
166+
Returns:
167+
Callable: A callable which accepts the appropriate
168+
deserialized request object and returns a
169+
deserialized response object.
170+
"""
171+
return self._stubs['web_security_scanner_stub'].StartScanRun
172+
173+
@property
174+
def get_scan_run(self):
175+
"""Return the gRPC stub for {$apiMethod.name}.
176+
177+
Gets a ScanRun.
178+
179+
Returns:
180+
Callable: A callable which accepts the appropriate
181+
deserialized request object and returns a
182+
deserialized response object.
183+
"""
184+
return self._stubs['web_security_scanner_stub'].GetScanRun
185+
186+
@property
187+
def list_scan_runs(self):
188+
"""Return the gRPC stub for {$apiMethod.name}.
189+
190+
Lists ScanRuns under a given ScanConfig, in descending order of ScanRun
191+
stop time.
192+
193+
Returns:
194+
Callable: A callable which accepts the appropriate
195+
deserialized request object and returns a
196+
deserialized response object.
197+
"""
198+
return self._stubs['web_security_scanner_stub'].ListScanRuns
199+
200+
@property
201+
def stop_scan_run(self):
202+
"""Return the gRPC stub for {$apiMethod.name}.
203+
204+
Stops a ScanRun. The stopped ScanRun is returned.
205+
206+
Returns:
207+
Callable: A callable which accepts the appropriate
208+
deserialized request object and returns a
209+
deserialized response object.
210+
"""
211+
return self._stubs['web_security_scanner_stub'].StopScanRun
212+
213+
@property
214+
def list_crawled_urls(self):
215+
"""Return the gRPC stub for {$apiMethod.name}.
216+
217+
List CrawledUrls under a given ScanRun.
218+
219+
Returns:
220+
Callable: A callable which accepts the appropriate
221+
deserialized request object and returns a
222+
deserialized response object.
223+
"""
224+
return self._stubs['web_security_scanner_stub'].ListCrawledUrls
225+
226+
@property
227+
def get_finding(self):
228+
"""Return the gRPC stub for {$apiMethod.name}.
229+
230+
Gets a Finding.
231+
232+
Returns:
233+
Callable: A callable which accepts the appropriate
234+
deserialized request object and returns a
235+
deserialized response object.
236+
"""
237+
return self._stubs['web_security_scanner_stub'].GetFinding
238+
239+
@property
240+
def list_findings(self):
241+
"""Return the gRPC stub for {$apiMethod.name}.
242+
243+
List Findings under a given ScanRun.
244+
245+
Returns:
246+
Callable: A callable which accepts the appropriate
247+
deserialized request object and returns a
248+
deserialized response object.
249+
"""
250+
return self._stubs['web_security_scanner_stub'].ListFindings
251+
252+
@property
253+
def list_finding_type_stats(self):
254+
"""Return the gRPC stub for {$apiMethod.name}.
255+
256+
List all FindingTypeStats under a given ScanRun.
257+
258+
Returns:
259+
Callable: A callable which accepts the appropriate
260+
deserialized request object and returns a
261+
deserialized response object.
262+
"""
263+
return self._stubs['web_security_scanner_stub'].ListFindingTypeStats

0 commit comments

Comments
 (0)