| Server IP : 35.236.43.222 / Your IP : 216.73.216.143 Web Server : Apache System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64 User : deploy ( 1002) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/lib/google-cloud-sdk/lib/surface/secrets/__pycache__/ |
Upload File : |
�
���n � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm
Z
ddlmZ
dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZ ddlmZ e j e j j � � e j G d� de j � � � � � � Z e j e j j! � � e j G d� de j � � � � � � Z"dS )zCreate a new secret.� )�absolute_import)�division)�unicode_literals)�api)�base)�
exceptions)�args)�log)�util)�crc32c)�labels_util)�map_util)�
properties)�
console_ioc �v � e Zd ZdZdZdZdZdZdZdZ dZ
d Zd
ZdZ
dZd
ZdZdZdZdZdZdZed� � � Zd� ZdS )�Createa� Create a new secret.
Create a secret with the given name and creates a secret version with the
given data, if any. If a secret already exists with the given name, this
command will return an error.
## EXAMPLES
Create a secret with an automatic replication policy without creating any
versions:
$ {command} my-secret
Create a new secret named 'my-secret' with an automatic replication policy
and data from a file:
$ {command} my-secret --data-file=/tmp/secret
Create a new secret named 'my-secret' in 'us-central1' with data from a file:
$ {command} my-secret --data-file=/tmp/secret
--replication-policy=user-managed \
--locations=us-central1
Create a new secret named 'my-secret' in 'us-central1' and 'us-east1' with
the value "s3cr3t":
$ printf "s3cr3t" | {command} my-secret --data-file=-
--replication-policy=user-managed --locations=us-central1,us-east1
Create a new secret named 'my-secret' in 'us-central1' and 'us-east1' with
the value "s3cr3t" in PowerShell (Note: PowerShell will add a newline to the
resulting secret):
$ Write-Output "s3cr3t" | {command} my-secret --data-file=-
--replication-policy=user-managed --locations=us-central1,us-east1
Create a secret with an automatic replication policy and a next rotation time:
$ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"
Create a secret with an automatic replication policy and a rotation period:
$ {command} my-secret --next-rotation-time="2030-01-01T15:30:00-05:00"
--rotation-period="7200s"
Create a secret with delayed secret version destroy enabled:
$ {command} my-secret --version-destroy-ttl="86400s"
��The value provided for --data-file is the empty string. This can happen if you pass or pipe a variable that is undefined. Please verify that the --data-file flag is not the empty string. If you are not providing secret data, omit the --data-file flag.�hThe value provided for --replication-policy is invalid. Valid values are "automatic" and "user-managed".��Cannot use the secrets/replication-policy property because its value is invalid. Please either set it to a valid value ("automatic" or "user-managed") or override it for this command by using the --replication-policy flag.�( If --replication-policy is user-managed then --locations must also be provided. Please set the desired storage regions in --locations or the secrets/locations property. For an automatic replication policy, please set --replication-policy or the secrets/replication-policy property to "automatic".��If --replication-policy is "automatic" then --locations are not allowed. Please remove the --locations flag or set the --replication-policy to "user-managed".��The secrets/replication-policy property is "automatic" and not overridden so --locations are not allowed. Please remove the --locations flag or set the replication-policy to "user-managed".��Cannot create a secret with an "automatic" replication policy if the secrets/locations property is set. Please either use a "user-managed" replication policy or unset secrets/locations.��Locations are only allowed when creating a secret with a "user-managed" replication policy. Please use the --replication-policy flag to set it or remove --locations to use an automatic replication policy.��The --kms-key-name flag can only be used when creating a secret with an "automatic" replication policy. To specify encryption keys for secrets with a "user-managed" replication policy, please use --replication-policy-file.�NA --replication-policy-file and --replication-policy cannot both be specified.�EA --replication-policy-file and --locations cannot both be specified.�HA --replication-policy-file and --kms-key-name cannot both be specified.�File cannot be empty.��The --kms-key-name flag can only be set for automatically replicated secrets. To create a user managed secret with customer managed encryption keys, please use --replication-policy-file.�rThis secret and all of its versions will be automatically deleted at the requested expire-time of [{expire_time}].�qThis secret and all of its versions will be automatically deleted after the requested ttl of [{ttl}] has elapsed.��The --regional-kms-key-name flag can only be used when creating a regional secret with "--location" and should not be used with "--replication-policy-file" or "--kms-key-name"��Regional secret created using "--location" should not have flags like "--replication-policy-file" or "--kms-key-name" or "--locations" or --replication-policyc � � t j | ddd�� � t j | dd�� � t j | � � t j | � � t j | � � t j | � � t j | � � t j | � � t j
| � � t j | � � | � dd�� � }t j |d dt t � � d
S )z�Args is called by calliope to gather arguments for this command.
Args:
parser: An argparse parser that you can use to add arguments that will be
available to the command.
� to createT��purpose�
positional�required�to create secretF�r( �hidden�Annotations��mutex�help�annotationsN)�secrets_args� AddSecret�AddLocation�AddDataFile�AddCreateReplicationPolicyGroupr
�AddCreateLabelsFlags�AddCreateExpirationGroup� AddTopics�AddCreateRotationGroup�AddRegionalKmsKeyName�AddCreateVersionDestroyTTL� add_groupr �
AddMapSetFlag�str��parserr2 s �lib/surface/secrets/create.py�ArgszCreate.Args� s � � �����t�� � � � ��V�-?��N�N�N�N���V�$�$�$��0��8�8�8��$�V�,�,�,��)�&�1�1�1���6�"�"�"��'��/�/�/��&�v�.�.�.��+�F�3�3�3��"�"��M�"�B�B�K���;�
�}�c�3�O�O�O�O�O� c �| �� t j | � � � � � }t j |�� � �|j j � � � }|j du}t j |j
� � }t j |j d�� � }t j
|�j j � � }|j }|j } g }
|j r |j rt% j | j � � �|j r |j rt% j | j � � �|j r |j rt% j | j � � �|s |j rt% j | j � � �|j r'|j s|j rt% j | j � � �|r0|s|j s|j s|j rt% j | j � � �|j r|
� |j � � |j r6|st% j d| j � � �t j |� � \ }} }
�nx|s(t>