
    u*                     >   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
 jrS!S jrS!S jrS!S jrS!S jrS"S jrS!S jrS!S jrS"S jrS"S jrS"S jrS"S jrS"S jrS!S jr   S#S jr      S$S jrS rS rS rS r S r!S  r"g)%z(Shared resource flags for kms resources.    )absolute_import)division)unicode_literals)concepts)deps)concept_parsers)presentation_specs)
propertiesc                 B    U (       a  SOSn[         R                  " USS9$ )Nzkms-key-versionzkey-versionz&The KMS key version of the {resource}.name	help_textr    ResourceParameterAttributeConfig
kms_prefixr   s     3lib/googlecloudsdk/command_lib/kms/resource_args.pyKeyVersionAttributeConfigr      s%    (	m$		2	2C
     c                 B    U (       a  SOSn[         R                  " USS9$ )Nzkms-keykeyzThe KMS key of the {resource}.r   r   r   s     r   KeyAttributeConfigr   #   s$     e$		2	2;
 r   c                 B    U (       a  SOSn[         R                  " USS9$ )Nzkms-keyringkeyringz"The KMS keyring of the {resource}.r   r   r   s     r   KeyringAttributeConfigr   *   s$    $)$		2	2?
 r   c                 B    U (       a  SOSn[         R                  " USS9$ )Nzkms-key-handle
key-handlez%The KMS key-handle of the {resource}.r   r   r   s     r   KeyHandleAttributeConfigr   1   s%    '	\$		2	2B
 r   c                 B    U (       a  SOSn[         R                  " USS9$ )Nzkms-ekmconnectionekmconnectionz)The KMS ekm connection of the {resource}.r   r   r   s     r   EkmConnectionAttributeConfigr!   8   s%     *	$		2	2F
 r   c                     U (       a  SOSn/ nU(       a%  UR                  [        R                  " S5      5        [        R                  " USUS9$ )Nzkms-locationlocationz--regionz-The Google Cloud location for the {resource}.r   r   fallthroughs)appendr   ArgFallthroughr   r   )r   region_fallthroughr   r%   s       r   LocationAttributeConfigr)   ?   sH    %:$,++J78		2	2?
 r   c                     U (       a  SOSn[         R                  " US[        R                  " [        R
                  R                  R                  5      /S9$ )Nzkms-projectprojectz,The Google Cloud project for the {resource}.r$   )r   r   r   PropertyFallthroughr
   VALUEScorer+   r   s     r   ProjectAttributeConfigr/   K   sG    $)$		2	2>,,Z->->-C-C-K-KLM
 r   c                     [         R                  " SS[        U 5      [        U 5      [	        U 5      [        U S9[        U S9SS9$ )NzAcloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersionszkey versionr   F)resource_namecryptoKeyVersionsIdcryptoKeysId
keyRingsIdlocationsId
projectsIddisable_auto_completers)r   ResourceSpecr   r   r   r)   r/   r1   s    r   GetKmsKeyVersionResourceSpecr:   T   sF    			I!3J?%j1'
3)Z@':>#	
 	r   c                 z    [         R                  " SS[        U 5      [        U 5      [	        XS9[        U 5      SS9$ )Nz/cloudkms.projects.locations.keyRings.cryptoKeysr   r   r(   F)r2   r4   r5   r6   r7   r8   )r   r9   r   r   r)   r/   r<   s     r   GetKmsKeyResourceSpecr=   a   sC    			7%j1'
3) (
3#

 
r   c           
      f    [         R                  " SS[        U 5      [        XS9[	        U 5      SS9$ )Nz$cloudkms.projects.locations.keyRingsr   r<   F)r2   r5   r6   r7   r8   )r   r9   r   r)   r/   r<   s     r   GetKmsKeyRingResourceSpecr?   o   s;    			,'
3) (
3#	
 	r   c           
      f    [         R                  " SS[        U 5      [        XS9[	        U 5      SS9$ )Nz&cloudkms.projects.locations.keyHandlesr   r<   F)r2   keyHandlesIdr6   r7   r8   )r   r9   r   r)   r/   r<   s     r   GetKmsKeyHandleResourceSpecrB   |   s;    			. +J7) (
3#	
 	r   c           
      f    [         R                  " SS[        U 5      [        XS9[	        U 5      SS9$ )Nz*cloudkms.projects.locations.ekmConnectionsr    r<   F)r2   ekmConnectionsIdr6   r7   r8   )r   r9   r!   r)   r/   r<   s     r   GetKmsEkmConnectionResourceSpecrE      s;    			2#3J?) (
3#	
 	r   c           	      R    [         R                  " SS[        XS9[        U 5      SS9$ )Nzcloudkms.projects.locationsr#   r<   F)r2   r6   r7   r8   )r   r9   r)   r/   r<   s     r   GetKmsLocationResourceSpecrG      s3    			#) (
3#
 r   c                 B    [         R                  " SS[        U 5      SS9$ )Nzcloudkms.projectsr+   F)r2   r7   r8   )r   r9   r/   r1   s    r   GetKmsProjectResourceSpecrI      s&    			'
3#	
 r   Nc                     U(       d  SR                  SS5      nSR                  X5      n[        R                  " S[        US9UU=(       d    0 S9nU$ )a  Return a Presentation Spec for kms key resource argument.

Args:
  resource: str, the name of the resource that the cryptokey will be used to
    protect.
  region_fallthrough: bool, True if the command has a region flag that should
    be used as a fallthrough for the kms location.
  flag_overrides: dict, The default flag names are 'kms-key', 'kms-keyring',
    'kms-location' and 'kms-project'. You can pass a dict of overrides where
    the keys of the dict are the default flag names, and the values are the
    override names.
  permission_info: str, optional permission info that overrides default
    permission info group help.

Returns:
  Presentation spec suitable for adding to concept parser.
{} must hold permission {}2The 'Compute Engine Service Agent' service account)'Cloud KMS CryptoKey Encrypter/Decrypter'YThe Cloud KMS (Key Management Service) cryptokey that will be used to protect the {}. {}.	--kms-keyr(   )flag_name_overrides)formatr	   ResourcePresentationSpecr=   )resourcer(   flag_overridespermission_info
group_helppresentation_specs         r   GetKmsKeyPresentationSpecrY      sc    0 
299<3O%%+VH%F 
 )AA/AB(.B	 
r   c           	          U(       d  SR                  SS5      n[        R                  R                  U[	        US9SR                  X5      UUUS9R                  U 5        g)a  Add a resource argument for a KMS key to protect other resources.

Args:
  parser: the parser for the command.
  resource: str, the name of the resource that the cryptokey will be used to
    protect.
  region_fallthrough: bool, True if the command has a region flag that should
    be used as a fallthrough for the kms location.
  flag_overrides: dict, The default flag names are 'kms-key', 'kms-keyring',
    'kms-location' and 'kms-project'. You can pass a dict of overrides where
    the keys of the dict are the default flag names, and the values are the
    override names.
  permission_info: str, optional permission info that overrides default
    permission info group help.
  required: bool, optional. True if the flag must be parsable by the parser.
    The default value is False.
  name: str, optional name of the arg for the KMS resource. Defaults to
    '--kms-key'.
  hidden: bool, optional to hide the field. True if the flag must be parsable
    by the parser. The default value is False.
rK   rL   rM   rP   rN   )rQ   requiredhiddenN)rR   r   ConceptParserForResourcer=   AddToParser)parserrT   r(   rU   rV   r[   r   r\   s           r   AddKmsKeyResourceArgra      sh    > 
299<3O ++
/AB"F8=( ,  Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   zThe KMS key resource.r[   )r   r]   r^   r=   r_   r`   r[   r   s      r   AddKmsKeyResourceArgForKMSre     s8    ++
u-	 , 
 Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   zThe KMS keyring resource.rc   )r   r]   r^   r?   r_   rd   s      r   AddKmsKeyringResourceArgForKMSrg     8    ++
51!	 , 
 Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   zThe KMS key-handle resource.rc   )r   r]   r^   rB   r_   rd   s      r    AddKmsKeyHandleResourceArgForKMSrj     s8    ++
!U3$	 , 
 Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   z The KMS ekm connection resource.rc   )r   r]   r^   rE   r_   rd   s      r   $AddKmsEkmConnectionResourceArgForKMSrl   !  s8    ++
%7(	 , 
 Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   zThe KMS location resource.rc   )r   r]   r^   rG   r_   rd   s      r   AddKmsLocationResourceArgForKMSrn   *  s8    ++
 E2"	 , 
 Kr   c                 p    [         R                  R                  U[        SS9SUS9R	                  U 5        g )NFr1   zThe KMS project resource.rc   )r   r]   r^   rI   r_   rd   s      r   AddKmsProjectResourceArgForKMSrp   3  rh   r   )T)TF)FNN)FNNFrO   F)#__doc__
__future__r   r   r    googlecloudsdk.calliope.conceptsr   r   (googlecloudsdk.command_lib.util.conceptsr   r	   googlecloudsdk.corer
   r   r   r   r   r!   r)   r/   r:   r=   r?   rB   rE   rG   rI   rY   ra   re   rg   rj   rl   rn   rp    r   r   <module>rw      s    / &  ' 5 1 D G *	



	 	)^ 	,^r   