Skip to content

Commit 0bcae3c

Browse files
authored
feat!: move to microgen (#33)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-containeranalysis/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent 3a705e1 commit 0bcae3c

Some content is hidden

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

46 files changed

+3918
-1544
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
1-
# -*- coding: utf-8 -*-
2-
#
3-
# Copyright 2020 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-
# Generated by synthtool. DO NOT EDIT!
181
[run]
192
branch = True
203

214
[report]
225
fail_under = 100
236
show_missing = True
7+
omit = google/cloud/devtools/containeranalysis/__init__.py
248
exclude_lines =
259
# Re-enable the standard pragma
2610
pragma: NO COVER
2711
# Ignore debug-only repr
2812
def __repr__
29-
# Ignore abstract methods
30-
raise NotImplementedError
31-
omit =
32-
*/gapic/*.py
33-
*/proto/*.py
34-
*/core/*.py
35-
*/site-packages/*.py
13+
# Ignore pkg_resources exceptions.
14+
# This is added at the module level as a safeguard for if someone
15+
# generates the code and tries to run it without pip installing. This
16+
# makes it virtually impossible to test properly.
17+
except pkg_resources.DistributionNotFound

packages/google-cloud-containeranalysis/README.rst

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ dependencies.
4848
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
4949

5050

51+
Supported Python Versions
52+
^^^^^^^^^^^^^^^^^^^^^^^^^
53+
Python >= 3.6
54+
55+
Deprecated Python Versions
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
Python == 2.7.
58+
59+
The last version of this library compatible with Python 2.7 is google-cloud-containeranalysis==1.0.2.
60+
5161
Mac/Linux
5262
^^^^^^^^^
5363

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-containeranalysis` 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-containeranalysis/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 2.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-containeranalysis
24+
```
25+
26+
* The script `fixup_containeranalysis_v1_keywords.py` is shipped with the library. It expects
27+
an input directory (with the code to convert) and an empty destination directory.
28+
29+
```sh
30+
$ fixup_containeranalysis_v1_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud.devtools import containeranalysis_v1
36+
37+
client = containeranalysis_v1.ContainerAnalysisClient()
38+
resource = "projects/[PROJECT_ID]/notes/[NOTE_ID]"
39+
policy = client.get_iam_policy(resource)
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud.devtools import containeranalysis_v1
46+
47+
client = containeranalysis_v1.ContainerAnalysisClient()
48+
request = {"resource": "projects/[PROJECT_ID]/notes/[NOTE_ID]"}
49+
policy = client.get_iam_policy(request=request)
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-containeranalysis<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
55+
56+
**Before:**
57+
```py
58+
def get_iam_policy(
59+
self,
60+
resource,
61+
options_=None,
62+
retry=google.api_core.gapic_v1.method.DEFAULT,
63+
timeout=google.api_core.gapic_v1.method.DEFAULT,
64+
metadata=None,
65+
):
66+
```
67+
68+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
69+
70+
Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/b77cacf1ed06e0301a39d6328b599e24102f04be/google/devtools/containeranalysis/v1/containeranalysis.proto#L67) specified by the API producer.
71+
72+
73+
**After:**
74+
```py
75+
def get_iam_policy(
76+
self,
77+
request: iam_policy.GetIamPolicyRequest = None,
78+
*,
79+
resource: str = None,
80+
retry: retries.Retry = gapic_v1.method.DEFAULT,
81+
timeout: float = None,
82+
metadata: Sequence[Tuple[str, str]] = (),
83+
) -> policy.Policy:
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.test_iam_permissions(
94+
request={
95+
"resource": resource,
96+
"permissions": permissions,
97+
}
98+
)
99+
```
100+
101+
```py
102+
response = client.test_iam_permissions(
103+
resource=resource,
104+
permissions=permissions,
105+
)
106+
```
107+
108+
This call is invalid because it mixes `request` with a keyword argument `permissions`. Executing this code
109+
will result in an error.
110+
111+
```py
112+
response = client.test_iam_permissions(
113+
request={
114+
"resource": resource,
115+
},
116+
permissions=permissions
117+
)
118+
```
119+
120+
121+
122+
## Enums and Types
123+
124+
125+
> **WARNING**: Breaking change
126+
127+
The submodule `types` has been removed.
128+
129+
**Before:**
130+
```py
131+
from google.cloud.devtools import containeranalysis_v1
132+
133+
audit_config = containeranalysis_v1.types.AuditConfigDelta()
134+
```
135+
136+
137+
**After:**
138+
```py
139+
from google.cloud.devtools import containeranalysis_v1
140+
141+
audit_config = containeranalysis_v1.AuditConfigDelta()
142+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Devtools Containeranalysis v1 API
2+
===========================================================
3+
4+
.. automodule:: google.cloud.devtools.containeranalysis_v1.services.container_analysis
5+
:members:
6+
:inherited-members:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Devtools Containeranalysis v1 API
2+
========================================================
3+
4+
.. automodule:: google.cloud.devtools.containeranalysis_v1.types
5+
:members:

packages/google-cloud-containeranalysis/docs/gapic/v1/api.rst

-6
This file was deleted.

packages/google-cloud-containeranalysis/docs/gapic/v1/types.rst

-5
This file was deleted.

packages/google-cloud-containeranalysis/docs/index.rst

+13-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Api Reference
77
.. toctree::
88
:maxdepth: 2
99

10-
gapic/v1/api
11-
gapic/v1/types
10+
containeranalysis_v1/services
11+
containeranalysis_v1/types
1212

1313

1414
Changelog
@@ -19,4 +19,14 @@ For all previous ``google-cloud-containeranalysis`` releases:
1919
.. toctree::
2020
:maxdepth: 2
2121

22-
changelog
22+
changelog
23+
24+
Migration Guide
25+
---------------
26+
27+
See the guide below for instructions on migrating to the 2.x release of this library.
28+
29+
.. toctree::
30+
:maxdepth: 2
31+
32+
UPGRADING

packages/google-cloud-containeranalysis/google/cloud/containeranalysis_v1/proto/containeranalysis.proto

-100
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2020 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+
# http://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+
18+
from google.cloud.devtools.containeranalysis_v1.services.container_analysis.async_client import (
19+
ContainerAnalysisAsyncClient,
20+
)
21+
from google.cloud.devtools.containeranalysis_v1.services.container_analysis.client import (
22+
ContainerAnalysisClient,
23+
)
24+
25+
__all__ = (
26+
"ContainerAnalysisAsyncClient",
27+
"ContainerAnalysisClient",
28+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Marker file for PEP 561.
2+
# The google-cloud-devtools-containeranalysis package uses inline types.

0 commit comments

Comments
 (0)