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

Commit 4077fc8

Browse files
feat: add support for external key manager (via synth) (#8)
This PR was generated using Autosynth. 🌈 <details><summary>Log from Synthtool</summary> ``` 2020-04-09 05:17:46,671 synthtool > Executing /tmpfs/src/git/autosynth/working_repo/synth.py. On branch autosynth nothing to commit, working tree clean 2020-04-09 05:17:46,744 synthtool > Ensuring dependencies. 2020-04-09 05:17:46,749 synthtool > Pulling artman image. latest: Pulling from googleapis/artman fe703b657a32: Pulling fs layer f9df1fafd224: Pulling fs layer a645a4b887f9: Pulling fs layer 57db7fe0b522: Pulling fs layer 21813e587ee0: Pulling fs layer c1a422e3936c: Pulling fs layer 7896fdb9a0c9: Pulling fs layer 0de4b0ae0d3f: Pulling fs layer 01bd40777c31: Pulling fs layer 56b5bb33902f: Pulling fs layer 1614ad0d8336: Pulling fs layer 1966fa070a3e: Pulling fs layer bdec75005236: Pulling fs layer 926959728054: Pulling fs layer 6336bbde4243: Pulling fs layer 528525f78682: Pulling fs layer e563a20cd63b: Pulling fs layer 5c8b90802b46: Pulling fs layer 1779990e45c7: Pulling fs layer b5fe0cb05c88: Pulling fs layer 09523ca76318: Pulling fs layer a097eb4cee97: Pulling fs layer 45a97578bd37: Pulling fs layer 1abced54aff8: Pulling fs layer 32448d22ea50: Pulling fs layer cca4a4de1600: Pulling fs layer bd1b621d3208: Pulling fs layer 690f3c005fd3: Pulling fs layer 7896fdb9a0c9: Waiting 0de4b0ae0d3f: Waiting 01bd40777c31: Waiting 56b5bb33902f: Waiting 1614ad0d8336: Waiting 1966fa070a3e: Waiting bdec75005236: Waiting 926959728054: Waiting 57db7fe0b522: Waiting 21813e587ee0: Waiting c1a422e3936c: Waiting 6336bbde4243: Waiting 528525f78682: Waiting e563a20cd63b: Waiting 5c8b90802b46: Waiting 1779990e45c7: Waiting b5fe0cb05c88: Waiting 09523ca76318: Waiting a097eb4cee97: Waiting 45a97578bd37: Waiting 1abced54aff8: Waiting 32448d22ea50: Waiting cca4a4de1600: Waiting bd1b621d3208: Waiting 690f3c005fd3: Waiting a645a4b887f9: Download complete f9df1fafd224: Verifying Checksum f9df1fafd224: Download complete 57db7fe0b522: Verifying Checksum 57db7fe0b522: Download complete fe703b657a32: Verifying Checksum fe703b657a32: Download complete 21813e587ee0: Verifying Checksum 21813e587ee0: Download complete 7896fdb9a0c9: Verifying Checksum 7896fdb9a0c9: Download complete 0de4b0ae0d3f: Verifying Checksum 0de4b0ae0d3f: Download complete 56b5bb33902f: Verifying Checksum 56b5bb33902f: Download complete 01bd40777c31: Verifying Checksum 01bd40777c31: Download complete 1966fa070a3e: Verifying Checksum 1966fa070a3e: Download complete 1614ad0d8336: Verifying Checksum 1614ad0d8336: Download complete 926959728054: Verifying Checksum 926959728054: Download complete c1a422e3936c: Verifying Checksum c1a422e3936c: Download complete 6336bbde4243: Verifying Checksum 6336bbde4243: Download complete fe703b657a32: Pull complete 528525f78682: Verifying Checksum 528525f78682: Download complete e563a20cd63b: Verifying Checksum e563a20cd63b: Download complete f9df1fafd224: Pull complete a645a4b887f9: Pull complete bdec75005236: Verifying Checksum bdec75005236: Download complete 57db7fe0b522: Pull complete 5c8b90802b46: Verifying Checksum 5c8b90802b46: Download complete 1779990e45c7: Verifying Checksum 1779990e45c7: Download complete 09523ca76318: Verifying Checksum 09523ca76318: Download complete 45a97578bd37: Verifying Checksum 45a97578bd37: Download complete 1abced54aff8: Verifying Checksum 1abced54aff8: Download complete 32448d22ea50: Verifying Checksum 32448d22ea50: Download complete 21813e587ee0: Pull complete b5fe0cb05c88: Verifying Checksum b5fe0cb05c88: Download complete cca4a4de1600: Download complete bd1b621d3208: Download complete 690f3c005fd3: Verifying Checksum 690f3c005fd3: Download complete c1a422e3936c: Pull complete 7896fdb9a0c9: Pull complete 0de4b0ae0d3f: Pull complete 01bd40777c31: Pull complete 56b5bb33902f: Pull complete a097eb4cee97: Verifying Checksum a097eb4cee97: Download complete 1614ad0d8336: Pull complete 1966fa070a3e: Pull complete bdec75005236: Pull complete 926959728054: Pull complete 6336bbde4243: Pull complete 528525f78682: Pull complete e563a20cd63b: Pull complete 5c8b90802b46: Pull complete 1779990e45c7: Pull complete b5fe0cb05c88: Pull complete 09523ca76318: Pull complete a097eb4cee97: Pull complete 45a97578bd37: Pull complete 1abced54aff8: Pull complete 32448d22ea50: Pull complete cca4a4de1600: Pull complete bd1b621d3208: Pull complete 690f3c005fd3: Pull complete Digest: sha256:ef1a5b367dbe1e37cea1c7c814c801a638473e8dd66f87f4a2b8c2a146013673 Status: Downloaded newer image for googleapis/artman:latest 2020-04-09 05:18:30,711 synthtool > Cloning googleapis. 2020-04-09 05:18:31,217 synthtool > Running generator for google/cloud/kms/artman_cloudkms.yaml. 2020-04-09 05:18:57,649 synthtool > Generated code into /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/python/kms-v1. 2020-04-09 05:18:57,650 synthtool > Copy: /home/kbuilder/.cache/synthtool/googleapis/google/cloud/kms/v1/service.proto to /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/python/kms-v1/google/cloud/kms_v1/proto/service.proto 2020-04-09 05:18:57,650 synthtool > Copy: /home/kbuilder/.cache/synthtool/googleapis/google/cloud/kms/v1/resources.proto to /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/python/kms-v1/google/cloud/kms_v1/proto/resources.proto 2020-04-09 05:18:57,650 synthtool > Placed proto files into /home/kbuilder/.cache/synthtool/googleapis/artman-genfiles/python/kms-v1/google/cloud/kms_v1/proto. 2020-04-09 05:18:57,679 synthtool > Replaced 'from google.iam.v1 import iam_policy_pb2' in google/cloud/kms_v1/gapic/transports/key_management_service_grpc_transport.py. .coveragerc .flake8 .github/CONTRIBUTING.md .github/ISSUE_TEMPLATE/bug_report.md .github/ISSUE_TEMPLATE/feature_request.md .github/ISSUE_TEMPLATE/support_request.md .github/PULL_REQUEST_TEMPLATE.md .github/release-please.yml .gitignore .kokoro/build.sh .kokoro/continuous/common.cfg .kokoro/continuous/continuous.cfg .kokoro/docs/common.cfg .kokoro/docs/docs.cfg .kokoro/presubmit/common.cfg .kokoro/presubmit/presubmit.cfg .kokoro/publish-docs.sh .kokoro/release.sh .kokoro/release/common.cfg .kokoro/release/release.cfg .kokoro/trampoline.sh CODE_OF_CONDUCT.md CONTRIBUTING.rst LICENSE MANIFEST.in docs/_static/custom.css docs/_templates/layout.html docs/conf.py.j2 noxfile.py.j2 renovate.json setup.cfg Running session blacken Creating virtual environment (virtualenv) using python3.6 in .nox/blacken pip install black==19.3b0 black docs google tests noxfile.py setup.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/__init__.py reformatted /tmpfs/src/git/autosynth/working_repo/google/__init__.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/__init__.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/gapic/enums.py reformatted /tmpfs/src/git/autosynth/working_repo/docs/conf.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/gapic/key_management_service_client_config.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/proto/resources_pb2_grpc.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/gapic/transports/key_management_service_grpc_transport.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/proto/service_pb2_grpc.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/types.py reformatted /tmpfs/src/git/autosynth/working_repo/noxfile.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/gapic/key_management_service_client.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/proto/resources_pb2.py reformatted /tmpfs/src/git/autosynth/working_repo/tests/unit/gapic/v1/test_key_management_service_client_v1.py reformatted /tmpfs/src/git/autosynth/working_repo/google/cloud/kms_v1/proto/service_pb2.py All done! ✨ 🍰 ✨ 16 files reformatted, 5 files left unchanged. Session blacken was successful. 2020-04-09 05:19:04,531 synthtool > Wrote metadata to synth.metadata. ``` </details>
1 parent d55ddd9 commit 4077fc8

File tree

16 files changed

+491
-356
lines changed

16 files changed

+491
-356
lines changed

.coveragerc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
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+
117
# Generated by synthtool. DO NOT EDIT!
218
[run]
319
branch = True

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
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+
117
# Generated by synthtool. DO NOT EDIT!
218
[flake8]
319
ignore = E203, E266, E501, W503

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Thanks for stopping by to let us know something could be better!
1111
Please run down the following list and make sure you've tried the usual "quick fixes":
1212

1313
- Search the issues already opened: https://github.com/googleapis/python-kms/issues
14-
- Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-python
15-
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+python
14+
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python
1615

1716
If you are still having issues, please be sure to include as much information as possible:
1817

CONTRIBUTING.rst

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions: 2.7,
25-
3.5, 3.6, and 3.7 on both UNIX and Windows.
25+
3.5, 3.6, 3.7 and 3.8 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should
@@ -214,26 +214,18 @@ We support:
214214
- `Python 3.5`_
215215
- `Python 3.6`_
216216
- `Python 3.7`_
217+
- `Python 3.8`_
217218

218219
.. _Python 3.5: https://docs.python.org/3.5/
219220
.. _Python 3.6: https://docs.python.org/3.6/
220221
.. _Python 3.7: https://docs.python.org/3.7/
222+
.. _Python 3.8: https://docs.python.org/3.8/
221223

222224

223225
Supported versions can be found in our ``noxfile.py`` `config`_.
224226

225227
.. _config: https://github.com/googleapis/python-kms/blob/master/noxfile.py
226228

227-
We explicitly decided not to support `Python 2.5`_ due to `decreased usage`_
228-
and lack of continuous integration `support`_.
229-
230-
.. _Python 2.5: https://docs.python.org/2.5/
231-
.. _decreased usage: https://caremad.io/2013/10/a-look-at-pypi-downloads/
232-
.. _support: https://blog.travis-ci.com/2013-11-18-upcoming-build-environment-updates/
233-
234-
We have `dropped 2.6`_ as a supported version as well since Python 2.6 is no
235-
longer supported by the core development team.
236-
237229
Python 2.7 support is deprecated. All code changes should maintain Python 2.7 compatibility until January 1, 2020.
238230

239231
We also explicitly decided to support Python 3 beginning with version
@@ -247,7 +239,6 @@ We also explicitly decided to support Python 3 beginning with version
247239
.. _prominent: https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
248240
.. _projects: http://flask.pocoo.org/docs/0.10/python3/
249241
.. _Unicode literal support: https://www.python.org/dev/peps/pep-0414/
250-
.. _dropped 2.6: https://github.com/googleapis/google-cloud-python/issues/995
251242

252243
**********
253244
Versioning

MANIFEST.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
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+
117
# Generated by synthtool. DO NOT EDIT!
218
include README.rst LICENSE
319
recursive-include google *.json *.proto

google/cloud/kms_v1/gapic/enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class CryptoKeyVersionAlgorithm(enum.IntEnum):
114114
RSA_DECRYPT_OAEP_4096_SHA512 (int): RSAES-OAEP 4096 bit key with a SHA512 digest.
115115
EC_SIGN_P256_SHA256 (int): ECDSA on the NIST P-256 curve with a SHA256 digest.
116116
EC_SIGN_P384_SHA384 (int): ECDSA on the NIST P-384 curve with a SHA384 digest.
117+
EXTERNAL_SYMMETRIC_ENCRYPTION (int): Algorithm representing symmetric encryption by an external key manager.
117118
"""
118119

119120
CRYPTO_KEY_VERSION_ALGORITHM_UNSPECIFIED = 0
@@ -132,6 +133,7 @@ class CryptoKeyVersionAlgorithm(enum.IntEnum):
132133
RSA_DECRYPT_OAEP_4096_SHA512 = 17
133134
EC_SIGN_P256_SHA256 = 12
134135
EC_SIGN_P384_SHA384 = 13
136+
EXTERNAL_SYMMETRIC_ENCRYPTION = 18
135137

136138
class CryptoKeyVersionState(enum.IntEnum):
137139
"""

google/cloud/kms_v1/gapic/key_management_service_client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path):
117117
def crypto_key_version_path(
118118
cls, project, location, key_ring, crypto_key, crypto_key_version
119119
):
120+
120121
"""Return a fully-qualified crypto_key_version string."""
121122
return google.api_core.path_template.expand(
122123
"projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}",
@@ -1676,7 +1677,8 @@ def encrypt(
16761677
>>>
16771678
>>> client = kms_v1.KeyManagementServiceClient()
16781679
>>>
1679-
>>> name = client.crypto_key_path_path('[PROJECT]', '[LOCATION]', '[KEY_RING]', '[CRYPTO_KEY_PATH]')
1680+
>>> # TODO: Initialize `name`:
1681+
>>> name = ''
16801682
>>>
16811683
>>> # TODO: Initialize `plaintext`:
16821684
>>> plaintext = b''
@@ -2320,7 +2322,8 @@ def set_iam_policy(
23202322
>>>
23212323
>>> client = kms_v1.KeyManagementServiceClient()
23222324
>>>
2323-
>>> resource = client.key_ring_path('[PROJECT]', '[LOCATION]', '[KEY_RING]')
2325+
>>> # TODO: Initialize `resource`:
2326+
>>> resource = ''
23242327
>>>
23252328
>>> # TODO: Initialize `policy`:
23262329
>>> policy = {}
@@ -2402,7 +2405,8 @@ def get_iam_policy(
24022405
>>>
24032406
>>> client = kms_v1.KeyManagementServiceClient()
24042407
>>>
2405-
>>> resource = client.key_ring_path('[PROJECT]', '[LOCATION]', '[KEY_RING]')
2408+
>>> # TODO: Initialize `resource`:
2409+
>>> resource = ''
24062410
>>>
24072411
>>> response = client.get_iam_policy(resource)
24082412
@@ -2486,7 +2490,8 @@ def test_iam_permissions(
24862490
>>>
24872491
>>> client = kms_v1.KeyManagementServiceClient()
24882492
>>>
2489-
>>> resource = client.key_ring_path('[PROJECT]', '[LOCATION]', '[KEY_RING]')
2493+
>>> # TODO: Initialize `resource`:
2494+
>>> resource = ''
24902495
>>>
24912496
>>> # TODO: Initialize `permissions`:
24922497
>>> permissions = []

google/cloud/kms_v1/proto/resources.proto

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2020 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@ syntax = "proto3";
1616

1717
package google.cloud.kms.v1;
1818

19-
import "google/api/annotations.proto";
2019
import "google/api/field_behavior.proto";
2120
import "google/api/resource.proto";
2221
import "google/protobuf/duration.proto";
2322
import "google/protobuf/timestamp.proto";
23+
import "google/api/annotations.proto";
2424

2525
option cc_enable_arenas = true;
2626
option csharp_namespace = "Google.Cloud.Kms.V1";
@@ -142,11 +142,6 @@ message CryptoKey {
142142
map<string, string> labels = 10;
143143
}
144144

145-
option (google.api.resource_definition) = {
146-
type: "cloudkms.googleapis.com/CryptoKey"
147-
pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}"
148-
};
149-
150145
// A [CryptoKeyVersionTemplate][google.cloud.kms.v1.CryptoKeyVersionTemplate] specifies the properties to use when creating
151146
// a new [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion], either manually with
152147
// [CreateCryptoKeyVersion][google.cloud.kms.v1.KeyManagementService.CreateCryptoKeyVersion] or
@@ -289,6 +284,9 @@ message CryptoKeyVersion {
289284

290285
// ECDSA on the NIST P-384 curve with a SHA384 digest.
291286
EC_SIGN_P384_SHA384 = 13;
287+
288+
// Algorithm representing symmetric encryption by an external key manager.
289+
EXTERNAL_SYMMETRIC_ENCRYPTION = 18;
292290
}
293291

294292
// The state of a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion], indicating if it can be used.
@@ -395,11 +393,21 @@ message CryptoKeyVersion {
395393
// [state][google.cloud.kms.v1.CryptoKeyVersion.state] is
396394
// [IMPORT_FAILED][google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.IMPORT_FAILED].
397395
string import_failure_reason = 16 [(google.api.field_behavior) = OUTPUT_ONLY];
396+
397+
// ExternalProtectionLevelOptions stores a group of additional fields for
398+
// configuring a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] that are specific to the
399+
// [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL] protection level.
400+
ExternalProtectionLevelOptions external_protection_level_options = 17;
398401
}
399402

400403
// The public key for a given [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion]. Obtained via
401404
// [GetPublicKey][google.cloud.kms.v1.KeyManagementService.GetPublicKey].
402405
message PublicKey {
406+
option (google.api.resource) = {
407+
type: "cloudkms.googleapis.com/PublicKey"
408+
pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey"
409+
};
410+
403411
// The public key, encoded in PEM format. For more information, see the
404412
// [RFC 7468](https://tools.ietf.org/html/rfc7468) sections for
405413
// [General Considerations](https://tools.ietf.org/html/rfc7468#section-2) and
@@ -565,3 +573,11 @@ enum ProtectionLevel {
565573
// Crypto operations are performed by an external key manager.
566574
EXTERNAL = 3;
567575
}
576+
577+
// ExternalProtectionLevelOptions stores a group of additional fields for
578+
// configuring a [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] that are specific to the
579+
// [EXTERNAL][google.cloud.kms.v1.ProtectionLevel.EXTERNAL] protection level.
580+
message ExternalProtectionLevelOptions {
581+
// The URI for an external resource that this [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] represents.
582+
string external_key_uri = 1;
583+
}

0 commit comments

Comments
 (0)