
                            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	Zd
 Z ej                   ej"                  j$                  ej"                  j&                         G d dej(                               Zy)z$Fetch Config Controller credentials.    )absolute_import)division)unicode_literals)api_adapter)util)base)logzNConfig Controller {0} is not running. The kubernetes API may not be available.c                    t        j                          d| j                  z   }| j                  }d}t	        j
                  d      }t        j                  j                  d       |j                  |||      }|j                  |      }|j                  |      s2t        j                  t        j                  |j                               ||fS )z2Base operations for `get-credentials` run command.zkrmapihost-Nv1z(Fetching cluster endpoint and auth data.)container_utilCheckKubectlInstallednamelocationcontainer_api_adapterNewAPIAdapterr	   statusPrintParseCluster
GetCluster	IsRunningwarningNOT_RUNNING_MSGformat	clusterId)args
cluster_idlocation_idprojectgke_apicluster_refclusters          7lib/surface/anthos/config/controller/get_credentials.py_BaseRunr#      s    &&(tyy(*+'!//5'**=>$$ZgF+{+'			7	#KK&&{'<'<=>	+	    c                   .    e Zd ZdZddiZed        Zd Zy)GetCredentialsAlphazFetch credentials for a running Anthos Config Controller.

  {command} updates a `kubeconfig` file with appropriate credentials and
  endpoint information to point `kubectl` at a specific
  Anthos Config Controller.
  EXAMPLESz          To switch to working on your Config Controller 'main', run:

            $ {command} main --location=us-central1
      c                 R    | j                  dd       | j                  ddd       y)	zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    r   z%Name of the Anthos Config Controller.)helpz
--locationTz6The location (region) of the Anthos Config Controller.)requiredr)   N)add_argument)parsers    r"   ArgszGetCredentialsAlpha.ArgsB   s5     %LM
E  Gr$   c                 t    t        |      \  }}t        j                  j                  ||j                         y)a  This is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Raises:
      container_util.Error: if the cluster is unreachable or not running.
    N)r#   r   ClusterConfigPersist	projectId)selfr   r!   r    s       r"   RunzGetCredentialsAlpha.RunP   s.     $D>G[  ((+2G2GHr$   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr-   r3    r$   r"   r&   r&   1   s4     
- G GIr$   r&   N)r7   
__future__r   r   r    googlecloudsdk.api_lib.containerr   r   r   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r   r#   ReleaseTracksReleaseTrackALPHAGACommandr&   r:   r$   r"   <module>rD      sv    + &  ' Q C ( #R& D%%++T->->-A-AB)I$,, )I C)Ir$   