
    0                        d 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	 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 dd
lmZ ddlmZ ddlmZ d Zd Z ej2                  ej4                  j6                         G d dej8                  ej:                               Z ej2                  ej4                  j>                         G d de             Z  ej2                  ej4                  jB                         G d de              Z"y)z,Displays details of a Google Cloud Function.    )absolute_import)division)unicode_literals)encoding)util)client)base)flags)	decorator)log)
propertiesc                     t        j                  d       t        j                  |       D ]$  }t         j                  j                  d|z          & t         j                  j                  d       y )Nz&Function has the following conditions:z   )r   criticalapi_util_v2GetStateMessagesStringsstatusPrint)state_messagesstate_message_strings     !lib/surface/functions/describe.py_PrintV2StateMessagesr   !   sV    ,,78)AA JJT001 **2    c                 f   | j                  d      rt        j                  j                  j                  j                         rm| j                  r)t        j                         st        j                  d       | j                  s+t        j                         rt        j                  d       yyyyy)zValidate arguments.v2zYConflicting flags "--v2" and "--no-gen2" specified, Cloud Functions v2 APIs will be used.zYConflicting flags "--no-v2" and "--gen2" specified, Cloud Functions v2 APIs will be used.N)IsSpecifiedr   VALUES	functionsgen2IsExplicitlySetr   r
   ShouldUseGen2r   warning)argss    r   _ValidateArgsr$   *   s     t



%
%
*
*
:
:
<wwu**,	kk# 77u**,	kk# -7 = r   c                   2    e Zd ZdZed        Zd Zd Zd Zy)Describe+Display details of a Google Cloud Function.c                     t        j                  | d       t        j                  | dd       t        j                  |        y)z Register flags for this command.zto describeT)hiddenallow_v2N)r
   AddFunctionResourceArgAddGen2Flag	AddV2Flag)parsers    r   ArgszDescribe.Args@   s2     
  7	fTD9	OOFr   c                    t        j                         }|j                  j                  |j                  j                  |j                  j                  j                         j                                     }| j                         t        j                  j                  k(  r5| j                  xs | j                  |      }t        j                   ||      S t#        j$                  |      S )N)name)api_util_v1GetApiClientInstanceprojects_locations_functionsGetMESSAGES_MODULE2CloudfunctionsProjectsLocationsFunctionsGetRequestCONCEPTSr1   ParseRelativeNameReleaseTrackr	   ALPHA_v2_function_RunV2r   %decorate_v1_function_with_v2_api_infor   MessageToDict)selfr#   r   functionv2_functions        r   _RunV1zDescribe._RunV1G   s    --/F2266QQ##))+88: 	R 	
H d//555%%:T):k<<
K 
 !!(++r   c                 0   t        j                  | j                               }| j                  xsC |j	                  |j
                  j                  j                         j                         d      }|j                  rt        |j                         |S )NT)raise_if_not_found)	client_v2FunctionsClientr;   r=   GetFunctionr8   r1   r9   r:   stateMessagesr   )rA   r#   r   rB   s       r   r>   zDescribe._RunV2X   s|    &&t'8'8':;F   F$6$6  "//1d %7 %H H223Or   c                     t        |       |j                  r| j                  |      S t        j                  j                  | |      S )N)r$   r   r>   r   FunctionResourceCommandRun)rA   r#   s     r   rM   zDescribe.Runa   s9    $ww[[''++D$77r   N)	__name__
__module____qualname____doc__staticmethodr/   rD   r>   rM    r   r   r&   r&   <   s&    3 ,"8r   r&   c                       e Zd ZdZy)DescribeBetar'   NrN   rO   rP   rQ   rS   r   r   rU   rU   j       3r   rU   c                       e Zd ZdZy)DescribeAlphar'   NrV   rS   r   r   rY   rY   o   rW   r   rY   N)#rQ   
__future__r   r   r   apitools.base.pyr   #googlecloudsdk.api_lib.functions.v1r   r2   #googlecloudsdk.api_lib.functions.v2r   rG   r   googlecloudsdk.callioper	   $googlecloudsdk.command_lib.functionsr
   'googlecloudsdk.command_lib.functions.v1r   googlecloudsdk.corer   r   r   r$   ReleaseTracksr;   GArL   DescribeCommandr&   BETArU   r<   rY   rS   r   r   <module>rf      s    3 &  ' % C C C ( 6 5 = # *$ D%%(()*8t++T-A-A *8 **8Z D%%**+48 4 ,4 D%%++,4L 4 -4r   