
    //                     *   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  SSKJr  SSKJ	r  SSKJr  SSKJr  SSKr\R6                  " \R8                  R:                  R<                  5      r\R6                  " \R8                  R@                  RB                  5      r"S r#S#S jr$S$S jr% S%S jr&S&S jr'S'S jr(S r)     S(S jr*   S)S jr+S$S jr,S r-S r.S r/S r0S r1S*S  jr2S*S! jr3S" r4g)+z'Helpers for parsing resource arguments.    )absolute_import)division)unicode_literals)base)	locations)
exceptions)concepts)deps)handlers)util)resource_args)
completers)concept_parsers)
propertiesNc                  *    [         R                  " SS9$ )Nzcertificate template)namer	    ResourceParameterAttributeConfig     9lib/googlecloudsdk/command_lib/privateca/resource_args.py"CertificateTemplateAttributeConfigr   ,   s    		2	28N	OOr   c                 @    [         R                  " U SU=(       d    / S9$ )Nz%The parent CA Pool of the {resource}.r   	help_textfallthroughsr   )display_namer   s     r   CaPoolAttributeConfigr   1   s#    		2	27%2
 r   c                 >    [         R                  " SU =(       d    / S9$ )Ncertificate)r   r   r   r   s    r   CertAttributeConfigr"   :   s!     
	2	2|'9r
 r   c                 D    U=(       d    / n[         R                  " U SUS9$ )Nz4The issuing certificate authority of the {resource}.r   r   arg_namer   s     r   CertAuthorityAttributeConfigr&   B   s*     #,		2	2F
 r   c                 l    U=(       d    [         /n[        R                  " U S[        R                  US9$ )NzThe location of the {resource}.)r   r   	completerr   )LOCATION_PROPERTY_FALLTHROUGHr	   r   privateca_completersLocationsCompleterr$   s     r   LocationAttributeConfigr,   M   s5    @"?!@,		2	21$77	
 r   c                 @    [         R                  " U SU=(       d    / S9$ )a  DO NOT USE THIS for most flags.

This config is only useful when you want to provide an explicit project
fallthrough. For most cases, prefer concepts.DEFAULT_PROJECT_ATTRIBUTE_CONFIG.

Args:
  arg_name: Name of the flag used to specify this attribute. Defaults to
    'project'.
  fallthroughs: List of deps.Fallthrough objects to provide project values.

Returns:
  A concepts.ResourceParameterAttributeConfig for a project.
z&The project containing the {resource}.r   r   r$   s     r   ProjectAttributeConfigr.   W   s%     
	2	28%2
 r   c                  2   [         R                  " SS[        R                  " SS9[        R                  " SS9[        R
                  " SS9[        S[        R                  " S5      [        /5      [        S[        R                  " S5      [        /5      S	9$ )
zCreates a resource spec for a KMS CryptoKeyVersion.

Defaults to the location and project of the CA, specified through flags or
properties.

Returns:
  A concepts.ResourceSpec for a CryptoKeyVersion.
zAcloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersionszkey versionT)
kms_prefixzkms-locationlocationzkms-projectproject)resource_namecryptoKeyVersionsIdcryptoKeysId
keyRingsIdlocationsId
projectsId)r	   ResourceSpeckms_argsKeyVersionAttributeConfigKeyAttributeConfigKeyringAttributeConfigr,   r
   ArgFallthroughr)   r.   PROJECT_PROPERTY_FALLTHROUGHr   r   r   CreateKmsKeyVersionResourceSpecr@   l   s     
		I!"<<M..$?00DA)
z*,I
J (
y)+G
H
 r   c                 ~    [         R                  " SSU [        XS9[        US9[	        X#S9[         R
                  SS9$ )Nz;privateca.projects.locations.caPools.certificateAuthoritiesv1r!   T)api_versionr3   certificateAuthoritiesId	caPoolsIdr7   r8   disable_auto_completers)r	   r9   r&   r   r,    DEFAULT_PROJECT_ATTRIBUTE_CONFIG)r   certificate_authority_attributelocation_attributelocation_fallthroughspool_id_fallthroughsca_id_fallthroughss         r   CreateCertAuthorityResourceSpecrM      sO     
		C ;
)  &3GH)
 ::"
 r   c                 n    [         R                  " SSU [        US9[        XS9[         R                  SS9$ )Nz$privateca.projects.locations.caPoolsrB   r!   T)rC   r3   rE   r7   r8   rF   )r	   r9   r   r,   rG   )r   rI   rK   rJ   s       r   CreateCaPoolResourceSpecrO      sB     
		, %3GH)
 ::"
 r   c                     [         R                  " SSU [        U=(       d    / S9[        S5      [	        S5      [         R
                  SS9$ )Nz1privateca.projects.locations.caPools.certificatesrB   r!   zissuer-poolzissuer-locationF)rC   r3   certificatesIdrE   r7   r8   rF   )r	   r9   r"   r   r,   rG   )r   id_fallthroughss     r   CreateCertResourceSpecrS      sH    			9 (o6KL%m4)*;<::#

 
r   c           
      r    [         R                  " SSU [        5       [        5       [         R                  SS9$ )Nz1privateca.projects.locations.certificateTemplatesrB   T)rC   r3   certificateTemplatesIdr7   r8   rF   )r	   r9   r   r,   rG   )r   s    r   %CreateCertificateTemplateResourceSpecrV      s6    			9 ?A)+::"	
 	r   c                     Sn[         R                  R                  U[        U5      SR	                  U5      SS9R                  U 5        g)zAdd a positional resource argument for a GA Certificate Authority.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
CERTIFICATE_AUTHORITYzThe certificate authority {}.TrequiredN)r   ConceptParserForResourcerM   formatAddToParserparserverbr%   s      r   %AddCertAuthorityPositionalResourceArgrb      sJ     %(++%h/%,,T2	 , 
 Kr   c                     Sn[         R                  R                  U[        U5      SR	                  U5      SS9R                  U 5        g)zAdd a positional resource argument for a CA Pool.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
CA_POOLzThe ca pool {}.TrY   N)r   r[   r\   rO   r]   r^   r_   s      r   AddCaPoolPositionalResourceArgre      sJ     (++x(t$	 , 
 Kr   c                     Sn[         R                  R                  U[        U5      SR	                  U5      SS9R                  U 5        g)zAdd a positional resource argument for a GA Certificate.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
CERTIFICATEzThe certificate {}.TrY   N)r   r[   r\   rS   r]   r^   r_   s      r   AddCertPositionalResourceArgrh      sJ     (++X&""4(	 , 
 Kr   c                     Sn[         R                  R                  U[        U5      SR	                  U5      SS9R                  U 5        g)zAdd a positional resource argument for a certificate template.

NOTE: Must be used only if it's the only resource arg in the command.

Args:
  parser: the parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
CERTIFICATE_TEMPLATEzThe template {}.TrY   N)r   r[   r\   rV   r]   r^   r_   s      r   +AddCertificateTemplatePositionalResourceArgrk     sJ     $(+++H5%	 , 
 Kr   c           
          [         R                  " US9nU R                  U;  a>  [        R                  " USR                  SR                  [        U5      5      5      5      eg)zHRaises an exception if the given resource is in an unsupported location.)versionzDResource is in an unsupported location. Supported locations are: {}.z, N)r   GetSupportedLocationsr7   r   InvalidArgumentExceptionr]   joinsorted)resource_refr%   rm   supported_locationss       r   ValidateResourceLocationrt     sY    !77H%88

-
-N			&!456	7  9r   c                 *   [         R                  " US9R                  R                  nXR                  :X  a&  UR
                  U :w  a  [        R                  " S5      eXR                  :X  a'  UR
                  U :w  a  [        R                  " S5      egg)zRaises an exception if the Certificate Authority type is not expected_type.

Args:
  expected_type: The expected type.
  ca: The ca object to check.
  version: The version of the API to check against.
)rC   zgCannot perform subordinates command on Root CA. Please use the `privateca roots` command group instead.znCannot perform roots command on Subordinate CA. Please use the `privateca subordinates` command group instead.N)	r   GetMessagesModuleCertificateAuthorityTypeValueValuesEnumSUBORDINATEtypeprivateca_exceptions$InvalidCertificateAuthorityTypeErrorSELF_SIGNED)expected_typecarm   ca_type_enums       r   CheckExpectedCATyper   '  s     '',,  ...277m3K

C
C	4  000RWW5M

C
C	;  6N0r   c                 B   [        U R                  U5      (       d  gU R                  R                  U5      nUR                  R	                  5        Vs/ s H  n[
        R                  " U5      PM     nnU Vs/ s H  o0R                  U5      (       d  M  UPM     sn(       d  g UR                  5         SUl	        UR                  U 5        gs  snf s  snf ! [        R                   a0  n[        R                  " U[        R                   " U5      5      eSnAff = f)zJRaises a ParseError if the given resource_arg_name is partially specified.NF)hasattrCONCEPTSArgNameToConceptInfoattribute_to_args_mapvaluesr   NamespaceFormatIsSpecified
ClearCacheallow_emptyParser	   InitializationErrorr   
ParseErrorsix	text_type)argsresource_arg_nameconcept_infoargassociated_argses         r   %ValidateResourceIsCompleteIfSpecifiedr   >  s    	 1	2	2
334EF, 33::<<# 3<   )	B#,<,<S,A#	B
C $Lt 
C 
	%	% C


/q1A
BBCs*    C:CC'(C D.+DD)poolN)N)certificate_authorityN)r1   N)r2   N)r   r1   NNN)r1   NN)rB   )5__doc__
__future__r   r   r    googlecloudsdk.api_lib.privatecar   r   googlecloudsdk.callioper    googlecloudsdk.calliope.conceptsr	   r
   r   r   googlecloudsdk.command_lib.kmsr   r:   $googlecloudsdk.command_lib.privatecar   r*   r{   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   PropertyFallthroughVALUES	privatecar1   r)   corer2   r?   r   r   r"   r&   r,   r.   r@   rM   rO   rS   rV   rb   re   rh   rk   rt   r   r   r   r   r   <module>r      s   . &  ' 1 6 . 5 1 5 1 D S S D * 
 !% 8 8((!   $77""  
P
 48*8 %<!8 "	*$$$*.Cr   