
    Ho                        S r SSKJr  SSKJr  SSKJr  SSKJr	  SSKJ
r  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  \R.                  " \R0                  R2                  5      \R4                   " S S\R6                  5      5       5       r\R.                  " \R0                  R:                  5      \R<                   " S S\R6                  5      5       5       rg)zCreate a new secret.    )api)base)
exceptions)args)log)util)crc32c)labels_util)map_util)
properties)
console_ioc                   v    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSr\S 5       rS rSrg)Create   aj  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                 j   [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U 5        [         R                  " U 5        [
        R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " 5       R                  U 5        U R                  SSS9n[        R                   " US	S["        ["        5        g
)zArgs 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parserr0   s     lib/surface/secrets/create.pyArgsCreate.Args   s     t V-?NV$008$$V,))&16"''/&&v.++F3))&1""M"BK;}c3O    c                 2   [         R                  " U R                  5       5      n[         R                  " US9nUR                  R
                  R                  5       nUR                  SLn[        R                  " UR                  5      n[        R                  " UR                  SS9n[        R                  " XR                  R                  5      n[         R"                  " XR                  R$                  5      n	UR&                  n
UR(                  n/ nUR                  (       a1  UR&                  (       a   [*        R,                  " U R.                  5      eUR                  (       a1  UR(                  (       a   [*        R,                  " U R0                  5      eUR                  (       a1  UR2                  (       a   [*        R,                  " U R4                  5      eU(       d1  UR6                  (       a   [*        R,                  " U R8                  5      eUR6                  (       aB  UR                  (       d  UR2                  (       a   [*        R,                  " U R8                  5      eU(       aZ  U
(       d3  UR2                  (       d"  UR                  (       d  UR(                  (       a   [*        R,                  " U R:                  5      eUR2                  (       a  UR=                  UR2                  5        UR                  (       aC  U(       d!  [*        R>                  " SU R@                  5      e[        RB                  " U5      u  pnGOU
(       d2  [D        RF                  RH                  R&                  RK                  5       n
U
SL nU(       a  Sn
U
S;  aS  UR&                  (       a!  [*        R>                  " SU RL                  5      e[*        R>                  " SU RN                  5      eU
S:X  a(  U(       a!  [*        R>                  " S	U RP                  5      eU(       dJ  [D        RF                  RH                  R(                  RK                  5       nU(       a  URS                  S
5      nU
S:X  a(  U(       d!  [*        RT                  " SU RV                  5      eU
S:X  a  UR(                  (       a{  UR&                  (       a!  [*        R>                  " SU RX                  5      eU(       a!  [*        R>                  " SU RZ                  5      e[*        R>                  " SU R\                  5      eU(       a!  [*        R>                  " SU R^                  5      e/ nUR                  S:X  a   [*        R`                  " U Rb                  5      eURd                  (       a9  U Rf                  Ri                  URd                  S9n[j        Rl                  " USSS9  URn                  (       a9  U Rp                  Ri                  URn                  S9n[j        Rl                  " USSS9  / nURs                  S5      (       aQ  URt                  Rw                  5        VVs/ s H*  u  nnUR                  Rx                  R{                  UUS9PM,     nnnU(       a  Sn
UR|                  (       a  UR|                   S3nOSn[         R~                  " US9R                  UUU	UU
URd                  URn                  UUR                  UUR                  UR                  UR6                  UUR                  S9nU(       a  [        R                  " U5      n[         R~                  " US9R                  UU[        R                  " U5      UR                  S9nU(       a!  [         R                  " UR                  5      nO [         R                  " UR                  5      n[        R                  " 5       R                  U5        U$ [        R~                  " 5       R                  U5        U$ s  snnf )zRun 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>   rM   user-managedrN   kms-key-name,	locations expire_timeTthrow_if_unattendedcancel_on_nottlset_annotationskeyvaluesapi_version)labelstagsrQ   policyrT   rY   keystopicsr0   next_rotation_timerotation_periodregional_kms_key_nameversion_destroy_ttlsecret_locationrj   )Nsecrets_apiGetApiFromTrackReleaseTrackGetMessagesCONCEPTSsecretParselocationsecrets_utilReadFileOrStdin	data_filereplication_policy_filer
   ParseCreateArgsSecretLabelsValuer1   GetTagsFromArgs	TagsValuereplication_policyrQ   r   ConflictingArgumentsExceptionPOLICY_AND_POLICY_FILE_MESSAGE!LOCATIONS_AND_POLICY_FILE_MESSAGEkms_key_nameKMS_KEY_AND_POLICY_FILE_MESSAGErh   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_MESSAGErT   CONFIRM_EXPIRE_TIME_MESSAGEformatr   PromptContinuerY   CONFIRM_TTL_MESSAGEIsSpecifiedrZ   itemsAnnotationsValueAdditionalPropertyri   Secretsr   re   rf   rg   r	   
get_crc32c
AddVersionget_checksumParseRegionalVersionRefnameParseVersionRefsecrets_logVersionsCreatedselfr   r`   messages
secret_refis_regionaldatareplication_policy_contentsra   rb   r}   rQ   kms_keysdefault_to_automaticmsgr0   
annotationmetadatari   responsedata_crc32crI   version_refs                          rC   Run
Create.Run   s    --d.?.?.ABK&&{;H%%++-J--t+K''7D".">">$$#7((/J/JKF''oo.G.GHD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

&
&  ood''(##(11 $"L"L
 	
 
3
34O
P .X  '..66IIMMO/47	(	#@	@""334H484O4OQ Q11 $"B"BD 	D	~	-(11DAAC 	C %%--77;;=	ooc*)	~	-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
4d< xx$$+++9c
4d< K)** )-(<(<(B(B(D )E$z8 //
*
*
=
=H > .(D   #778: ""{;BB!$$HH{{22,,"88/ C H$ %%d+k##<GG




k
*--	 H g 
"::7<<H"227<<@$$[1 O ##J/O_   1` N__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   MANAGED_AND_KMS_FLAG_MESSAGEr   r   r   r   r   r   r   r   r   staticmethodrD   r   __static_attributes__r   rF   rC   r   r      s    1j0 , 
#  #0 "? '7 'F "#  !
 N $ Q " ,C'? #6 
8 
9   P P.irF   r   c                   v    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrSrSrSrSrSrSr\S 5       rS rSrg)
CreateBetair  a  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"
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   c                 j   [         R                  " U SSSS9  [         R                  " U SSS9  [         R                  " U 5        [         R                  " U 5        [
        R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " 5       R                  U 5        U R                  SSS9n[        R                   " US	S["        ["        5        g )
Nr$   Tr%   r)   Fr*   r,   r-   r0   )r1   r2   r3   r4   r5   r
   r6   r7   r9   r8   r:   r;   r<   r=   r>   r   r?   r@   rA   s     rC   rD   CreateBeta.Args  s    t V-?NV$008$$V,))&1''/6"&&v.++F3))&1""M"BK;}c3OrF   c                 2   [         R                  " U R                  5       5      n[         R                  " US9nUR                  R
                  R                  5       nUR                  S Ln[        R                  " UR                  5      n[        R                  " UR                  SS9n[        R                  " XR                  R                  5      n[         R"                  " XR                  R$                  5      n	UR&                  n
UR(                  n/ nUR                  (       a1  UR&                  (       a   [*        R,                  " U R.                  5      eUR                  (       a1  UR(                  (       a   [*        R,                  " U R0                  5      eUR                  (       a1  UR2                  (       a   [*        R,                  " U R4                  5      eU(       d1  UR6                  (       a   [*        R,                  " U R8                  5      eUR6                  (       aB  UR                  (       d  UR2                  (       a   [*        R,                  " U R8                  5      eU(       aZ  U
(       d3  UR2                  (       d"  UR                  (       d  UR(                  (       a   [*        R,                  " U R:                  5      eUR2                  (       a  UR=                  UR2                  5        UR                  (       aC  U(       d!  [*        R>                  " SU R@                  5      e[        RB                  " U5      u  pnGOU
(       d2  [D        RF                  RH                  R&                  RK                  5       n
U
S L nU(       a  Sn
U
S;  aS  UR&                  (       a!  [*        R>                  " SU RL                  5      e[*        R>                  " SU RN                  5      eU
S:X  a(  U(       a!  [*        R>                  " SU RP                  5      eU(       dJ  [D        RF                  RH                  R(                  RK                  5       nU(       a  URS                  S	5      nU
S:X  a(  U(       d!  [*        RT                  " S
U RV                  5      eU
S:X  a  UR(                  (       a{  UR&                  (       a!  [*        R>                  " S
U RX                  5      eU(       a!  [*        R>                  " S
U RZ                  5      e[*        R>                  " S
U R\                  5      eU(       a!  [*        R>                  " SU R^                  5      e/ nUR                  S:X  a   [*        R`                  " U Rb                  5      eURd                  (       a9  U Rf                  Ri                  URd                  S9n[j        Rl                  " USSS9  URn                  (       a9  U Rp                  Ri                  URn                  S9n[j        Rl                  " USSS9  / nURs                  S5      (       aQ  URt                  Rw                  5        VVs/ s H*  u  nnUR                  Rx                  R{                  UUS9PM,     nnnU(       a  S n
UR|                  (       a  UR|                   S3nOS n[         R~                  " US9R                  UUU	UU
URd                  URn                  UUR                  UR                  UR                  UUR6                  UUR                  S9nU(       a  [        R                  " U5      n[         R~                  " US9R                  UU[        R                  " U5      UR                  S9nU(       a!  [         R                  " UR                  5      nO [         R                  " UR                  5      n[        R                  " 5       R                  U5        U$ [        R~                  " 5       R                  U5        U$ s  snnf )NrH   FrJ   rL   rM   >   rM   rN   rN   rO   rP   rQ   rR   rS   TrU   rX   rZ   r[   r^   r_   )ra   rb   rQ   rc   rT   rY   rd   rf   rg   re   r0   rh   ri   rj   rk   )Nrl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   r
   rx   ry   rz   r1   r{   r|   r}   rQ   r   r~   r   r   r   r   rh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rT   r   r   r   r   rY   r   r   rZ   r   r   r   ri   r   r   rf   rg   re   r	   r   r   r   r   r   r   r   r   r   r   s                          rC   r   CreateBeta.Run  s   --d.?.?.ABK&&{;H%%++-J--t+K''7D".">">$$#7((/J/JKF''oo.G.GHD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

&
&  ood''(##(11 $"L"L
 	
 
3
34O
P .X  '..66IIMMO/47	(	#@	@""334H484O4OQ Q11 $"B"BD 	D	~	-(11DAAC 	C %%--77;;=	ooc*)	~	-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
4d< xx$$+++9c
4d< K)** )-(<(<(B(B(D )E$z8 //
*
*
=
=H > .(D   #778: ""{;BB!$$HH22,,{{"88/ C H$ %%d+k##<GG




k
*--	 H g 
"::7<<H"227<<@$$[1 O ##J/O_r   r   Nr   r   rF   rC   r   r   r  s    ;~0 , 
#  #0 "? '7 'F "#  !
 N $ Q " ,C'? #6 
8 
9   P P"brF   r   N) r   googlecloudsdk.api_lib.secretsr   rl   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.secretsr   r1   r   r   r   rt   googlecloudsdk.command_lib.utilr	   $googlecloudsdk.command_lib.util.argsr
   r   googlecloudsdk.corer   googlecloudsdk.core.consoler   ReleaseTracksrn   GAUniverseCompatibleCreateCommandr   BETADefaultUniverseOnlyr   r   rF   rC   <module>r      s     > ( . C A C 2 < 9 * 2 D%%(()NT N  *Nb
 D%%**+K## K  ,KrF   