
    "                         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 Zd Zd Zd Zd Zy)zFThis file provides the implementation of the `functions list` command.    )absolute_import)division)unicode_literals)
exceptions)
list_pager)util)log)
properties)	resourcesc                     | j                   r1t        j                  ddj                  | j                         z         t	        | |      S )z@Response callback to log unreachable while generating functions.zThe following regions were fully or partially unreachable for query: %sThis could be due to permission setup. Additional informationcan be found in: https://cloud.google.com/functions/docs/troubleshootingz, )unreachabler	   warningjoingetattr)message	attributes     ;lib/googlecloudsdk/command_lib/functions/v1/list/command.py_GetFunctionsAndLogUnreachabler      sE    KK	B
 ))G''
(	) 
)	$$    c              #      K   | D ]=  }t         j                  j                  |d|id      }t        ||||      D ]  }|  ? yw)z-Yield the functions from the given locations.
projectsIdz!cloudfunctions.projects.locations)params
collectionN)r   REGISTRYParse_YieldFromLocation)	locationsprojectlimitmessagesclientlocationlocation_reffunctions           r   YieldFromLocationsr%   -   sV     h%%++g&6 , L
 '|UHfMn N s   AAc              #   D  K   t        j                  |j                  t        | |      |ddt              }	 |D ]  }|  y# t
        j                  $ rG}t        j                  |      }t        j                  t        j                  |             Y d}~yd}~ww xY ww)z,Yield the functions from the given location.	functionspageSize)servicerequestr   fieldbatch_size_attributeget_field_funcN)r   YieldFromListprojects_locations_functions_BuildRequestr   api_exceptions	HttpErrorr   GetHttpErrorMessager   reraisebase_exceptionsHttpException)r#   r   r    r!   list_generatoritemerrormsgs           r   r   r   9   s     ++11L(3%3.;j 		!	! ;

"
"5
)C44S9::;s.   4B A B B=BB BB c                 B    |j                  | j                               S )N)parent)3CloudfunctionsProjectsLocationsFunctionsListRequestRelativeName)r#   r    s     r   r0   r0   O   s'    		E	E&&( 
F 
 r   c                     t        j                         }t        j                         }t        j                  j
                  j                  j                         }| j                  }t        | j                  ||||      S )zList Google Cloud Functions.)r   GetApiClientInstanceGetApiMessagesModuler
   VALUEScorer   	GetOrFailr   r%   regions)argsr!   r    r   r   s        r   RunrG   U   s^    $$&&&&((""**446'
**%	DLL'5(F	KKr   N)__doc__
__future__r   r   r   apitools.base.pyr   r1   r   #googlecloudsdk.api_lib.functions.v1r   googlecloudsdk.callioper5   googlecloudsdk.corer	   r
   r   r   r%   r   r0   rG    r   r   <module>rO      sF    M &  ' 9 ' 4 A * # * )%	;,Lr   