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

Commit 4196032

Browse files
feat!: migrate to use microgen (#44)
* feat!: migrate to use microgen * update * fix lint
1 parent 538071b commit 4196032

File tree

97 files changed

+20530
-11886
lines changed

Some content is hidden

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

97 files changed

+20530
-11886
lines changed

.coveragerc

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

README.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ 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-secret-manager==1.0.0.
60+
61+
5162
Mac/Linux
5263
^^^^^^^^^
5364

UPGRADING.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-secret-manager` 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-secret-manager/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-secret-manager
24+
```
25+
26+
* The script `fixup_secretmanager_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_secretmanager_v1_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import secretmanager_v1
36+
37+
client = secretmanager_v1.SecretManagerServiceClient()
38+
39+
secret = client.get_secret("secret_name")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud import secretmanager_v1
46+
47+
client = secretmanager_v1.SecretManagerServiceClient()
48+
49+
secret = client.get_secret(request={'name': "secret_name"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-secret-manager<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
55+
56+
**Before:**
57+
```py
58+
def create_secret(
59+
self,
60+
parent,
61+
secret_id,
62+
secret,
63+
retry=google.api_core.gapic_v1.method.DEFAULT,
64+
timeout=google.api_core.gapic_v1.method.DEFAULT,
65+
metadata=None,
66+
):
67+
```
68+
69+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
70+
71+
Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer.
72+
73+
74+
**After:**
75+
```py
76+
def create_secret(
77+
self,
78+
request: service.CreateSecretRequest = None,
79+
*,
80+
parent: str = None,
81+
secret_id: str = None,
82+
secret: resources.Secret = None,
83+
retry: retries.Retry = gapic_v1.method.DEFAULT,
84+
timeout: float = None,
85+
metadata: Sequence[Tuple[str, str]] = (),
86+
) -> resources.Secret:
87+
```
88+
89+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
90+
> Passing both will result in an error.
91+
92+
93+
Both of these calls are valid:
94+
95+
```py
96+
response = client.create_secret(
97+
request={
98+
"parent": parent,
99+
"secret_id": secret_id,
100+
"secret": secret
101+
}
102+
)
103+
```
104+
105+
```py
106+
response = client.create_secret(
107+
parent=parent,
108+
secret_id=secret_id,
109+
secret=secret
110+
)
111+
```
112+
113+
This call is invalid because it mixes `request` with a keyword argument `secret`. Executing this code
114+
will result in an error.
115+
116+
```py
117+
response = client.create_secret(
118+
request={
119+
"parent": parent,
120+
"secret_id": secret_id
121+
},
122+
secret=secret
123+
)
124+
```
125+
126+
127+
128+
## Enums and Types
129+
130+
131+
> **WARNING**: Breaking change
132+
133+
The submodules `enums` and `types` have been removed.
134+
135+
**Before:**
136+
```py
137+
from google.cloud import secretmanager_v1
138+
139+
secret_version = secretmanager_v1.enums.SecretVersion.ENABLED
140+
secret = secretmanager_v1.types.Secret(name="name")
141+
```
142+
143+
144+
**After:**
145+
```py
146+
from google.cloud import secretmanager_v1
147+
148+
secret_version = secretmanager_v1.SecretVersion.ENABLED
149+
secret = secretmanager_v1.Secret(name="name")
150+
```
151+
152+
## Path Helper Methods
153+
154+
The following path helper methods have been removed. Please construct
155+
the paths manually.
156+
157+
```py
158+
project = 'my-project'
159+
secret = 'secret'
160+
secret_version = 'secret_version'
161+
162+
project_path = f'projects/{project}'
163+
secret_version_path = f'projects/{project}/secrets/{secret}/versions/{secret_version}'
164+
```

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/v1/api.rst

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

docs/gapic/v1/types.rst

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

docs/gapic/v1beta1/api.rst

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

docs/gapic/v1beta1/types.rst

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

docs/index.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,26 @@ v1 Api Reference
77
.. toctree::
88
:maxdepth: 2
99

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

1313
v1beta1 Api Reference
1414
---------------------
1515
.. toctree::
1616
:maxdepth: 2
1717

18-
gapic/v1beta1/api
19-
gapic/v1beta1/types
18+
secretmanager_v1beta1/services
19+
secretmanager_v1beta1/types
20+
21+
Migration Guide
22+
---------------
23+
24+
See the guide below for instructions on migrating to the 2.x release of this library.
25+
26+
.. toctree::
27+
:maxdepth: 2
28+
29+
UPGRADING
2030

2131
Changelog
2232
---------

docs/secretmanager_v1/services.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Secretmanager v1 API
2+
==============================================
3+
4+
.. automodule:: google.cloud.secretmanager_v1.services.secret_manager_service
5+
:members:
6+
:inherited-members:

0 commit comments

Comments
 (0)