
    A                         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	KJr  SS
KJr  SSKJr  \	R"                   " S S\	R$                  5      5       rg)z:Implementation of service agent command for Cloud Storage.    )absolute_import)division)unicode_literalsN)api_factory)base)requests)storage_url)log)
propertiesc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
ServiceAgent   z^Manage a project's Cloud Storage service agent, which is used to perform Cloud KMS operations.z
      *{command}* displays the Cloud Storage service agent, which is used to
      perform Cloud KMS operations against your a default or supplied project.
      If the project does not yet have a service agent, *{command}* creates one.

      aj  
      To show the service agent for your default project:

        $ {command}

      To show the service account for ``my-project'':

        $ {command} --project=my-project

      To authorize your default project to use a Cloud KMS key:

        $ {command} --authorize-cmek=projects/key-project/locations/us-east1/keyRings/key-ring/cryptoKeys/my-key
      )DESCRIPTIONEXAMPLESc                 L    U R                  S[        R                  " S5      S9  g )Nz--authorize-cmeka              Adds appropriate encrypt/decrypt permissions to the specified Cloud
            KMS key. This allows the Cloud Storage service agent to write and
            read Cloud KMS-encrypted objects in buckets associated with the
            service agent's project.)help)add_argumenttextwrapdedent)parsers    $lib/surface/storage/service_agent.pyArgsServiceAgent.Args;   s)    
__ ( )  *    c                    [         R                  " [        R                  R                  5      nUR                  5       nUR                  (       a  [        R                  " UR                  SU-   5        [        R                  " SR                  [        R                  R                  R                  R!                  5       UR                  5      5        g [        R                  " U5        g )NzserviceAccount:z9Authorized project {} to encrypt and decrypt with key:
{})r   get_apir	   ProviderPrefixGCSget_service_agentauthorize_cmekr   AddCryptoKeyPermissionr
   Printformatr   VALUEScoreprojectGet)selfargsapiservice_agents       r   RunServiceAgent.RunE   s    


k88<<
=C))+M%%d&9&9&7-&GI	ii
F
M
M$$,,002D4G4GIJ 
iir    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r,   __static_attributes__r.   r   r   r   r      s/    f

-0 * *r   r   )r3   
__future__r   r   r   r   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr   "googlecloudsdk.command_lib.storager	   googlecloudsdk.corer
   r   UniverseCompatibleCommandr   r.   r   r   <module>r?      sN    A &  '  6 ( 9 : # * 04<< 0 0r   