
                             S r SSKJr  SSKJr  SSKJr  SSKrSSK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
 rS rS rS rS rg)zUtil functions for DM commands.    )absolute_import)division)unicode_literalsN)
exceptions)log)resource_printer)http_encodingc                 p    [         R                  R                  S[        R                  " U 5      -  5        g)z*Prints the fingerprint for user reference.z'The fingerprint of the deployment is %sN)r   statusPrintbase64urlsafe_b64encode)fingerprints    <lib/googlecloudsdk/command_lib/deployment_manager/dm_util.pyPrintFingerprintr       s,     **<..{;= >    c                      [         R                  " [        R                  " U 5      5      nU$ ! [        [
        R                  4 a    [        R                  " SS5      ef = f)z+Returns the base64 url decoded fingerprint.z--fingerprintzfingerprint cannot be decoded.)	r   urlsafe_b64decoder	   Encode	TypeErrorbinasciiErrorcalliope_exceptionsInvalidArgumentException)r   decoded_fingerprints     r   DecodeFingerprintr   '   sa    ; 22[)+
 
 X^^	$ ;

6
69; ;;s	   *. 2A c                     US:X  a  U R                  SS9$ UR                  S5      (       a*  U R                  U[        S5      S S9nU R                  US9$ [        R
                  " SS	5      e)
a/  Translates a dict of credential data into a message object.

Args:
  message: The API message to use.
  principal: A string contains service account data.
Returns:
  An ServiceAccount message object derived from credential_string.
Raises:
  InvalidArgumentException: principal string unexpected format.
PROJECT_DEFAULTT)useProjectDefaultzserviceAccount:N)email)serviceAccountz--credentialzBcredential must start with serviceAccount: or use PROJECT_DEFAULT.)
Credential
startswithServiceAccountlenr   r   )message	principalservice_accounts      r   CredentialFromr)   2   s     ##55+,,,,-./0 - 2O_==44J	L Lr   c                 x    [         R                  " 5       n[        R                  " U SUS9  UR	                  5       $ )zReturns a ready-to-print string representation for the provided message.

Args:
  message: message object

Returns:
  A ready-to-print string representation of the message.
yaml)out)ioStringIOr   r   getvalue)r&   output_messages     r   RenderMessageAsYamlr1   H   s0     ;;=.&n=		 	 	""r   c           	         U R                   (       aD  [        R                  " SR                  XR                  [        U R                   5      5      5        g[        R                  R                  SR                  XR                  5      5        g)z'Log operation warnings if there is any.z.{0} operation {1} completed with warnings:
{2}z){0} operation {1} completed successfully.N)warningsr   warningformatnamer1   r   r   )	operationoperation_descriptions     r   LogOperationStatusr9   V   sc    KK9@@!>>	 2 23	56 JJ@GG~~/ 0r   )__doc__
__future__r   r   r   r   r   r-   googlecloudsdk.callioper   r   googlecloudsdk.corer   googlecloudsdk.core.resourcer   googlecloudsdk.core.utilr	   r   r   r)   r1   r9    r   r   <module>rA      sB     & &  '   	 E # 9 2>L,#
0r   