
    ]                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSK	Jr   " S	 S
\
R                  5      rg)z=Fetch Hub-registered cluster credentials for Connect Gateway.    )absolute_import)division)unicode_literalsN)util)gateway)	resourcesc                   .    \ rS rSrSr\S 5       rS rSrg)GetCredentials   a  Fetch credentials for a fleet-registered cluster to be used in Connect Gateway.

{command} updates the `kubeconfig` file with the appropriate credentials and
endpoint information to send `kubectl` commands to a fleet-registered and
-connected cluster through the Connect Gateway service.

It takes a project, passed through by set defaults or flags. By default,
credentials are written to `$HOME/.kube/config`. You can provide an alternate
path by setting the `KUBECONFIG` environment variable. If `KUBECONFIG`
contains multiple paths, the first one is used.

Upon success, this command will switch the current context to the target
cluster if other contexts are already present in the `kubeconfig` file.

## EXAMPLES

  Get the Gateway kubeconfig for a globally registered cluster:

    $ {command} my-cluster
    $ {command} my-cluster --location=global

  Get the Gateway kubeconfig for a cluster registered in us-central1:

    $ {command} my-cluster --location=us-central1
c           	          [         R                  " U[        R                  " S5      [        R                  " S5      SSS9  UR	                  SSSS[        R                  " S5      S	9  UR	                  S
SSS[        R                  " S5      S	9  g )Nz          The membership name that you choose to uniquely represent the cluster
          being registered in the fleet.
        z          The location of the membership resource, e.g. `us-central1`.
          If not specified, attempts to automatically choose the correct region.
        T)membership_helplocation_helpmembership_required
positionalz--use-client-side-generation
store_trueFzi          Generate the kubeconfig locally rather than generating
          it using an API call.
        )actionrequiredhiddenhelpz--force-use-agentzB          Force the use of Connect Agent-based transport.
        )r   AddMembershipResourceArgtextwrapdedentadd_argument)clsparsers     :lib/surface/container/fleet/memberships/get_credentials.pyArgsGetCredentials.Args7   s    &&  )  oo '  ! &__    	 __        c                    [         R                  " U5      n[        R                  " U5      n[        R                  " U5      nUR
                  (       a  U R                  XC5        g U R                  XCUR                  S9  g )N)force_use_agent)	r   ParseMembershipArg
fleet_utilMembershipLocationMembershipShortnameuse_client_side_generationRunGetCredentialsRunServerSider!   )selfargsmembership_namelocationmembership_ids        r   RunGetCredentials.Run]   sg    2248O,,_=H22?CM&&
]5

43G3G  r    N)	__name__
__module____qualname____firstlineno____doc__classmethodr   r.   __static_attributes__r0   r   r   r
   r
      s!    4 # #J
r   r
   )r5   
__future__r   r   r   r   &googlecloudsdk.api_lib.container.fleetr   r#   *googlecloudsdk.command_lib.container.fleetr   r   GetCredentialsCommandr
   r0   r   r   <module>r<      s4    D &  '  E > @KW22 Kr   