Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit aaa956b

Browse files
feat!: migrate to microgenerator (#21)
1 parent 3a7405c commit aaa956b

116 files changed

Lines changed: 20781 additions & 15128 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ branch = True
2121
[report]
2222
fail_under = 100
2323
show_missing = True
24+
omit =
25+
google/cloud/websecurityscanner_v1/*
26+
google/cloud/websecurityscanner_v1beta/__init__.py
27+
google/cloud/websecurityscanner_v1alpha/__init__.py
2428
exclude_lines =
2529
# Re-enable the standard pragma
2630
pragma: NO COVER
2731
# Ignore debug-only repr
2832
def __repr__
29-
# Ignore abstract methods
30-
raise NotImplementedError
31-
omit =
32-
*/gapic/*.py
33-
*/proto/*.py
34-
*/core/*.py
35-
*/site-packages/*.py
33+
# Ignore pkg_resources exceptions.
34+
# This is added at the module level as a safeguard for if someone
35+
# generates the code and tries to run it without pip installing. This
36+
# makes it virtually impossible to test properly.
37+
except pkg_resources.DistributionNotFound

README.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Python Client for Web Security Scanner API
22
==========================================
33

4-
|alpha| |pypi| |versions|
4+
|alpha| |pypi| |versions|
55

66
`Web Security Scanner API`_: Web Security Scanner API (under development).
77

@@ -48,12 +48,14 @@ dependencies.
4848

4949

5050
Supported Python Versions
51-
~~~~~~~~~~~~~~~~~~~~~~~~~
52-
Python >= 3.5
51+
^^^^^^^^^^^^^^^^^^^^^^^^^
52+
Python >= 3.6
5353

5454
Deprecated Python Versions
55-
~~~~~~~~~~~~~~~~~~~~~~~~~~
56-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
55+
^^^^^^^^^^^^^^^^^^^^^^^^^^
56+
Python == 2.7.
57+
58+
The last version of this library compatible with Python 2.7 is google-cloud-websecurityscanner==0.4.0.
5759

5860

5961
Mac/Linux

UPGRADING.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# 1.0.0 Migration Guide
2+
3+
The 1.0 release of the `google-cloud-websecurityscanner` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.
4+
5+
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-websecurityscanner/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 1.0.0 release requires Python 3.6+.
12+
13+
14+
## Method Calls
15+
16+
> **WARNING**: Breaking change
17+
18+
Methods expect request objects. We provide a script that will convert most common use cases.
19+
20+
* Install the library
21+
22+
```py
23+
python3 -m pip install google-cloud-websecurityscanner
24+
```
25+
26+
* The script `fixup_websecurityscanner_v1alpha_keywords.py` and `fixup_websecurityscanner_v1beta_keywords.py` are shipped with the library. It expects an input directory (with the code to convert) and an empty destination directory.
27+
28+
```sh
29+
$ fixup_websecurityscanner_v1beta_keywords.py --input-directory .samples/ --output-directory samples/
30+
```
31+
32+
**Before:**
33+
```py
34+
from google.cloud import websecurityscanner_v1beta
35+
36+
client = websecurityscanner_v1beta.WebSecurityScannerClient()
37+
38+
scan_configs = client.list_scan_configs(parent=parent)
39+
```
40+
41+
42+
**After:**
43+
```py
44+
from google.cloud import websecurityscanner_v1beta
45+
46+
client = websecurityscanner_v1beta.WebSecurityScannerClient()
47+
48+
scan_configs = client.list_scan_configs(request = {'parent': parent})
49+
```
50+
51+
### More Details
52+
53+
In `google-cloud-websecurityscanner<1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
54+
55+
**Before:**
56+
```py
57+
def update_scan_config(
58+
self,
59+
scan_config,
60+
update_mask,
61+
retry=google.api_core.gapic_v1.method.DEFAULT,
62+
timeout=google.api_core.gapic_v1.method.DEFAULT,
63+
metadata=None,
64+
):
65+
```
66+
67+
In the 1.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
68+
69+
Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/cloud/websecurityscanner/v1beta/web_security_scanner.proto#L84) specified by the API producer.
70+
71+
72+
**After:**
73+
```py
74+
def update_scan_config(
75+
self,
76+
request: web_security_scanner.UpdateScanConfigRequest = None,
77+
*,
78+
scan_config: gcw_scan_config.ScanConfig = None,
79+
update_mask: field_mask.FieldMask = None,
80+
retry: retries.Retry = gapic_v1.method.DEFAULT,
81+
timeout: float = None,
82+
metadata: Sequence[Tuple[str, str]] = (),
83+
) -> gcw_scan_config.ScanConfig:
84+
```
85+
86+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
87+
> Passing both will result in an error.
88+
89+
90+
Both of these calls are valid:
91+
92+
```py
93+
response = client.update_scan_config(
94+
request={
95+
"scan_config": scan_config,
96+
"update_mask": update_mask
97+
}
98+
)
99+
```
100+
101+
```py
102+
response = client.update_scan_config(
103+
scan_config=scan_config,
104+
update_mask=update_mask
105+
)
106+
```
107+
108+
This call is invalid because it mixes `request` with a keyword argument `update_mask`. Executing this code
109+
will result in an error.
110+
111+
```py
112+
response = client.update_scan_config(
113+
request={ "scan_config": scan_config },
114+
update_mask=update_mask
115+
)
116+
```
117+
118+
119+
120+
## Enums and Types
121+
122+
123+
> **WARNING**: Breaking change
124+
125+
The submodules `enums` and `types` have been removed.
126+
127+
**Before:**
128+
```py
129+
from google.cloud import websecurityscanner_v1beta
130+
131+
risk_level = websecurityscanner_v1beta.enums.ScanConfig.RiskLevel.LOW
132+
finding = websecurityscanner_v1beta.types.Finding(name="name")
133+
```
134+
135+
136+
**After:**
137+
```py
138+
from google.cloud import websecurityscanner_v1beta
139+
140+
risk_level = websecurityscanner_v1beta.ScanConfig.RiskLevel.LOW
141+
finding = websecurityscanner_v1beta.Finding(name="name")
142+
```

docs/UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md

docs/gapic/v1alpha/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/gapic/v1alpha/types.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/gapic/v1beta/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/gapic/v1beta/types.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/index.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This package includes clients for multiple versions of the Web Security Scanner
99
.. toctree::
1010
:maxdepth: 2
1111

12-
gapic/v1beta/api
13-
gapic/v1beta/types
12+
websecurityscanner_v1beta/services
13+
websecurityscanner_v1beta/types
1414

1515
The previous alpha release, spelled ``v1alpha`` is provided to continue to support code previously written against it. In order to use it, you will want to import from it e.g., ``google.cloud.websecurityscanner_v1alpha`` in lieu of ``google.cloud.websecurityscanner`` (or the equivalent ``google.cloud.websecurityscanner_v1beta``).
1616

@@ -19,8 +19,19 @@ v1alpha
1919
.. toctree::
2020
:maxdepth: 2
2121

22-
gapic/v1alpha/api
23-
gapic/v1alpha/types
22+
websecurityscanner_v1alpha/services
23+
websecurityscanner_v1alpha/types
24+
25+
26+
Migration Guide
27+
---------------
28+
29+
See the guide below for instructions on migrating to the 1.x release of this library.
30+
31+
.. toctree::
32+
:maxdepth: 2
33+
34+
UPGRADING
2435

2536

2637
Changelog
@@ -31,4 +42,4 @@ For a list of all ``google-cloud-websecurityscanner`` releases.
3142
.. toctree::
3243
:maxdepth: 2
3344

34-
changelog
45+
changelog
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Websecurityscanner v1alpha API
2+
========================================================
3+
4+
.. automodule:: google.cloud.websecurityscanner_v1alpha.services.web_security_scanner
5+
:members:
6+
:inherited-members:

0 commit comments

Comments
 (0)