
    $                         S 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  SSKJr  SS	KJr  SS
KJr  SS jrSS jrSS jrSS jrSS jr\\\\\S.rS rg)a  CloudBuild resource transforms and symbols dict.

A resource transform function converts a JSON-serializable resource to a string
value. This module contains built-in transform functions that may be used in
resource projection and filter expressions.

NOTICE: Each TransformFoo() method is the implementation of a foo() transform
function. Even though the implementation here is in Python the usage in resource
projection and filter expressions is language agnostic. This affects the
Pythonicness of the Transform*() methods:
  (1) The docstrings are used to generate external user documentation.
  (2) The method prototypes are included in the documentation. In particular the
      prototype formal parameter names are stylized for the documentation.
  (3) The 'r', 'kwargs', and 'projection' args are not included in the external
      documentation. Docstring descriptions, other than the Args: line for the
      arg itself, should not mention these args. Assume the reader knows the
      specific item the transform is being applied to. When in doubt refer to
      the output of $ gcloud topic projections.
  (4) The types of some args, like r, are not fixed until runtime. Other args
      may have either a base type value or string representation of that type.
      It is up to the transform implementation to silently do the string=>type
      conversions. That's why you may see e.g. int(arg) in some of the methods.
  (5) Unless it is documented to do so, a transform function must not raise any
      exceptions related to the resource r. The `undefined' arg is used to
      handle all unusual conditions, including ones that would raise exceptions.
      Exceptions for arguments explicitly under the caller's control are OK.
    )absolute_import)division)unicode_literals)encoding)client)apis)
properties)	resources)resource_transformc                    [         R                  " SS5      n[        R                  " XR                  5      nUR
                  c  U$ UR
                  R                  nU(       d  U$ / nU H>  nUR                  c  UR                  U5        M#  UR                  UR                  5        M@     [        U5      S:  a#  US   SR                  [        U5      S-
  5      -   $ US   $ )zReturns the formatted build results images.

Args:
  r: JSON-serializable object.
  undefined: Returns this value if the resource cannot be formatted.
Returns:
  The formatted build results images.

cloudbuildv1   r   z (+{0} more))	core_apisGetMessagesModuleapitools_encodingDictToMessageBuildresultsimagesnameappendlenformat)r	undefinedmessagesbr   namesis          3lib/googlecloudsdk/api_lib/cloudbuild/transforms.pyTransformBuildImagesr"   9   s     ((t<(%%a8!YY99&	
%avv~ll9ll166	 
 	Z!^8n++CJqL999	q/    c                 x   [         R                  " SS5      n[        R                  " XR                  5      nUR
                  c  U$ UR
                  R                  nUb1  UR                  nUR                  nUb  Uc  U$ SR                  XV5      $ UR
                  R                  nUbu  UR                  =(       d    SnUR                  n	U	b  SR                  X5      $ UR                  n
U
b  SR                  X5      $ UR                  nUb  SR                  X5      $ UR
                  R                  nUb,  UR                   nUR"                  nUb  SR                  X5      $ UR
                  R$                  nUb1  UR                  nUR                  nUb  Uc  U$ SR                  XV5      $ UR
                  R&                  nUb-  UR(                  nUR"                  nUb  SR                  UU5      $ UR
                  R*                  nUb-  UR,                  nUR"                  nUb  SR                  UU5      $ U$ )zReturns the formatted build source.

Args:
  r: JSON-serializable object.
  undefined: Returns this value if the resource cannot be formatted.
Returns:
  The formatted build source.
r   r   zgs://{0}/{1}defaultz{0}@{1})r   r   r   r   r   sourcestorageSourcebucketobjectr   
repoSourcerepoName
branchNametagName	commitSha	gitSourceurlrevisionstorageSourceManifestconnectedRepository
repositorydeveloperConnectConfiggitRepositoryLink)r   r   r   r   storage_sourcer(   objrepo_source	repo_namebranch_nametag_name
commit_sha
git_sourcer0   r1   storage_source_manifestconnected_repositoryr4   developer_connect_configgit_repository_links                       r!   TransformBuildSourcerC   T   s-    ((t<(%%a8!XX88)).""F


C~  --##+$$1	I((Ki55""Hi22&&Ji44xx!!*
..C""H
c,,HH::($++F
!
(
(C~  --55%%00J#,,Hj(33XX<<)2DD'00H&18<<	r#   c           
      l   [         R                  " SS5      n[        R                  " XR                  5      n[
        R                  R                  UR                  S   R                  5      nSU;   a  [        R                  " USSSSSSS	5      $ S
U;   a  [        R                  " USS
SSSSS	5      $ U$ )zReturns the formatted result duration.

Args:
  resource: JSON-serializable object.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  The formatted result duration.
r   v2r   completion_time
start_time   Fr   -finish_time)r   r   r   r   Result
hub_client	HubClientToPyDictrecordSummaries
recordDatar   TransformDuration)resourcer   r   resultrecord_datas        r!   TransformResultDurationrU      s     ((t<(**8__E&$$--Q**,++%//\0A1a0138 8 k!//\0=q!UA035 5 
r#   c                     [         R                  " SS5      n[        R                  " XR                  5      nUR
                  S   n[        R                  R                  UR                  5      nUR                  b  UR                  $ SU;   d  SU;   a  gSnSnS HR  nUR                  S	U S
35      n	U	S:X  a  UR                  S	U S35      nM5  U	S:X  d  M=  UR                  S	U S35      nMT     US:X  a  gUS:X  a  gUS:X  a  gUS:X  a  gU$ )zReturns the formatted result status.

Args:
  resource: JSON-serializable object.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  The formatted result status.
r   rE   r   pipeline_run_statustask_run_status	CANCELLED )r   r   zconditions[z].type	Succeededz].statusDequeuedTRUESUCCESSFALSEFAILUREIN_PROGRESSQUEUED)r   r   r   r   rK   rO   rL   rM   rN   rP   statusget)
rR   r   r   rS   record_summaryrT   succeeded_statusdequeued_statusindexcondition_types
             r!   TransformResultStatusrj      s     ((t<(**8__E&))!,.$$--n.G.GH+&   k)->+-M/e __{5'%@AN$$;ugX)FG	:	%#+eWH(EFo   	r#   Nc                 &   [         R                  " SS5      n[        XR                  5      (       aO  [        R
                  R                  S U R                  U R                  S.SS9nUR                  5       =(       d    U$ [        XR                  5      (       av  [        R                  R                  R                  R                  SS9n[        R
                  R                  S UU R                  S.S	S9nUR                  5       =(       d    U$ U$ )
Nr   r   )	projectIdidzcloudbuild.projects.builds)params
collectionT)required)rl   	triggerIdzcloudbuild.projects.triggers)r   r   
isinstancer   r
   REGISTRYParserl   rm   SelfLinkBuildTriggerr	   VALUEScoreprojectGet)rR   r   r   	build_refry   trigger_refs         r!   _GetUrir}      s    ((t<(..))""((!++++
 0 ) 1I ,9,(1122$$,,00$0?G$$** !
 2 + 3K !.Y.r#   )build_imagesbuild_sourceresult_durationresult_statusuric                      [         $ )z@Returns the cloudbuild specific resource transform symbol table.)_TRANSFORMS r#   r!   GetTransformsr      s    	r#   )rZ   )N)__doc__
__future__r   r   r   apitools.base.pyr   r   &googlecloudsdk.api_lib.container.fleetr   rL   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer	   r
   googlecloudsdk.core.resourcer   r"   rC   rU   rj   r}   r   r   r   r#   r!   <module>r      s`   "8 '  ' : G 9 * ) ;6@F2$N4 )(.*r#   