
    F                     @   d Z ddlmZ ddlmZ ddlmZ ddl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  ej                   ej"                  j$                  ej"                  j&                  ej"                  j(                         G d dej*                               Zy)Lists AlloyDB operations.    )absolute_import)division)unicode_literalsN)
list_pager)api_util)base)flags)
propertiesc                   6    e Zd ZdZdddZed        Zd Zd Zy)	Listr   z{description}zU        To list operations, run:

          $ {command} --region=us-central1
        )DESCRIPTIONEXAMPLESc                 Z    | j                  ddd       t        j                  | dd       y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    z--region-zRegional location (e.g. asia-east1, us-east1). See the full list of regions at https://cloud.google.com/sql/docs/instance-locations. Default: list operations in all regions.)defaulthelpFN)add_argumentr
   
AddCluster)parsers    &lib/surface/alloydb/operations/list.pyArgsz	List.Args/   s6     9  ; 
VUE*    c           	          t        j                   j                               }|j                  j	                  dt
        j                  j                  j                  j                  j                        } fd}t        j                  |j                  j                  |j                  j!                  |j#                               d|j$                  j&                  d      }|S )zConstructs and sends request.

    Args:
      args: argparse.Namespace, An object that contains the values for the
          arguments specified in the .Args() method.

    Returns:
      ProcessHttpResponse of the request made.
    zalloydb.projects.locations)
projectsIdlocationsIdc                     j                   y| j                  j                  D ]E  }|j                  dk(  s|j                  j
                  }j                  |j                         c S  y)NTtargetF)clustermetadataadditionalPropertieskeyvaluestring_value_matchesTarget)operation_itemadditional_propertyr   argsselfs      r   _FilterOperationz"List.Run.<locals>._FilterOperationO   sc    		!/!8!8!M!M
""h.&,,99&$$VT\\:
: "N r   )name
operationspageSize)field	predicatelimit
batch_sizebatch_size_attribute)r   AlloyDBClientReleaseTrackresource_parserCreater   VALUEScoreproject	GetOrFailregionr   YieldFromListalloydb_clientprojects_locations_operationsalloydb_messages-AlloydbProjectsLocationsOperationsListRequestRelativeNamer0   	page_size)r)   r(   clientlocation_refr*   results   ``    r   RunzList.Run?   s     ##D$5$5$78F))00$$$))11;;KK 1 !L
 %%;;MM**, 	N 	."jj>>')F Mr   c                 B    d|z   dz   }t        j                  ||      d uS )Nz(projects/[^/]*/locations/[^/]*/clusters/z($|/.*$))rematch)r)   r   
cluster_idpatterns       r   r%   zList._matchesTargetd   s)    
 :JFTG88GV$D00r   N)	__name__
__module____qualname____doc__detailed_helpstaticmethodr   rF   r%    r   r   r   r      s7     " 		- + +#J1r   r   )rO   
__future__r   r   r   rH   apitools.base.pyr   googlecloudsdk.api_lib.alloydbr   googlecloudsdk.callioper	   "googlecloudsdk.command_lib.alloydbr
   googlecloudsdk.corer   ReleaseTracksr4   ALPHABETAGAListCommandr   rR   r   r   <module>r^      s      '  ' 	 ' 3 ( 4 * D%%++T->->-C-C%%((*I14 I1*I1r   