
                             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  G d de	j                         Zy)z/Command for signing blobs for service accounts.    )absolute_import)division)unicode_literalsN)util)base)iam_util)log)filesc                   p    e Zd ZdZ ej
                  d       ej
                  d      dZed        Zd Z	y)SignBloba  Sign a blob with a managed service account key.

  This command signs a file containing arbitrary binary data (a blob) using a
  system-managed service account key.

  If the service account does not exist, this command returns a
  `PERMISSION_DENIED` error.
  z
          To sign a blob file with a system-managed service account key,
          run:

            $ {command} --iam-account=my-iam-account@my-project.iam.gserviceaccount.com input.bin output.bin
          z
        For more information on how this command ties into the wider cloud
        infrastructure, please see
        [](https://cloud.google.com/appengine/docs/java/appidentity/)
        )EXAMPLESzSEE ALSOc                 |    | j                  ddd       | j                  ddd       | j                  d	d
d       y )Nz--iam-accountTzThe service account to sign as.)requiredhelpinputz
INPUT-FILEz%A path to the blob file to be signed.)metavarr   outputzOUTPUT-FILEz4A path the resulting signed blob will be written to.)add_argument)parsers    -lib/surface/iam/service_accounts/sign_blob.pyArgszSignBlob.Args7   s[    
!%>  @  ,D  F  -&  '    c           
      (   t        j                         \  }}|j                  j                  |j	                  t        j                  |j                        |j                  t        j                  |j                                          }t        j                  |j                  |j                  d       t        j                   j#                  dj%                  |j                  |j                  |j                  |j&                               y )N)payload)namesignBlobRequestT)contentbinaryz4signed blob [{0}] as [{1}] for [{2}] using key [{3}])r   "GetIamCredentialsClientAndMessagesprojects_serviceAccountsr   4IamcredentialsProjectsServiceAccountsSignBlobRequestr   EmailToAccountResourceNameiam_accountSignBlobRequestr
   ReadBinaryFileContentsr   r	   WriteToFileOrStdoutr   
signedBlobstatusPrintformatkeyId)selfargsclientmessagesresponses        r   RunzSignBlob.RunF   s    >>@FH..77EE44T5E5EF$4444TZZ@ 5 B 	F 	CDH X00?JJ>EEJJT%5%5x~~	GHr   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r1    r   r   r   r      sR     "(// #  "(// # - ' 'Hr   r   )r5   
__future__r   r   r   r6   googlecloudsdk.api_lib.iamr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer	   googlecloudsdk.core.utilr
   Commandr   r:   r   r   <module>rB      s7     6 &  '  + ( 3 # *3Ht|| 3Hr   