HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/secrets/__pycache__/create.cpython-312.pyc
�

���o����dZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZ
dd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZe	j6e	j8j:�e	j<Gd�de	j>���Z e	j6e	j8jB�e	j<Gd�de	j>���Z"y)zCreate a new secret.�)�absolute_import)�division)�unicode_literals)�api)�base)�
exceptions)�args)�log)�util)�crc32c)�labels_util)�map_util)�
properties)�
console_ioc�n�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZed��Zd�Zy)�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�d�tj|ddd��tj|dd��tj|�tj|�tj|�tj|�tj|�tj|�tj|�tj|�tj�j|�|jdd��}tj |d	dt"t"�y
)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�
GetTagsArg�AddToParser�	add_groupr�
AddMapSetFlag�str��parserr2s  �lib/surface/secrets/create.py�ArgszCreate.Args�s���������t�����V�-?��N����V�$��0�0��8��$�$�V�,��)�)�&�1����6�"��'�'��/��&�&�v�.��+�+�F�3�����)�)�&�1��"�"��M�"�B�K����;�
�}�c�3�O�c��tj|j��}tj|��}|jj
j
�}|jdu}tj|j�}tj|jd��}tj||jj�}t!j"||jj$�}	|j&}
|j(}g}|jr+|j&rt+j,|j.��|jr+|j(rt+j,|j0��|jr+|j2rt+j,|j4��|s+|j6rt+j,|j8��|j6r7|js|j2rt+j,|j8��|rE|
s$|j2s|js|j(rt+j,|j:��|j2r|j=|j2�|jr=|s t+j>d|j@��tjB|�\}
}}�n�|
s2tDjFjHj&jK�}
|
du}
|
rd}
|
dvrL|j&r t+j>d|jL��t+j>d|jN��|
dk(r"|r t+j>d	|jP��|sEtDjFjHj(jK�}|r|jSd
�}|
dk(r"|s t+jTd|jV��|
dk(r�|j(rn|j&r t+j>d|jX��|
r t+j>d|jZ��t+j>d|j\��|r t+j>d|j^��g}|jdk(rt+j`|jb��|jdr>|jfji|jd�
�}tkjl|dd��|jnr>|jpji|jn��}tkjl|dd��g}|jsd�rQ|jtjw�D��cgc],\}}|jjxj{||����.}}}|rd}
|j|r|j|�d�}nd}tj~|��j�|||	||
|jd|jn||j�||j�|j�|j6||j��}|r�t�j�|�}tj~|��j�||t�j�|�|j��}|r t!j�|j��}nt!j�|j��}t�j��j�|�|St�j~�j�|�|Scc}}w)z�Run is called by calliope to create the secret.

    Args:
      args: an argparse namespace, all the arguments that were provided to this
        command invocation.

    Returns:
      The response from the create secret API call.
    ��versionNF��	is_binary�replication-policy�	automatic>rN�user-managedrO�kms-key-name�,�	locations���expire_timeT��throw_if_unattended�cancel_on_no��ttl�set_annotations��key�value�s��api_version)�labels�tagsrR�policyrUrZ�keys�topicsr2�next_rotation_time�rotation_period�regional_kms_key_name�version_destroy_ttl�secret_location�rk)N�secrets_api�GetApiFromTrack�ReleaseTrack�GetMessages�CONCEPTS�secret�Parse�location�secrets_util�ReadFileOrStdin�	data_file�replication_policy_filer
�ParseCreateArgs�Secret�LabelsValuer3�GetTagsFromArgs�	TagsValue�replication_policyrRr�ConflictingArgumentsException�POLICY_AND_POLICY_FILE_MESSAGE�!LOCATIONS_AND_POLICY_FILE_MESSAGE�kms_key_name�KMS_KEY_AND_POLICY_FILE_MESSAGEri�REGIONAL_KMS_FLAG_MESSAGE�REGIONAL_SECRET_MESSAGE�append�InvalidArgumentException�%REPLICATION_POLICY_FILE_EMPTY_MESSAGE�ParseReplicationFileContentsr�VALUES�secrets�Get�INVALID_POLICY_MESSAGE�INVALID_POLICY_PROP_MESSAGE� KMS_KEY_AND_USER_MANAGED_MESSAGE�split�RequiredArgumentException� MANAGED_BUT_NO_LOCATIONS_MESSAGE�AUTOMATIC_AND_LOCATIONS_MESSAGE�NO_POLICY_AND_LOCATIONS_MESSAGE�$AUTOMATIC_PROP_AND_LOCATIONS_MESSAGE�$AUTOMATIC_AND_LOCATIONS_PROP_MESSAGE�BadFileException�EMPTY_DATA_FILE_MESSAGErU�CONFIRM_EXPIRE_TIME_MESSAGE�formatr�PromptContinuerZ�CONFIRM_TTL_MESSAGE�IsSpecifiedr[�items�AnnotationsValue�AdditionalPropertyrj�Secretsrrfrgrhr�
get_crc32c�
AddVersion�get_checksum�ParseRegionalVersionRef�name�ParseVersionRef�secrets_log�Versions�Created��selfr	ra�messages�
secret_ref�is_regional�data�replication_policy_contentsrbrcr~rR�kms_keys�default_to_automatic�msgr2�
annotation�metadatarj�response�data_crc32crJ�version_refs                       rE�Runz
Create.Run�s����-�-�d�.?�.?�.A�B�K��&�&�{�;�H����%�%�+�+�-�J��-�-�t�+�K��'�'����7�D�".�">�">��$�$��#7��
�
(�
(��x���/J�/J�
K�F��'�'��h�o�o�.G�.G�H�D��0�0�����I��H��#�#��(?�(?��4�4�
�
-�
-�
/�/��#�#�����4�4�
�
0�
0�
2�2��#�#��(9�(9��4�4�
�
.�
.�
0�0��4�5�5��4�4�
�
(�
(�
���!�!��$�$��(9�(9��4�4�
�
(�
(�
��������'�'��>�>��4�4�
�
&�
&�
������o�o�d�'�'�(��#�#�
(��1�1� �$�"L�"L�
�	
��
3�
3�4O�
P�.��)�X� �'�.�.�6�6�I�I�M�M�O��/�4�7��	�(��	�#@�	@��"�"��3�3�4H�48�4O�4O�Q�Q��1�1� �$�"B�"B�D�	D�	�~�	-�(��1�1��D�A�A�C�	C���%�%�-�-�7�7�;�;�=�	���o�o�c�*�)�	�~�	-�i��2�2���>�>�@�	@�	�{�	*��>�>��
$�
$��5�5��T�A�A�C�
C�
!��5�5��T�A�A�C�
C��3�3��4�D�D�F�F���3�3�"�D�$M�$M�O�O��	��~�~����'�'��(D�(D�E�E�����,�,�3�3��&�&�
4�
(�c����

�4�d�<��x�x��$�$�+�+����+�9�c����

�4�d�<��K����)�*�)-�(<�(<�(B�(B�(D��)E�$�z�8��/�/�
*�
*�
=�
=��H�>�.�(D���������#�7�7�8��:�� ���"�"�{�;�B�B���
��!��$�$��H�H�
��{�{���2�2��,�,�"�8�8�/��
�
�C��H�$��%�%�d�+�k��#�#��<�G�G�
�
�
�
�
�k�
*��-�-�	H��g�
�"�:�:�7�<�<�H��"�2�2�7�<�<�@������$�$�[�1��O�����#�#�J�/��O��_��1]N��__name__�
__module__�__qualname__�__doc__r�r�r�r�r�r�r�r��MANAGED_AND_KMS_FLAG_MESSAGEr�r�r�r�r�r�r�r�r��staticmethodrFr��rGrErr"s���1�j0��,��
#���#�0�"�?�'�7�'�F�"�#���!�
N�$�Q�"�,C�'�?�#�6��
8��
9�����P��P�.irGrc�n�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZed��Zd�Zy)�
CreateBetaa�Create a new secret.

  Create a secret with the given name and creates a secret version with the
  given data, if any. Note, the created secret ends with a newline.
  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 an expiring secret with an automatic replication policy using a ttl:

    $ {command} my-secret --ttl="600s"

  Create an expiring secret with an automatic replication policy using an
  expire-time:

    $ {command} my-secret --expire-time="2030-01-01T08:15:30-05:00"

  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"
  rrrrrrrrrrrrrr r!r"r#r$c�d�tj|ddd��tj|dd��tj|�tj|�tj|�tj|�tj|�tj|�tj|�tj|�tj�j|�|jdd��}tj |d	dt"t"�y)
Nr&Tr'r+Fr,r.r/r2)r3r4r5r6r7r
r8r9r;r:r<r=r>r?r@rrArBrCs  rErFzCreateBeta.Argss���������t�����V�-?��N����V�$��0�0��8��$�$�V�,��)�)�&�1��'�'��/����6�"��&�&�v�.��+�+�F�3�����)�)�&�1��"�"��M�"�B�K����;�
�}�c�3�OrGc��tj|j��}tj|��}|jj
j
�}|jdu}tj|j�}tj|jd��}tj||jj�}t!j"||jj$�}	|j&}
|j(}g}|jr+|j&rt+j,|j.��|jr+|j(rt+j,|j0��|jr+|j2rt+j,|j4��|s+|j6rt+j,|j8��|j6r7|js|j2rt+j,|j8��|rE|
s$|j2s|js|j(rt+j,|j:��|j2r|j=|j2�|jr=|s t+j>d|j@��tjB|�\}
}}�n�|
s2tDjFjHj&jK�}
|
du}
|
rd}
|
dvrL|j&r t+j>d|jL��t+j>d|jN��|
dk(r"|r t+j>d|jP��|sEtDjFjHj(jK�}|r|jSd	�}|
dk(r"|s t+jTd
|jV��|
dk(r�|j(rn|j&r t+j>d
|jX��|
r t+j>d
|jZ��t+j>d
|j\��|r t+j>d|j^��g}|jdk(rt+j`|jb��|jdr>|jfji|jd��}tkjl|d
d
��|jnr>|jpji|jn��}tkjl|d
d
��g}|jsd�rQ|jtjw�D��cgc],\}}|jjxj{||����.}}}|rd}
|j|r|j|�d�}nd}tj~|��j�|||	||
|jd|jn||j�|j�|j�||j6||j��}|r�t�j�|�}tj~|��j�||t�j�|�|j��}|r t!j�|j��}nt!j�|j��}t�j��j�|�|St�j~�j�|�|Scc}}w)NrIFrKrMrN>rNrOrOrPrQrRrSrTTrVrYr[r\r_r`)rbrcrRrdrUrZrergrhrfr2rirjrkrl)Nrmrnrorprqrrrsrtrurvrwrxr
ryrzr{r3r|r}r~rRrrr�r�r�r�rir�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rUr�r�rr�rZr�r�r[r�r�r�rjr�rrgrhrfrr�r�r�r�r�r�r�r�r�r�s                       rEr�zCreateBeta.Run s����-�-�d�.?�.?�.A�B�K��&�&�{�;�H����%�%�+�+�-�J��-�-�t�+�K��'�'����7�D�".�">�">��$�$��#7��
�
(�
(��x���/J�/J�
K�F��'�'��h�o�o�.G�.G�H�D��0�0�����I��H��#�#��(?�(?��4�4�
�
-�
-�
/�/��#�#�����4�4�
�
0�
0�
2�2��#�#��(9�(9��4�4�
�
.�
.�
0�0��4�5�5��4�4�
�
(�
(�
���!�!��$�$��(9�(9��4�4�
�
(�
(�
��������'�'��>�>��4�4�
�
&�
&�
������o�o�d�'�'�(��#�#�
(��1�1� �$�"L�"L�
�	
��
3�
3�4O�
P�.��)�X� �'�.�.�6�6�I�I�M�M�O��/�4�7��	�(��	�#@�	@��"�"��3�3�4H�48�4O�4O�Q�Q��1�1� �$�"B�"B�D�	D�	�~�	-�(��1�1��D�A�A�C�	C���%�%�-�-�7�7�;�;�=�	���o�o�c�*�)�	�~�	-�i��2�2���>�>�@�	@�	�{�	*��>�>��
$�
$��5�5��T�A�A�C�
C�
!��5�5��T�A�A�C�
C��3�3��4�D�D�F�F���3�3�"�D�$M�$M�O�O��	��~�~����'�'��(D�(D�E�E�����,�,�3�3��&�&�
4�
(�c����

�4�d�<��x�x��$�$�+�+����+�9�c����

�4�d�<��K����)�*�)-�(<�(<�(B�(B�(D��)E�$�z�8��/�/�
*�
*�
=�
=��H�>�.�(D���������#�7�7�8��:�� ���"�"�{�;�B�B���
��!��$�$��H�H�
��2�2��,�,��{�{��"�8�8�/��
�
�C��H�$��%�%�d�+�k��#�#��<�G�G�
�
�
�
�
�k�
*��-�-�	H��g�
�"�:�:�7�<�<�H��"�2�2�7�<�<�@������$�$�[�1��O�����#�#�J�/��O��_r�Nr�r�rGrEr�r�us���;�~0��,��
#���#�0�"�?�'�7�'�F�"�#���!�
N�$�Q�"�,C�'�?�#�6��
8��
9�����P��P�"brGr�N)#r��
__future__rrr�googlecloudsdk.api_lib.secretsrrm�googlecloudsdk.callioperr�"googlecloudsdk.command_lib.secretsr	r3r
r�rru�googlecloudsdk.command_lib.utilr�$googlecloudsdk.command_lib.util.argsr
r�googlecloudsdk.corer�googlecloudsdk.core.consoler�
ReleaseTracksro�GA�DefaultUniverseOnly�
CreateCommandr�BETAr�r�rGrE�<module>r�s����&��'�=�(�.�C�A�C�2�<�9�*�2�����D�%�%�(�(�)����N�T�
�
�N��*�N�b
����D�%�%�*�*�+����K��#�#�K��,�KrG