
                         Z   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
 rS r\R$                  " \R&                  R(                  \R&                  R*                  \R&                  R,                  5       " S S\R.                  5      5       rSSSS.\l        g)z&Command for creating SSL certificates.    )base_classes)arg_parsers)base)
exceptions)scope)flags)ssl_certificates_utils)filesc                 L   U R                  SSS9  U R                  R                  [        R                  5        U R                  SSSS9nUR                  SS[        R                  " S	S
9/ SS9  UR                  S5      nUR                  SSSSS9  UR                  SSSSS9  g)z:Add the SSL certificates command line flags to the parser.z--descriptionz9An optional, textual description for the SSL certificate.)helpTz/Flags for managed or self-managed certificate. )mutexrequiredr   z	--domainsDOMAIN   )
min_lengthzA      List of domains to create a managed certificate for.
      )metavartypedefaultr   z"Flags for self-managed certificatez--certificateLOCAL_FILE_PATHz      Path to a local certificate file to create a self-managed
      certificate. The certificate must be in PEM format. The certificate
      chain must be no greater than 5 certs long. The chain must include at
      least one intermediate cert.
      )r   r   r   z--private-keyz      Path to a local private key file. The private key must be in PEM
      format and must use RSA or ECDSA encryption.
      N)add_argumentdisplay_infoAddCacheUpdaterr   SslCertificatesCompleterBeta	add_groupr   ArgList)parsermanaged_or_notnot_manageds      .lib/surface/compute/ssl_certificates/create.py_Argsr       s    F  H 	%%e&H&HI##< $ >.
 !,
   (()MN+
	  	 
	      c           
         UR                   nU R                  (       a  [        R                  " U5      (       a  [        R
                  " S5      eUR                  R                  UR                  R                  UR                  R                  R                  R                  UR                  5       UR                  R                  U R                  S9U R                  S9UR                  S9nUR                  R                   nGO?["        R$                  " U R&                  5      n["        R$                  " U R(                  5      n[        R                  " U5      (       ax  UR                  R+                  UR                  R                  UR                  5       UUU R                  S9UR,                  UR                  S9nUR                  R.                  nOlUR                  R                  UR                  R                  UR                  5       UUU R                  S9UR                  S9nUR                  R                   nUR1                  USU4/5      $ )z&Make a SslCertificates.Insert request.z9--domains flag is not supported for regional certificates)domains)r   namemanageddescription)sslCertificateproject)r$   certificate
privateKeyr&   )r'   regionr(   Insert)clientr#   r	   IsRegionalSslCertificatesRefcompute_exceptionsArgumentErrormessages#ComputeSslCertificatesInsertRequestSslCertificateTypeValueValuesEnumMANAGEDName#SslCertificateManagedSslCertificater&   r(   apitools_clientsslCertificatesr
   ReadFileContentsr)   private_key)ComputeRegionSslCertificatesInsertRequestr+   regionSslCertificatesMakeRequests)argsholderssl_certificate_refr-   request
collectionr)   r;   s           r   _RunrD   G   s   ==&	\\::;NOO,,
EG GooAA55//CCKK$))+OOGG H &(( 6 * $++ B -G ''77J(()9)9:K(()9)9:K::;NOOII77&++-%$**	 8 ,
 %++%-- J /g ))??jCC77&++-%$**	 8 ,
 &-- D /g ))99j			z8W=>	??r!   c                   2    \ rS rSrSrSr\S 5       rS rSr	g)Creates   a8  Create a Compute Engine SSL certificate resource.

*{command}* is used to create SSL certificate resources. An SSL certificate
resource consists of the certificate itself and a private key. The private key
is encrypted before it is stored.

You can create either a managed or a self-managed SslCertificate resource. A
managed SslCertificate is provisioned and renewed for you, when you specify
the `--domains` flag. A self-managed certificate is created by passing the
certificate obtained from Certificate Authority through `--certificate` and
`--private-key` flags.
Nc                     UR                   R                  [        R                  5        [        R                  " 5       U l        U R
                  R                  USS9  [        U5        g )Ncreate)operation_type)r   	AddFormatr   DEFAULT_LIST_FORMATSslCertificateArgumentSSL_CERTIFICATE_ARGAddArgumentr    )clsr   s     r   ArgsCreate.Args   sM    
!!%";";<#::<C''x'H	&Mr!   c                     [         R                  " U R                  5       5      nU R                  R	                  XR
                  [        R                  R                  S9n[        XU5      $ )z<Issues the request necessary for adding the SSL certificate.)default_scope)
r   ComputeApiHolderReleaseTrackrN   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALrD   )selfr?   r@   rA   s       r   Run
Create.Run   s^    **4+<+<+>?F22DDm.E.E.L.L E N122r!    )
__name__
__module____qualname____firstlineno____doc__rN   classmethodrQ   r]   __static_attributes__r_   r!   r   rF   rF   s   s&      3r!   rF   z'Create a Compute Engine SSL certificateaR          *{command}* creates SSL certificate resources, which you can use in a
        target HTTPS or target SSL proxy. An SSL certificate resource consists
        of a certificate and private key. The private key is encrypted before it
        is stored.

        You can create either a managed or a self-managed SslCertificate
        resource. A managed SslCertificate is provisioned and renewed for you. A
        self-managed certificate is created by passing the
        certificate obtained from Certificate Authority through `--certificate`
        and `--private-key` flags.
        a          To create a self-managed certificate resource 'my-cert' from a
        certificate placed under path
        'foo/cert' and a private key placed under path 'foo/pk', run:

            $ {command} my-cert --certificate=foo/cert --private-key=foo/pk
        )briefDESCRIPTIONEXAMPLESN)rd   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer   r/   r   rY   3googlecloudsdk.command_lib.compute.ssl_certificatesr   r	   googlecloudsdk.core.utilr
   r    rD   ReleaseTracksrV   GABETAALPHACreateCommandrF   detailed_helpr_   r!   r   <module>ru      s    - 8 / ( O E E V *(V)@X D%%(($*;*;*@*@%%++-3T 3-3D 	2		# r!   