
                          l   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 dd
lmZ ddddZdZdZdZdZdZdZdZdZ G d dej4                        Z ej8                  ej:                  j<                        ej>                   G d dej@                                      Z!y)z!Command to list shared templates.    )absolute_import)division)unicode_literalsN)shared_templates)utils)base)
exceptions)
propertiesz'List shared templates in a given space.a           To list all shared templates in space `my-space`, project `my-project` and location `us-central1`, run:

          $ {command} --space=my-space --project=my-project --location=us-central1

        Or run:

          $ {command} --space=projects/my-project/locations/us-central1/spaces/my-space

        To list all shared templates from the Google Catalog in location `us-central1`, run:

          $ {command} --google-catalog --location=us-central1

        To filter and list shared templates that contain a `my-shared-template` prefix in the display name in space `my-space`, project `my-project` and location `us-central1`, run:

          $ {command} --space=my-space --project=my-project --location=us-central1 --filter="displayName:my-shared-template*"

        To list up to 10 shared templates in space `my-space`, project `my-project` and location `us-central1`, run:

          $ {command} --space=my-space --project=my-project --location=us-central1 --limit=10
        z         This command uses the designcenter/v1alpha API. The full documentation for
        this API can be found at:
        http://cloud.google.com/application-design-center/docs
        )DESCRIPTIONEXAMPLESzAPI REFERENCEzSpace resource - The parent space for which shared templates are listed in the following format: projects/$project/locations/$location/spaces/$space The following arguments in this group can be used to specify the attributes of this resource.zThe location id of the space resource.

To set the location attribute:
  * provide the argument `--space` on the command line with a fully specified name;
  * provide the argument `--location` on the command line.zThe project id of the space resource.

To set the project attribute:
  * provide the argument `--space` on the command line with a fully specified name;
  * provide the argument `--project` on the command line;
  * set the property `core/project`.zID of the space or fully qualified identifier for the space.

To set the space attribute:
  * provide the argument `--space` on the command line.zIf provided, lists all shared template from the Google Catalog. This sets the project to "gcpdesigncenter" and space to "googlespace".zError parsing [space].aW  The [space] resource is not properly specified.
Failed to find attribute [location]. [location] must be specified unless using full resource name for [space]. The attribute can be set in the following ways:
- provide the argument `--space` on the command line with a fully specified name
- provide the argument `--location` on the command linea  The [space] resource is not properly specified.
Failed to find attribute [project]. [project] must be specified unless using --google-catalog, a full resource name, or the core/project property is set. The attribute can be set in the following ways:
- provide the argument `space` on the command line with a fully specified name
- provide the argument `--project` on the command line
- set the property `core/project`c                       e Zd ZdZy)SpaceResourceErrorz0Exception for errors related to Space resources.N)__name__
__module____qualname____doc__     9lib/surface/design_center/spaces/shared_templates/list.pyr   r   x   s    8r   r   c                   :    e Zd ZdZeZed        Zed        Zd Z	y)ListzList shared templates.c                    | j                  dt              }|j                  ddt               |j	                  d      }|j                  dt
               |j                  d	dt               | j                  d
dt               | j                  j                  d       | j                  j                  t        j                  dt        j                  j                               y)z Register flags for this command.T)requiredhelpz--google-catalog
store_true)actionr   z=Specify --project and/or --space for custom shared templates.z	--project)r   z--spacez
--locationFyamlz6designcenter.projects.locations.spaces.sharedTemplatesrelease_trackN)add_mutually_exclusive_group_REQUIRED_FLAGS_BASE_TEXTadd_argument_GOOGLE_CATALOG_HELP_TEXTadd_argument_group_PROJECT_HELP_TEXT_SPACE_HELP_TEXT_LOCATION_HELP_TEXTdisplay_info	AddFormat
AddUriFuncapi_lib_utilsMakeGetUriFuncr   ReleaseTrackALPHA)parsergroupproject_space_groups      r   Argsz	List.Args   s     //& 0 E 
&  
  22G $$ %  $$ % 
    
 !!&)
""$$D++11	
r   c                 `    t        j                  d      }t        |j                  |             S )zValidates the space name.z,^projects/[^/]+/locations/[^/]+/spaces/[^/]+)recompileboolmatch)namepatterns     r   ValidSpaceNamezList.ValidSpaceName   s'     jjHIGd#$$r   c                 t   t        j                  t        j                  j                        }|j
                  rL|j                  d      st        t         dt               d}d}dj                  ||j                  |      }n| j                  |j                        rD|j                  d      s|j                  d      rt        j                  d      |j                  }n|j                  d      st        t         dt               |j                   xs2 t"        j$                  j&                  j                   j)                         }|st        t         dt*               |j                  }dj                  ||j                  |      }|j-                  ||j.                  |j0                  	      S )
zRun the list command.r   location
gcpdesigncentergooglespacez"projects/{}/locations/{}/spaces/{}projectzZ--location and --project cannot be used when a full resource name is provided for --space.)parentlimit	page_size)apisSharedTemplatesClientr   r-   r.   google_catalogIsSpecifiedr   _BASE_ERROR_MESSAGE_LOCATION_NOT_SPECIFIED_MESSAGEformatr<   r:   spacer	   ConflictingArgumentsExceptionr@   r
   VALUEScoreGet_PROJECT_NOT_SPECIFIED_MESSAGEr   rB   rC   )selfargsclient
project_idspace_idrA   s         r   RunzList.Run   s   ''d6G6G6M6MNFj) "#2&E%FG
 	
 %jh3::
dmmXf 
		TZZ	(			*	%)9)9))D66(
 	
 zzfj) "#2&E%FG
 	
 <<G:#4#4#9#9#A#A#E#E#Gj "#2&D%EF
 	
 h3::
dmmXf ;;TZZ4>>   r   N)
r   r   r   r   _DETAILED_HELPdetailed_helpstaticmethodr2   r:   rV   r   r   r   r   r   |   s8      -" "H % %
$r   r   )"r   
__future__r   r   r   r4   $googlecloudsdk.api_lib.design_centerr   rD   r   r+   googlecloudsdk.callioper   r	   googlecloudsdk.corecore_exceptionsr
   rW   r!   r'   r%   r&   r#   rH   rI   rP   Errorr   ReleaseTracksr-   r.   UniverseCompatibleListCommandr   r   r   r   <module>rc      s    ( &  ' 	 I G ( . = * =*/>$ A + >   / >  ( 9.. 9 D%%++,T4 T  -Tr   