|
| 1 | +.. This file is automatically generated. Do not edit this file directly. |
| 2 | +
|
| 3 | +Google Secret Manager Python Samples |
| 4 | +=============================================================================== |
| 5 | + |
| 6 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 7 | + :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 |
| 8 | + |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +.. _Google Secret Manager: https://cloud.google.com/secret-manager |
| 16 | + |
| 17 | +Setup |
| 18 | +------------------------------------------------------------------------------- |
| 19 | + |
| 20 | + |
| 21 | +Authentication |
| 22 | +++++++++++++++ |
| 23 | + |
| 24 | +This sample requires you to have authentication setup. Refer to the |
| 25 | +`Authentication Getting Started Guide`_ for instructions on setting up |
| 26 | +credentials for applications. |
| 27 | + |
| 28 | +.. _Authentication Getting Started Guide: |
| 29 | + https://cloud.google.com/docs/authentication/getting-started |
| 30 | + |
| 31 | +Install Dependencies |
| 32 | +++++++++++++++++++++ |
| 33 | + |
| 34 | +#. Clone python-docs-samples and change directory to the sample directory you want to use. |
| 35 | + |
| 36 | + .. code-block:: bash |
| 37 | +
|
| 38 | + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git |
| 39 | +
|
| 40 | +#. 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. |
| 41 | + |
| 42 | + .. _Python Development Environment Setup Guide: |
| 43 | + https://cloud.google.com/python/setup |
| 44 | + |
| 45 | +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. |
| 46 | + |
| 47 | + .. code-block:: bash |
| 48 | +
|
| 49 | + $ virtualenv env |
| 50 | + $ source env/bin/activate |
| 51 | +
|
| 52 | +#. Install the dependencies needed to run the samples. |
| 53 | + |
| 54 | + .. code-block:: bash |
| 55 | +
|
| 56 | + $ pip install -r requirements.txt |
| 57 | +
|
| 58 | +.. _pip: https://pip.pypa.io/ |
| 59 | +.. _virtualenv: https://virtualenv.pypa.io/ |
| 60 | + |
| 61 | +Samples |
| 62 | +------------------------------------------------------------------------------- |
| 63 | + |
| 64 | +Quickstart |
| 65 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 66 | + |
| 67 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 68 | + :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,secretman
A3D4
ager/api-client/README.rst |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | +To run this sample: |
| 74 | + |
| 75 | +.. code-block:: bash |
| 76 | +
|
| 77 | + $ python quickstart.py |
| 78 | +
|
| 79 | +
|
| 80 | +Access Secret Version |
| 81 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 82 | + |
| 83 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 84 | + :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 |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +To run this sample: |
| 90 | + |
| 91 | +.. code-block:: bash |
| 92 | +
|
| 93 | + $ python access_secret_version.py |
| 94 | +
|
| 95 | + usage: access_secret_version.py [-h] project_id secret_id version_id |
| 96 | +
|
| 97 | + command line application and sample code for accessing a secret version. |
| 98 | +
|
| 99 | + positional arguments: |
| 100 | + project_id id of the GCP project |
| 101 | + secret_id id of the secret to access |
| 102 | + version_id version to access |
| 103 | +
|
| 104 | + optional arguments: |
| 105 | + -h, --help show this help message and exit |
| 106 | +
|
| 107 | +
|
| 108 | +
|
| 109 | +Add Secret Version |
| 110 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 111 | + |
| 112 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 113 | + :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 |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +To run this sample: |
| 119 | + |
| 120 | +.. code-block:: bash |
| 121 | +
|
| 122 | + $ python add_secret_version.py |
| 123 | +
|
| 124 | + usage: add_secret_version.py [-h] project_id secret_id payload |
| 125 | +
|
| 126 | + command line application and sample code for adding a secret version with the |
| 127 | + specified payload to an existing secret. |
| 128 | +
|
| 129 | + positional arguments: |
| 130 | + project_id id of the GCP project |
| 131 | + secret_id id of the secret in which to add |
| 132 | + payload secret material payload |
| 133 | +
|
| 134 | + optional arguments: |
| 135 | + -h, --help show this help message and exit |
| 136 | +
|
| 137 | +
|
| 138 | +
|
| 139 | +Create Secret |
| 140 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 141 | + |
| 142 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 143 | + :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 |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | +To run this sample: |
| 149 | + |
| 150 | +.. code-block:: bash |
| 151 | +
|
| 152 | + $ python create_secret.py |
| 153 | +
|
| 154 | + usage: create_secret.py [-h] project_id secret_id |
| 155 | +
|
| 156 | + command line application and sample code for creating a new secret. |
| 157 | +
|
| 158 | + positional arguments: |
| 159 | + project_id id of the GCP project |
| 160 | + secret_id id of the secret to create |
| 161 | +
|
| 162 | + optional arguments: |
| 163 | + -h, --help show this help message and exit |
| 164 | +
|
| 165 | +
|
| 166 | +
|
| 167 | +Delete Secret |
| 168 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 169 | + |
| 170 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 171 | + :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 |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | +To run this sample: |
| 177 | + |
| 178 | +.. code-block:: bash |
| 179 | +
|
| 180 | + $ python delete_secret.py |
| 181 | +
|
| 182 | + usage: delete_secret.py [-h] project_id secret_id |
| 183 | +
|
| 184 | + command line application and sample code for deleting an existing secret. |
| 185 | +
|
| 186 | + positional arguments: |
| 187 | + project_id id of the GCP project |
| 188 | + secret_id id of the secret to delete |
| 189 | +
|
| 190 | + optional arguments: |
| 191 | + -h, --help show this help message and exit |
| 192 | +
|
| 193 | +
|
| 194 | +
|
| 195 | +Destroy Secret Version |
| 196 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 197 | + |
| 198 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 199 | + :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 |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | +To run this sample: |
| 205 | + |
| 206 | +.. code-block:: bash |
| 207 | +
|
| 208 | + $ python destroy_secret_version.py |
| 209 | +
|
| 210 | + usage: destroy_secret_version.py [-h] project_id secret_id version_id |
| 211 | +
|
| 212 | + command line application and sample code for destroying a secret verison. |
| 213 | +
|
| 214 | + positional arguments: |
| 215 | + project_id id of the GCP project |
| 216 | + secret_id id of the secret from which to act |
| 217 | + version_id id of the version to destroy |
| 218 | +
|
| 219 | + optional arguments: |
| 220 | + -h, --help show this help message and exit |
| 221 | +
|
| 222 | +
|
| 223 | +
|
| 224 | +Enable Secret Version |
| 225 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 226 | + |
| 227 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 228 | + :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 |
| 229 | + |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | +To run this sample: |
| 234 | + |
| 235 | +.. code-block:: bash |
| 236 | +
|
| 237 | + $ python enable_secret_version.py |
| 238 | +
|
| 239 | + usage: enable_secret_version.py [-h] project_id secret_id version_id |
| 240 | +
|
| 241 | + command line application and sample code for enabling a secret version. |
| 242 | +
|
| 243 | + positional arguments: |
| 244 | + project_id id of the GCP project |
| 245 | + secret_id id of the secret from which to act |
| 246 | + version_id id of the version to enable |
| 247 | +
|
| 248 | + optional arguments: |
| 249 | + -h, --help show this help message and exit |
| 250 | +
|
| 251 | +
|
| 252 | +
|
| 253 | +Get Secret Version |
| 254 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 255 | + |
| 256 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 257 | + :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 |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | +To run this sample: |
| 263 | + |
| 264 | +.. code-block:: bash |
| 265 | +
|
| 266 | + $ python get_secret_version.py |
| 267 | +
|
| 268 | + usage: get_secret_version.py [-h] project_id secret_id version_id |
| 269 | +
|
| 270 | + command line application and sample code for getting metdata about a secret |
| 271 | + version, but not the secret payload. |
| 272 | +
|
| 273 | + positional arguments: |
| 274 | + project_id id of the GCP project |
| 275 | + secret_id id of the secret from which to act |
| 276 | + version_id id of the version to get |
| 277 | +
|
| 278 | + optional arguments: |
| 279 | + -h, --help show this help message and exit |
| 280 | +
|
| 281 | +
|
| 282 | +
|
| 283 | +Get Secret |
| 284 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 285 | + |
| 286 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 287 | + :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 |
| 288 | + |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | +To run this sample: |
| 293 | + |
| 294 | +.. code-block:: bash |
| 295 | +
|
| 296 | + $ python get_secret.py |
| 297 | +
|
| 298 | + usage: get_secret.py [-h] project_id secret_id |
| 299 | +
|
| 300 | + command line application and sample code for getting metadata about a secret. |
| 301 | +
|
| 302 | + positional arguments: |
| 303 | + project_id id of the GCP project |
| 304 | + secret_id id of the secret to get |
| 305 | +
|
| 306 | + optional arguments: |
| 307 | + -h, --help show this help message and exit |
| 308 | +
|
| 309 | +
|
| 310 | +
|
| 311 | +List Secret Versions |
| 312 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 313 | + |
| 314 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 315 | + :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 |
| 316 | + |
| 317 | + |
| 318 | + |
| 319 | + |
| 320 | +To run this sample: |
| 321 | + |
| 322 | +.. code-block:: bash |
| 323 | +
|
| 324 | + $ python list_secret_versions.py |
| 325 | +
|
| 326 | + usage: list_secret_versions.py [-h] project_id secret_id |
| 327 | +
|
| 328 | + command line application and sample code for listing secret versions of a |
| 329 | + secret. |
| 330 | +
|
| 331 | + positional arguments: |
| 332 | + project_id id of the GCP project |
| 333 | + secret_id id of the secret in which to list |
| 334 | +
|
| 335 | + optional arguments: |
| 336 | + -h, --help show this help message and exit |
| 337 | +
|
| 338 | +
|
| 339 | +
|
| 340 | +List Secrets |
| 341 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 342 | + |
| 343 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 344 | + :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 |
| 345 | + |
| 346 | + |
| 347 | + |
| 348 | + |
| 349 | +To run this sample: |
| 350 | + |
| 351 | +.. code-block:: bash |
| 352 | +
|
| 353 | + $ python list_secrets.py |
| 354 | +
|
| 355 | + usage: list_secrets.py [-h] project_id |
| 356 | +
|
| 357 | + command line application and sample code for listing secrets in a project. |
| 358 | +
|
| 359 | + positional arguments: |
| 360 | + project_id id of the GCP project |
| 361 | +
|
| 362 | + optional arguments: |
| 363 | + -h, --help show this help message and exit |
| 364 | +
|
| 365 | +
|
| 366 | +
|
| 367 | +Update Secret |
| 368 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 369 | +
|
| 370 | +.. image:: https://gstatic.com/cloudssh/images/open-btn.png |
| 371 | + :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 |
| 372 | +
|
| 373 | +
|
| 374 | +
|
| 375 | +
|
| 376 | +To run this sample: |
| 377 | +
|
| 378 | +.. code-block:: bash |
| 379 | +
|
| 380 | + $ python update_secret.py |
| 381 | +
|
| 382 | + usage: update_secret.py [-h] --secret-id SECRET_ID project_id |
| 383 | +
|
| 384 | + positional arguments: |
| 385 | + project_id id of the GCP project |
| 386 | +
|
| 387 | + optional arguments: |
| 388 | + -h, --help show this help message and exit |
| 389 | + --secret-id SECRET_ID |
| 390 | +
|
| 391 | +
|
| 392 | +
|
| 393 | +
|
| 394 | +
|
| 395 | +.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
0 commit comments