
    E                         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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r " S S\R*                  " \R,                  \R.                  5      5      rS rg)zJCross-version utility classes and functions for gcloud functions commands.    )absolute_import)division)unicode_literalsN)Any)util)client)base)parser_extensions)flagsc                      ^  \ rS rSrSrU 4S jr\R                  S\R                  S\
4S j5       r\R                  S\R                  S\
4S j5       r\R                  S\R                  S\
4S j5       rS	rU =r$ )
FunctionResourceCommand!   a  Mix-in for single function resource commands that work with both v1 or v2.

Which version of the command to run is determined by the following precedence:
1. Explicit setting via the --gen2/--no-gen2 flags or functions/gen2 property.
2. The generation of the function if it exists.
3. The v2 API by default if the function doesn't exist.

Subclasses should add the function resource arg and --gen2 flag.
c                 <   > [         [        U ]
  " U0 UD6  S U l        g )N)superr   __init___v2_function)selfargskwargs	__class__s      0lib/googlecloudsdk/command_lib/functions/util.pyr    FunctionResourceCommand.__init__,   s     	
!414B6BD    r   returnc                     g)z$Runs the command against the v1 API.N r   r   s     r   _RunV1FunctionResourceCommand._RunV10       r   c                     g)z$Runs the command against the v2 API.Nr   r   s     r   _RunV2FunctionResourceCommand._RunV24   r    r   c                 P   [         R                  " 5       (       a  U R                  U5      $ [         R                  " 5       (       a  U R	                  U5      $ [
        R                  " U R                  5       5      nUR                  UR                  R                  R                  5       R                  5       5      U l        U R                  (       aE  [        U R                  R                  5      S:X  a  U R                  U5      $ U R	                  U5      $ U R                  U5      $ )zRuns the command.

Args:
  args: The arguments this command was invoked with.

Returns:
  The result of the command.

Raises:
  HttpException: If an HttpError occurs.
GEN_2)r   ShouldUseGen2r"   ShouldUseGen1r   	client_v2FunctionsClientReleaseTrackGetFunctionCONCEPTSnameParseRelativeNamer   strenvironment)r   r   r   s      r   RunFunctionResourceCommand.Run8   s     [[[[&&t'8'8':;F**  "//1D 	T**	+w	6{{4  {{4  ;;tr   )r   )__name__
__module____qualname____firstlineno____doc__r   abcabstractmethodr
   	Namespacer   r   r"   api_util_v1 CatchHTTPErrorRaiseHTTPExceptionr2   __static_attributes____classcell__)r   s   @r   r   r   !   s     /*44 / / / /*44 / / / //'11 c  0r   r   c                 R    [         R                  " SSU R                  SS5      5      $ )zFormats a timestamp which will be presented to a user.

Args:
  timestamp: Raw timestamp string in RFC3339 UTC "Zulu" format.

Returns:
  Formatted timestamp string.
z(\.\d{3})\d*Z$z\1T )resubreplace)	timestamps    r   FormatTimestamprG   Y   s%     
!5)*;*;C*E	FFr   )r8   
__future__r   r   r   r9   rC   typingr   #googlecloudsdk.api_lib.functions.v1r   r<   #googlecloudsdk.api_lib.functions.v2r   r(   googlecloudsdk.callioper	   r
   $googlecloudsdk.command_lib.functionsr   sixwith_metaclassABCMetaCommandr   rG   r   r   r   <module>rR      sW    Q &  ' 
 	  C C ( 5 6 
5c00dllK 5p	Gr   