
    '
                         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
Z
dd	lmZ  G d
 dej                        Zy)zHA command that generates resource URIs given collection and api version.    )absolute_import)division)unicode_literals)arg_parsers)base)	resourcesN)rangec                   &    e Zd ZdZed        Zd Zy)ParsezwCloud SDK resource test URI generator.

  *{command}* is an handy way to generate test URIs for the resource parser.
  c                     | j                  dddd       | j                  ddd	       | j                  d
dt        j                  d      d       y )Nz--collectionNAMETz6The resource collection name of the resource to parse.)metavarrequiredhelpz--api-versionVERSIONzUThe resource collection API version. The collection default is used if not specified.)r   r   z--count   )lower_boundz-The number of test resource URIs to generate.)defaulttyper   )add_argumentr   
BoundedInt)parsers    &lib/surface/meta/resources/generate.pyArgsz
Parse.Args#   sn    
E	  G
 *  ,
 ##2<	  >    c                    t         j                  j                  |j                  |j                        }i }|j                  d      }|sg S |D ]  }d|j                         z   dz   ||<    g }t        d|j                  dz         D ]m  }i }t        j                  |      D ]  \  }}|j                  |      ||<    t        j                  d|d|d      j                         }	|j                  |	       o |S )z(Returns the list of generated resources.)api_version zmy-z-{}r   N)r   REGISTRYGetCollectionInfo
collectionr   	GetParamslowerr	   countsix	iteritemsformatResourceSelfLinkappend)
selfargscollection_info	templatesparamsparamurisitemplateuris
             r   Runz	Parse.Run5   s    ((::T%5%5 ; 7OI&&r*F i.6i D1djj1n%f ]]95/% *u 6
VT33;8: 

kk# & Kr   N)__name__
__module____qualname____doc__staticmethodr   r5    r   r   r   r      s     
 > >"r   r   )r9   
__future__r   r   r   googlecloudsdk.callioper   r   googlecloudsdk.corer   r%   	six.movesr	   Commandr   r;   r   r   <module>rA      s3     O &  ' / ( ) 
 -DLL -r   