Skip to content

Commit 86fc579

Browse files
authored
feat!: migrate to microgenerator. (#16)
1 parent b16ebac commit 86fc579

File tree

86 files changed

+18138
-11308
lines changed

Some content is hidden

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

86 files changed

+18138
-11308
lines changed

packages/google-cloud-kms/.coveragerc

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# Generated by synthtool. DO NOT EDIT!
1817
[run]
1918
branch = True
2019

2120
[report]
2221
fail_under = 100
2322
show_missing = True
23+
omit =
24+
google/cloud/kms/__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

packages/google-cloud-kms/README.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ dependencies.
5151

5252
Supported Python Versions
5353
^^^^^^^^^^^^^^^^^^^^^^^^^
54-
Python >= 3.5
54+
Python >= 3.6
5555

5656
Deprecated Python Versions
5757
^^^^^^^^^^^^^^^^^^^^^^^^^^
58-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
58+
Python == 2.7.
59+
60+
The last version of this library compatible with Python 2.7 is google-cloud-kms==1.4.0.
5961

6062

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

packages/google-cloud-kms/docs/_templates/layout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
<div class="body" role="main">
2323
<div class="admonition" id="python2-eol">
24-
On January 1, 2020 this library will no longer support Python 2 on the latest released version.
25-
Previously released library versions will continue to be available. For more information please
24+
As of January 1, 2020 this library no longer supports Python 2 on the latest released version.
25+
Library versions released prior to that date will continue to be available. For more information please
2626
visit <a href="https://cloud.google.com/python/docs/python2-sunset/">Python 2 support on Google Cloud</a>.
2727
</div>
2828
{% block body %} {% endblock %}

packages/google-cloud-kms/docs/conf.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,18 @@
3838
"sphinx.ext.napoleon",
3939
"sphinx.ext.todo",
4040
"sphinx.ext.viewcode",
41+
"recommonmark",
4142
]
4243

4344
# autodoc/autosummary flags
4445
autoclass_content = "both"
45-
autodoc_default_flags = ["members"]
46+
autodoc_default_options = {"members": True}
4647
autosummary_generate = True
4748

4849

4950
# Add any paths that contain templates here, relative to this directory.
5051
templates_path = ["_templates"]
5152

52-
# Allow markdown includes (so releases.md can include CHANGLEOG.md)
53-
# http://www.sphinx-doc.org/en/master/markdown.html
54-
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
55-
5653
# The suffix(es) of source filenames.
5754
# You can specify multiple suffix as a list of string:
5855
# source_suffix = ['.rst', '.md']
@@ -293,7 +290,7 @@
293290
# One entry per manual page. List of tuples
294291
# (source start file, name, description, authors, manual section).
295292
man_pages = [
296-
(master_doc, "google-cloud-kms", u"google-cloud-kms Documentation", [author], 1)
293+
(master_doc, "google-cloud-kms", u"google-cloud-kms Documentation", [author], 1,)
297294
]
298295

299296
# If true, show URL addresses after external links.
@@ -334,7 +331,7 @@
334331
intersphinx_mapping = {
335332
"python": ("http://python.readthedocs.org/en/latest/", None),
336333
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
337-
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None),
334+
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
338335
"grpc": ("https://grpc.io/grpc/python/", None),
339336
}
340337

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

-6
This file was deleted.

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

-5
This file was deleted.

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

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

10-
gapic/v1/api
11-
gapic/v1/types
10+
kms_v1/services
11+
kms_v1/types
12+
13+
14+
Migration Guide
15+
---------------
16+
17+
See the guide below for instructions on migrating to the 2.x release of this library.
18+
19+
.. toctree::
20+
:maxdepth: 2
21+
22+
UPGRADING
1223

1324

1425
Changelog
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Kms v1 API
2+
====================================
3+
4+
.. automodule:: google.cloud.kms_v1.services.key_management_service
5+
:members:
6+
:inherited-members:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Kms v1 API
2+
=================================
3+
4+
.. automodule:: google.cloud.kms_v1.types
5+
:members:

packages/google-cloud-kms/google/cloud/kms.py

-25
This file was deleted.

0 commit comments

Comments
 (0)