migrate code from googleapis/python-kms by rsamborski · Pull Request #8470 · GoogleCloudPlatform/python-docs-samples

@product-auto-label bot added the samples

Issues that are directly related to samples.

label

Nov 8, 2022

rsamborski

dandhlee

chalmerlowe

dandhlee

* Draft of first half of KMS samples

* reversed wrong change

* KMS Apiary Python samples - P1

* Few minor style issues

* Adding back in space i accidentally deleted

* Addressed all code review comments

* Renamed api directory to api-client

* Addressed more code review comments

* Formatting change

* Fix quickstart test

Change-Id: Ib79dc1345c9c40547f3fd4e9c3c9a48963a3b399

* Update readme

Change-Id: Icf4a66083f56d6f51be76ba1cf3b5dc8daf2c4c1

* Add readme

Change-Id: I2fbaa55092ef8787f1423d499aa310cab258c0c1

* Added parsers

* Final minor changes to parsers

* Added autogenerated README

* Changed snippets_test keyring name and cryptokey name
* random generation of keyring / cryptokey names

* Fixed formatting of keyring name and cryptokey name

@dpebot @rsamborski

@rsamborski

@philcoakley @rsamborski

* Remove cloud config fixture

* Fix client secrets

* Fix bigtable instance

@rsamborski

)](#1074)

The use of base64 is essentially an implementation detail of the Cloud KMS REST
API: it is required only so that arbitrary binary data can be included in a JSON
string, which only allows Unicode characters. Therefore, the "encrypt" sample
function should decode the base64-encoded ciphertext before writing the
file. Similarly, "decrypt" should not assume that an input file is
base64-encoded, but should perform the base64-encoding itself before sending the
encrypted data to KMS.

This aligns with how the "gcloud kms encrypt" and "gcloud kms decrypt" commands
behave. See https://stackoverflow.com/q/45699472 for an example of user
confusion caused by the mismatch.
…1075)

In particular, this change:
- changes to use a consistent "_id" suffix for resource name components
- uses "data" instead of "text", since encryption is not restricted to text
- substitutes "ciphertext" for "encrypted {text, data}"
- spells "crypto key" and "key ring" each as two separate words, as in the API

Tracking bug: http://b/64758639
* Auto-update dependencies.

* Relax assertions in the ocr_nl sample

Change-Id: I6d37e5846a8d6dd52429cb30d501f448c52cbba1

* Drop unused logging apiary samples

Change-Id: I545718283773cb729a5e0def8a76ebfa40829d51
Change-Id: I03b5eaef8b17ac3dc3c0339fd2c7447bd3e11bd2
* Auto-update dependencies.

* Fix missing http library

Change-Id: I99faa600f2f3f1f50f57694fc9835d7f35bda250

@renovate-bot @rsamborski

@renovate-bot @rsamborski

* chore(python): drop python 3.6

Source-Link: googleapis/synthtool@4f89b13
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c

* add api_description to .repo-metadata.json

* require python 3.7+ in setup.py

* remove python 3.6 sample configs

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>

@renovate-bot @rsamborski

@renovate-bot @rsamborski

@renovate-bot @rsamborski

@renovate-bot @rsamborski

Source-Link: googleapis/synthtool@50db768
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978

@renovate-bot @rsamborski

@renovate-bot @rsamborski

@renovate-bot @rsamborski

@rsamborski

@rsamborski

@rsamborski

@rsamborski

@rsamborski

@rsamborski

@rsamborski

@rsamborski

dandhlee

@rsamborski

dandhlee