
    o
                     l    S r SSKrSSKrSSKJr  SSKJr  \R                  " SSS/5      rS r	S	 r
S
 rg)z5Utilities for edge-cloud container location commands.    N)encoding)
exceptionsEdgeContainerZonenameregionc                 X    A A[         R                  " SSUR                  5      Ul        U$ )zGReplaces the request.name 'locations/{zone}' with 'locations/{region}'.zF(projects/[-a-z0-9]+/locations/[a-z]+-[a-z]+[0-9])[-a-z0-9]*((?:/.*)?)z\1\2)resubr   )refargsrequests      @lib/googlecloudsdk/command_lib/edge_cloud/container/locations.pyReplaceResourceZoneWithRegionr      s*    	4Ow||', 
.    c              #      #    U  Hd  nUR                   (       d  M  [        R                  " UR                   5      nUR                  S/ 5       H  n[	        XBR
                  S9v   M     Mf     g7f)z.Returns the zones from a ListLocationResponse.availableZones)r   r   N)metadatar   MessageToDictget_Zone
locationId)response_r   r   zones        r   ExtractZonesFromLocationsr   $   sT     f??%%foo6H-r2t$5$566 3 s   A,A.c                 *   [         R                  " U R                  5      nUR                  R	                  S5      S   nUR                  S0 5      R                  5        H  u  pEXC:X  d  M  SU;   ay  UR                  S5      n/ nUR                  5        HN  u  pU	S:X  a  UR                  US-   5        M!  U	S:X  a  UR                  US-   5        M=  UR                  U5        MP     XuS	'   Us  $    [        R                  " S
R                  U5      5      e)z?Returns the argument-specified zone from a GetLocationResponse./r   	rackTypesBASEz (BASE)	EXPANSIONz (EXPANSION)rackszZone not found: {})r   r   r   r   splitr   itemspopappendr   Errorformat)
r   r   r   	want_zone	zone_namer   r"   populated_rackrack	rack_types
             r   ExtractZoneFromLocationr.   /   s    ##H$5$56(iiooc"2&)!&6;AACoi		%${{}OD & !!$"23 K'!!$"78 !!$'  - 'Wk' D( 	-44Y?@@r   )__doc__collectionsr	   apitools.base.pyr   googlecloudsdk.corer   
namedtupler   r   r   r.    r   r   <module>r5      s@    <  	 % *2VX4FG7Ar   