
                             S 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S
 jrSS jrSS jrSS jrS rSS jr\\\\S.r\\\\\S.rS rS rg)a  Functions 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)typesz1st genz2nd genCloudFunctionFunctionc                 `    [        U [        5      (       d  U$ SU ;   a  U S   $ SU ;   a  U S   $ U$ )zReturns textual information about functions state.

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

Returns:
  str containing information about the functions state.
statusstate)
isinstancedictdata	undefineds     2lib/googlecloudsdk/api_lib/functions/transforms.py_TransformStater   9   s@     
D$		>_=	    c                    [        U 5      nU[        :X  a>  SU ;   a  gSU ;   a  SU S   -   $ SU ;   a  SU S   R                  S5      S   -   $ S	U ;   a  g
U$ U[        :X  a  S	U ;   a  U S	   nUR	                  S5      n[
        R                  " U5      (       a  g[
        R                  " U5      (       a$  US   n[        S U 5       S5      nU(       a  SU-   $ SU;   a  SUS   R                  S5      S   -   $ g
gU$ )zReturns textual information about functions trigger.

Args:
  data: JSON-serializable 1st and 2nd gen Functions objects.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  str containing information about functions trigger.
httpsTriggerzHTTP Trigger
gcsTriggerzbucket: pubsubTriggerztopic: /eventTriggerzEvent Trigger	eventTypezCloud Audit LogeventFiltersc              3   r   #    U  H-  nUR                  S 5      S:X  d  M  UR                  S5      v   M/     g7f)	attributebucketvalueNget).0fs     r   	<genexpr>$_TransformTrigger.<locals>.<genexpr>l   s4      &A55%1 g&s   77NpubsubTopic)	_InferFunctionMessageFormatCLOUD_FUNCTIONsplitFUNCTIONr"   trigger_typesIsAuditLogTypeIsStorageTypenext)r   r   	data_typeevent_trigger
event_typeevent_filtersr   s          r   _TransformTriggerr4   L   s-    *$/). t$|,,,$o.44S9"===H>*m $$[1j		%	%j	1	1 &&z22%n5&
 
 f$
$	-	'=7==cB2FFF 	r   c                    U R                  S5      nU R                  S5      nU R                  S5      n[        X#U/5      (       a  [        $ U R                  S5      nU R                  S5      n[        XV/5      (       a  [        $ U$ )a  Returns Cloud Functions product version.

Infers data type by checking whether the object contains particular fields of
CloudFunction (1st Gen Function message type) or Function (2nd Gen Function
message type). Notes that Function can be used for both 1st Gen and 2nd Gen
functions.

Args:
  data: JSON-serializable 1st and 2nd gen Functions objects.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  str containing inferred product version.

entryPointbuildIdruntimebuildConfigserviceConfig)r"   anyr)   r+   )r   r   entry_pointbuild_idr8   build_configservice_configs          r   r(   r(      sy    " &+XXi (HHY'+	)**-(,88O,.,	'((O	r   c                     U R                  S5      nUS:X  a  [        $ US:X  a  [        $ [        X5      nU[        :X  a  [        $ U[
        :X  a  [        $ U$ )zReturns Cloud Functions product version.

Args:
  data: JSON-serializable 1st and 2nd gen Functions objects.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  str containing inferred product version.
environmentGEN_1GEN_2)r"   rB   rC   r(   r)   r+   )r   r   rA   r0   s       r   _TransformGenerationrD      sX     '+GLGL *$:). LHL	r   c                     / nU R                  S5       H;  nUS:X  a  UR                  [        5        US:X  d  M&  UR                  [        5        M=     SR	                  U5      $ )zReturns the supported environments for a runtime.

Args:
  data: JSON-serializable Runtimes object.

Returns:
  str containing inferred product version.
environmentsrB   rC   z, )r"   appendrB   rC   join)r   generationsenvs      r   _TransformEnvironmentsrK      sW     +XXn%c
g~
g~	 & 
;	r   c                 H    SU ;   a  U S   b  U S   R                  SU5      $ U$ )aR  Returns Cloud Functions upgrade state.

Upgrade state will only be available for gen1 functions which meet the upgrade
criteria

Args:
  data: JSON-serializable 1st and 2nd gen Functions objects in V2 resource
    format.
  undefined: Returns this value if the resource cannot be formatted.

Returns:
  String representing upgrade state.
upgradeInfoupgradeStater!   r   s     r   _TransformUpgradeStaterO      s4     dtM2>"">9==	r   )triggerr   
generationrF   )rP   r   rQ   rF   upgradestatec                      [         $ )z?Returns the functions specific resource transform symbol table.)_TRANSFORMS r   r   GetTransformsrV      s    	r   c                      [         $ )N)_TRANSFORMS_BETArU   r   r   GetTransformsBetarY      s    	r   N) )-)__doc__
__future__r   r   r   #googlecloudsdk.command_lib.eventarcr   r,   rB   rC   r)   r+   r   r4   r(   rD   rK   rO   rT   rX   rV   rY   rU   r   r   <module>r_      s    : '  ' F &2j@8 &( !&*	 !&** 
r   