
    3                        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Sr\R:                  " \R<                  R>                  \R<                  R@                  5      \RB                   " S S\RD                  5      5       5       r#g)z&Command to import an Attached cluster.    )attached)	locations)base)cluster_util)flags)resource_args)	kube_util)command_util)	constants)endpoint_util)pretty_print)
exceptions)
console_io)retryNa8  
To import the fleet membership of an attached cluster in fleet ``FLEET_MEMBERSHIP'' managed in location ``us-west1'', run:

$ {command} --location=us-west1 --platform-version=PLATFORM_VERSION --fleet-membership=FLEET_MEMBERSHIP --distribution=DISTRIBUTION --context=CLUSTER_CONTEXT --kubeconfig=KUBECONFIG_PATH
c                   H    \ rS rSrSrS\0r\S 5       rS r	S r
S rS rS	rg
)Import*   z0Import fleet membership for an Attached cluster.EXAMPLESc                    [         R                  " U S5        [         R                  " U 5        [        R                  " U 5        [        R
                  " U SS9  [        R                  " U 5        [        R                  " U 5        [        R                  " U 5        [        R                  " U S5        [        R                  R                  U 5        g)z!Registers flags for this command.zto import attached cluster.T)requiredzcluster to importN)r   AddLocationResourceArgAddFleetMembershipResourceArgattached_flagsAddPlatformVersionAddDistribution
AddKubectlAddProxyConfigAddSkipClusterAdminCheckr   AddValidateOnlyr   
ASYNC_FLAGAddToParser)parsers    1lib/surface/container/attached/clusters/import.pyArgsImport.Args1   s     ((1NO//7%%f-""6D9f%!!&)++F3	&"56OO'    c           
         UR                   R                  R                  5       nUR                   R                  R                  5       n[        R
                  " UR                  5         U R                  XUR                  5      nSn[        R                  " [        R                  " U5      [        R                  " U5      SS9 n[        R                  " U5      (       d  UR                  5          [         R"                  " U5      (       dw  [$        R&                  " S5        UR)                  U5        [*        R,                  " [.        R0                  S9nUR3                  [4        R6                  U4[.        R8                  S9  U R;                  XU5      nU R?                  XU5        S	S	S	5        UsS	S	S	5        $ ! [*        R<                   ac  nU R?                  XU5        UR@                  S   (       a7  [B        RD                  " UR@                  S   S   UR@                  S   S   5        e S	nAf[F        RH                   a    S
RK                  [L        RN                  " U RQ                  5       5      RS                  5       UR                  [        RT                  " U5      UR                  5      n	[$        R&                  " U	5        e   U R?                  XU5        e = f! , (       d  f       GN== f! , (       d  f       g	= f)zRuns the import command. T)
kubeconfigcontextenable_workload_identityz!Creating in-cluster install agent)max_retrials)argssleep_ms      NzTo manually clean up the in-cluster install agent, run:

$ gcloud {} container attached clusters generate-install-manifest --location={} --platform-version={} --format="value(manifest)"  {}  | kubectl delete -f -

AFTER the attach operation completes.
)+CONCEPTSlocationParsefleet_membershipr   GkemulticloudEndpointOverridelocationsId_get_manifestmembershipsIdr	   KubernetesClientr   GetKubeconfig
GetContextGetSkipClusterAdminCheckCheckClusterAdminPermissionsr   GetValidateOnlyr   InfoApplyr   Retryerr   %ATTACHED_INSTALL_AGENT_VERIFY_RETRIESRetryOnExceptionr   verify_install_agent_deployed%ATTACHED_INSTALL_AGENT_VERIFY_WAIT_MS_import_attached_clusterRetryException_remove_manifestlast_resultr   reraiser   OperationCancelledErrorformatsix	text_typeReleaseTracklowerGetPlatformVersion)
selfr-   location_reffleet_membership_refmanifestimport_respkube_clientretryeremsgs
             r#   Run
Import.RunA   sr   ==))//1L==99??A		4	4\5M5M	N##
2@@h k%%#11$7 ++D1#' 66t<<

2
2
4)	&&t,,ABh'mm&LLG $$::!^"HH %  55"6+< 	d:gj w 
O	N< ## 	


8
<
 ]]1q}}Q/2AMM!4DQ4GH
11 	
 FmmD--/0668&&//5"00	  

C
 
	


8
<
c  
O	NsL   )AK1,K3B$F<K)	K1<KAH..B.KK
K.	)K11
K?c                 d    [         R                  " 5       nUR                  X#US9nUR                  $ )N)r-   )loc_utilLocationsClient GenerateInstallManifestForImportrU   )rR   r-   rS   memberships_idlocation_clientresps         r#   r7   Import._get_manifest   s6    ..0O;;4 < D ==r&   c                     [         R                  " U5      (       d(  [        R                  " S5        UR	                  U5        g g )Nz!Deleting in-cluster install agent)r   r>   r   r?   Delete)rR   r-   rW   rU   s       r#   rH   Import._remove_manifest   s5      &&;<" 'r&   c           	          [         R                  " 5       n[        R                  " UR	                  5       S[
        R                  S9n[        R                  " UUUUU[
        R                  S9$ )N	Importing)actionkind)rS   resource_clientrT   r-   messagerk   )	api_utilClustersClientr
   ClusterMessageRelativeNamer   ATTACHEDr   ATTACHED_CLUSTER_KIND)rR   r-   rS   rT   cluster_clientrm   s         r#   rF   Import._import_attached_cluster   se    ,,.N))))+G
 !&1,, r&    N)__name__
__module____qualname____firstlineno____doc__	_EXAMPLESdetailed_helpstaticmethodr$   r[   r7   rH   rF   __static_attributes__rv   r&   r#   r   r   *   s9     9y)-( (@D#
r&   r   )$r{   .googlecloudsdk.api_lib.container.gkemulticloudr   rn   r   r^   googlecloudsdk.callioper   -googlecloudsdk.command_lib.container.attachedr   r   r   r   *googlecloudsdk.command_lib.container.fleetr	   2googlecloudsdk.command_lib.container.gkemulticloudr
   r   r   googlecloudsdk.command_lib.runr   googlecloudsdk.corer   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   rM   r|   ReleaseTracksrO   ALPHAGADefaultUniverseOnlyCommandr   rv   r&   r#   <module>r      s    - P P ( F Q G @ K H L D 7 * 2 * 
	 D%%++T->->-A-ABqT\\ q  Cqr&   