
                         2   d Z ddlmZ ddlmZ ddlmZ ddl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 ej*                  ej,                  j.                  ej,                  j0                         G d dej2                               Zy)z9Command to get the public certificate of an Azure Client.    )absolute_import)division)unicode_literalsN)encoding)azure)base)resource_args)endpoint_util)flags)loga  
To get the public certificate of an Azure client named ``my-client'' in
location ``us-west1'', run:

$ {command} my-client --location=us-west1

To store the certificate in a file named ``client.crt'', run:

$ {command} my-client --location=us-west1 --output-file=client.crt
c                   4    e Zd ZdZdeiZed        Zd Zd Z	y)GetPublicCertz.Get the public certificate of an Azure client.EXAMPLESc                 \    t        j                  | d       t        j                  | d       y )Nzto get the public certificatezto store PEM)r	   AddAzureClientResourceArgr   AddOutputFile)parsers    6lib/surface/container/azure/clients/get_public_cert.pyArgszGetPublicCert.Args2   s(    ++/ 
/    c                    t        j                  t        j                  |      j                  | j                               5  t        j                  |      }t        j                         }|j                  |      }| j                  |      }t        j                  |j                  r|j                  nd|ddd       ddd       y# 1 sw Y   yxY w)z!Runs the get-public-cert command.-TF)	overwritebinaryprivateN)r
   GkemulticloudEndpointOverrider	   ParseAzureClientResourceArglocationsIdReleaseTrackapi_utilClientsClientGet_GetCertr   WriteToFileOrStdoutoutput_file)selfargs
client_ref
api_clientclientcerts         r   RunzGetPublicCert.Run9   s    		4	411$7CC
 !<<TBj))+j~~j)f]]6"d	"..$

C

 
 
s   A>C		Cc                     |j                   r|j                   S t        j                  |      }d|v r't        j                  |d   j                  d            S y )Ncertificatezutf-8)pemCertificater   MessageToPyValuebase64	b64decodeencode)r&   r*   client_dicts      r   r#   zGetPublicCert._GetCertK   sW    """ ++F3K#k-8??HII $r   N)
__name__
__module____qualname____doc__	_EXAMPLESdetailed_helpstaticmethodr   r,   r#    r   r   r   r   ,   s,    6y)-0 0$Jr   r   )r8   
__future__r   r   r   r1   apitools.base.pyr   .googlecloudsdk.api_lib.container.gkemulticloudr   r    googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.azurer	   2googlecloudsdk.command_lib.container.gkemulticloudr
   r   googlecloudsdk.corer   r9   ReleaseTracksr   ALPHAGADescribeCommandr   r<   r   r   <module>rH      s    @ &  '  % L ( D L D #		 D%%++T->->-A-AB&JD(( &J C&Jr   