
                         4   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ	 ddlm
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlZ ej2                  ej4                  j6                         G d dej8                               Zy)z$Delete a root certificate authority.    )absolute_import)division)unicode_literals)tz)base)request_utils)waiter)flags)
operations)resource_args)log)
console_io)timesNc                   &    e Zd ZdZed        Zd Zy)Deletea  Delete a Root Certificate Authority.

    Delete a Root Certificate Authority. Deleted Root Certificate Authorities
    may be recovered with the `{parent_command} undelete` command within a grace
    period of 30 days.

    Use the --skip-grace-period flag to delete as soon as possible without the
    30-day grace period to undelete.

    Note that any user-managed KMS keys or Google Cloud Storage buckets
    will not be affected by this operation. You will need to delete the user-
    managed resources separately once the CA is deleted. Any Google-managed
    resources will be cleaned up.

    The CA specified in this command MUST:

      1) be in the DISABLED or STAGED state.
      2) have no un-revoked or un-expired certificates. Use the revoke command
         to revoke any active certificates.

    Use the `--ignore-active-certificates` flag to remove 2) as a requirement.

    ## EXAMPLES

    To delete a root CA:

      $ {command} prod-root --pool=my-pool --location=us-west1

    To delete a CA while skipping the confirmation
    input:

      $ {command} prod-root --pool=my-pool --location=us-west1 --quiet

    To undo the deletion for a root CA:

      $ {parent_command} undelete prod-root --pool=my-pool --location=us-west1
  c                     t        j                  | d       t        j                  |        t        j                  |        t        j
                  |        y )Nz	to delete)r   %AddCertAuthorityPositionalResourceArgr
   AddIgnoreActiveCertificatesFlagAddSkipGracePeriodFlagAddIgnoreDependentResourcesFlag)parsers    %lib/surface/privateca/roots/delete.pyArgszDelete.ArgsL   s<    77L	))&1	  (	))&1    c           
         t        j                  d      }t        j                  d      }|j                  j                  j                         }dj                  |j                               }|j                  r|dz  }|j                  r|dz  }t        j                  |d      s t        j                  j                  d       y |j                  j!                  |j#                  |j                         	            }t%        j&                  |j(                  j*                  j,                  |d
       |j                  j/                  |j1                  |j                         |j2                  |j                  |j                  t5        j6                                     }	 t9        j:                  |dd      }t9        jF                  ||j(                        }
tI        jJ                  |
jL                        jO                  tQ        jR                               jU                  d      }|j                  r=t        j                  j                  dj                  |j                                      y t        j                  j                  dj                  |j                         |             y # t<        j>                  $ r=}	t9        j>                  tA        jB                  |	      jE                  dd            d }	~	ww xY w)Nv1)api_versionz3You are about to delete Certificate Authority [{}].z
This deletion will happen without checking if the CA's CA Pool is being used by another resource, which may cause unintended and effects on any dependent resource(s) since the CA Pool would not be able to issue certificates.z
This deletion will happen as soon as possible without a 30-day grace period where undeletion would have been allowed. If you proceed, there will be no way to recover this CA.T)messagedefaultzAborted by user.)name)version)r    ignoreActiveCertificatesskipGracePeriodignoreDependentResources	requestIdzDeleting Root CAz&`ignore_active_certificates` parameterz#`--ignore-active-certificates` flagz%Y-%m-%dT%H:%MZz.Deleted Root CA [{}]. CA can not be undeleted.z3Deleted Root CA [{}]. CA can be undeleted until {}.)+privateca_baseGetClientInstanceGetMessagesModuleCONCEPTScertificate_authorityParseformatRelativeNameignore_dependent_resourcesskip_grace_periodr   PromptContinuer   statusPrint1projects_locations_caPools_certificateAuthoritiesGetAPrivatecaProjectsLocationsCaPoolsCertificateAuthoritiesGetRequestr   CheckExpectedCATypeCertificateAuthorityTypeValueValuesEnumSELF_SIGNEDr   DPrivatecaProjectsLocationsCaPoolsCertificateAuthoritiesDeleteRequestignore_active_certificatesr   GenerateRequestIdr   Awaitr	   OperationErrorsix	text_typereplaceGetMessageFromResponser   ParseDateTime
expireTime
astimezoner   tzutcstrftime)selfargsclientmessagesca_refprompt_message
current_ca	operationca_responseecaformatted_expire_times               r   Runz
Delete.RunS   s   --$?F//DAH]]00668F 	>vv!@#  &&()n /0n $$^TJ	jj)*IIMM	J	J$$& 
K 
()J
 %%%%99EE
 HHOO	M	M$$&%)%D%D 22%)%D%D#557 
N 
9:IK$$
'T;k 
	*	*;+3+H+H
JB "//>II

H./  	jjGNN



! " 
jj
?
F
F!!#%:<=!    K %%
--

"
"#K#HJK KKs   &J4 4L8K??LN)__name__
__module____qualname____doc__staticmethodr   rT    r   r   r   r   $   s"    $L 2 2C=r   r   )rX   
__future__r   r   r   dateutilr    googlecloudsdk.api_lib.privatecar   r&   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.calliope$googlecloudsdk.command_lib.privatecar
   r   r   googlecloudsdk.corer   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   r?   ReleaseTracksReleaseTrackGADeleteCommandr   rZ   r   r   <module>rh      st    + &  '  C : . ( 6 ; > # 2 * 
 D%%(()q=T q= *q=r   