Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial Secret Manager samples #2664

Merged
merged 6 commits into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 395 additions & 0 deletions secretmanager/api-client/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,395 @@
.. This file is automatically generated. Do not edit this file directly.

Google Secret Manager Python Samples
===============================================================================

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/README.rst


This directory contains samples for Google Secret Manager. `Google Secret Manager` is a service that allows you to store, manage, and secure access to application secrets.




.. _Google Secret Manager: https://cloud.google.com/secret-manager

Setup
-------------------------------------------------------------------------------


Authentication
++++++++++++++

This sample requires you to have authentication setup. Refer to the
`Authentication Getting Started Guide`_ for instructions on setting up
credentials for applications.

.. _Authentication Getting Started Guide:
https://cloud.google.com/docs/authentication/getting-started

Install Dependencies
++++++++++++++++++++

#. Clone python-docs-samples and change directory to the sample directory you want to use.

.. code-block:: bash

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions.

.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.

.. code-block:: bash

$ virtualenv env
$ source env/bin/activate

#. Install the dependencies needed to run the samples.

.. code-block:: bash

$ pip install -r requirements.txt

.. _pip: https://pip.pypa.io/
.. _virtualenv: https://virtualenv.pypa.io/

Samples
-------------------------------------------------------------------------------

Quickstart
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/quickstart.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python quickstart.py


Access Secret Version
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/access_secret_version.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python access_secret_version.py

usage: access_secret_version.py [-h] project_id secret_id version_id

command line application and sample code for accessing a secret version.

positional arguments:
project_id id of the GCP project
secret_id id of the secret to access
version_id version to access

optional arguments:
-h, --help show this help message and exit



Add Secret Version
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/add_secret_version.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python add_secret_version.py

usage: add_secret_version.py [-h] project_id secret_id payload

command line application and sample code for adding a secret version with the
specified payload to an existing secret.

positional arguments:
project_id id of the GCP project
secret_id id of the secret in which to add
payload secret material payload

optional arguments:
-h, --help show this help message and exit



Create Secret
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/create_secret.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python create_secret.py

usage: create_secret.py [-h] project_id secret_id

command line application and sample code for creating a new secret.

positional arguments:
project_id id of the GCP project
secret_id id of the secret to create

optional arguments:
-h, --help show this help message and exit



Delete Secret
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/delete_secret.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python delete_secret.py

usage: delete_secret.py [-h] project_id secret_id

command line application and sample code for deleting an existing secret.

positional arguments:
project_id id of the GCP project
secret_id id of the secret to delete

optional arguments:
-h, --help show this help message and exit



Destroy Secret Version
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/destroy_secret_version.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python destroy_secret_version.py

usage: destroy_secret_version.py [-h] project_id secret_id version_id

command line application and sample code for destroying a secret verison.

positional arguments:
project_id id of the GCP project
secret_id id of the secret from which to act
version_id id of the version to destroy

optional arguments:
-h, --help show this help message and exit



Enable Secret Version
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/enable_secret_version.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python enable_secret_version.py

usage: enable_secret_version.py [-h] project_id secret_id version_id

command line application and sample code for enabling a secret version.

positional arguments:
project_id id of the GCP project
secret_id id of the secret from which to act
version_id id of the version to enable

optional arguments:
-h, --help show this help message and exit



Get Secret Version
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/get_secret_version.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python get_secret_version.py

usage: get_secret_version.py [-h] project_id secret_id version_id

command line application and sample code for getting metdata about a secret
version, but not the secret payload.

positional arguments:
project_id id of the GCP project
secret_id id of the secret from which to act
version_id id of the version to get

optional arguments:
-h, --help show this help message and exit



Get Secret
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/get_secret.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python get_secret.py

usage: get_secret.py [-h] project_id secret_id

command line application and sample code for getting metadata about a secret.

positional arguments:
project_id id of the GCP project
secret_id id of the secret to get

optional arguments:
-h, --help show this help message and exit



List Secret Versions
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/list_secret_versions.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python list_secret_versions.py

usage: list_secret_versions.py [-h] project_id secret_id

command line application and sample code for listing secret versions of a
secret.

positional arguments:
project_id id of the GCP project
secret_id id of the secret in which to list

optional arguments:
-h, --help show this help message and exit



List Secrets
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/list_secrets.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python list_secrets.py

usage: list_secrets.py [-h] project_id

command line application and sample code for listing secrets in a project.

positional arguments:
project_id id of the GCP project

optional arguments:
-h, --help show this help message and exit



Update Secret
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. image:: https://gstatic.com/cloudssh/images/open-btn.png
:target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=secretmanager/api-client/update_secret.py,secretmanager/api-client/README.rst




To run this sample:

.. code-block:: bash

$ python update_secret.py

usage: update_secret.py [-h] --secret-id SECRET_ID project_id

positional arguments:
project_id id of the GCP project

optional arguments:
-h, --help show this help message and exit
--secret-id SECRET_ID





.. _Google Cloud SDK: https://cloud.google.com/sdk/
Loading