
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS jrS r	S	 r
S
 rS rS rSS jrSS jrS rSS jrg)zResource parsing helpers.    )absolute_import)division)unicode_literals)
properties)	resourcesc                 d    [         R                  R                  R                  R	                  U S9$ )aV  Returns the value of the composer/location config property.

Config properties can be overridden with command line flags. If the --location
flag was provided, this will return the value provided with the flag.

Args:
  required: boolean, if True, the absence of the [composer/location] property
      will result in an exception being raised
required)r   VALUEScomposerlocationGetr	   s    2lib/googlecloudsdk/command_lib/composer/parsers.pyGetLocationr      s*     
			#	#	,	,	0	0(	0	CC    c                  d    [         R                  R                  R                  R	                  SS9$ )zReturns the value of the core/project config property.

Config properties can be overridden with command line flags. If the --project
flag was provided, this will return the value provided with the flag.
Tr	   )r   r   coreprojectr    r   r   
GetProjectr   &   s*     
					'	'	+	+T	+	::r   c                 V    [         R                  R                  U [        [        S.SS9$ )zParse out an environment resource using configuration properties.

Args:
  environment_name: str, the environment's ID, absolute name, or relative name
Returns:
  Environment: the parsed environment resource

projectsIdlocationsIdz(composer.projects.locations.environmentsparams
collectionr   REGISTRYParser   r   )environment_names    r   ParseEnvironmentr"   /   s5     
			!	!"$ < 
" 
= =r   c                 L    [         R                  R                  U S[        0SS9$ )zParse out a location resource using configuration properties.

Args:
  location_name: str, the location's base name, absolute name, or
      relative name

Returns:
  Location: the parsed Location resource
r   zcomposer.projects.locationsr   r   r   r    r   )location_names    r   ParseLocationr&   @   s0     
			!	!J'. 
" 
0 0r   c                 V    [         R                  R                  U [        [        S.SS9$ )zParse out an operation resource using configuration properties.

Args:
  operation_name: str, the operation's UUID, absolute name, or relative name

Returns:
  Operation: the parsed Operation resource
r   z&composer.projects.locations.operationsr   r   )operation_names    r   ParseOperationr)   P   s5     
			!	!"$ : 
" 
; ;r   c                 L    [         R                  R                  U S[        0SS9$ )zParses a zone name using configuration properties for fallback.

Args:
  zone: str, the zone's ID, fully-qualified URL, or relative name

Returns:
  googlecloudsdk.core.resources.Resource: a resource reference for the zone
r   zcompute.zonesr   r$   )zones    r   	ParseZoner,   b   s0     
			!	!
$  
" 
" "r   Nc                 p    S[         0nU(       a	  U4S jUS'   [        R                  R                  U USS9$ )a  Parses a machine type name using configuration properties for fallback.

Args:
  machine_type: str, the machine type's ID, fully-qualified URL, or relative
      name
  fallback_zone: str, the zone to use if `machine_type` does not contain zone
      information. If None, and `machine_type` does not contain zone
      information, parsing will fail.

Returns:
  googlecloudsdk.core.resources.Resource: a resource reference for the
  machine type
r   c                     U $ Nr   )zs    r   <lambda>"ParseMachineType.<locals>.<lambda>   s    Qr   r+   zcompute.machineTypesr   r   r   r   r    )machine_typefallback_zoner   s      r   ParseMachineTyper6   q   sD     z"&+.F6N				!	!' 
" 
) )r   c                 n    S[         0nU(       a	  U4S jUS'   [        R                  R                  XSS9$ )a  Parses a network attachment name using configuration properties for fallback.

Args:
  network_attachment: str, the network attachment's ID, fully-qualified URL,
    or relative name
  fallback_region: str, the region to use if `networkAttachment` does not
    contain region information. If None, and `networkAttachment` does not
    contain region information, parsing will fail.

Returns:
  googlecloudsdk.core.resources.Resource: a resource reference for the
  networkAttachment
r   c                     U $ r/   r   rs    r   r1   (ParseNetworkAttachment.<locals>.<lambda>       r   regionzcompute.networkAttachmentsr   r3   )network_attachmentfallback_regionr   s      r   ParseNetworkAttachmentr@      sB     z"& /2F8				!	!4P 
" 
 r   c                 L    [         R                  R                  U S[        0SS9$ )zParses a network name using configuration properties for fallback.

Args:
  network: str, the network's ID, fully-qualified URL, or relative name

Returns:
  googlecloudsdk.core.resources.Resource: a resource reference for the network
r   zcompute.networksr   r$   )networks    r   ParseNetworkrC      s0     
			!	!$# 
" 
% %r   c                 p    S[         0nU(       a	  U4S jUS'   [        R                  R                  U USS9$ )a  Parses a subnetwork name using configuration properties for fallback.

Args:
  subnetwork: str, the subnetwork's ID, fully-qualified URL, or relative name
  fallback_region: str, the region to use if `subnetwork` does not contain
      region information. If None, and `subnetwork` does not contain region
      information, parsing will fail.

Returns:
  googlecloudsdk.core.resources.Resource: a resource reference for the
  subnetwork
r   c                     U $ r/   r   r9   s    r   r1   !ParseSubnetwork.<locals>.<lambda>   r<   r   r=   zcompute.subnetworksr   r3   )
subnetworkr?   r   s      r   ParseSubnetworkrH      sE     z"& /2F8				!	!& 
" 
( (r   )Tr/   )__doc__
__future__r   r   r   googlecloudsdk.corer   r   r   r   r"   r&   r)   r,   r6   r@   rC   rH   r   r   r   <module>rL      sL      &  ' * )
D;="0 ;$").,%(r   