
                             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Zd Z	d	 Z
d
 Zd Zd ZddZddZd ZddZy)zResource parsing helpers.    )absolute_import)division)unicode_literals)
properties)	resourcesc                 j    t         j                  j                  j                  j	                  |       S )ab  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                  j    t         j                  j                  j                  j	                  d      S )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                 \    t         j                  j                  | t        t        dd      S )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                 R    t         j                  j                  | dt        id      S )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                 \    t         j                  j                  | t        t        dd      S )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                 R    t         j                  j                  | dt        id      S )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                 j    dt         i}|r|fd|d<   t        j                  j                  | |d      S )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                     | S Nr   )zs    r   <lambda>z"ParseMachineType.<locals>.<lambda>   s    Qr   r+   zcompute.machineTypesr   r   r   r   r    )machine_typefallback_zoner   s      r   ParseMachineTyper5   q   sD     z"&+.F6N				!	!' 
" 
) )r   c                 j    dt         i}|r|fd|d<   t        j                  j                  | |d      S )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                     | S r/   r   rs    r   r1   z(ParseNetworkAttachment.<locals>.<lambda>       r   regionzcompute.networkAttachmentsr   r2   )network_attachmentfallback_regionr   s      r   ParseNetworkAttachmentr>      sD     z"& /2F8				!	!4P 
" 
 r   c                 R    t         j                  j                  | dt        id      S )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   ParseNetworkrA      s0     
			!	!$# 
" 
% %r   c                 j    dt         i}|r|fd|d<   t        j                  j                  | |d      S )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                     | S r/   r   r8   s    r   r1   z!ParseSubnetwork.<locals>.<lambda>   r:   r   r;   zcompute.subnetworksr   r2   )
subnetworkr=   r   s      r   ParseSubnetworkrE      sE     z"& /2F8				!	!& 
" 
( (r   )Tr/   )__doc__
__future__r   r   r   googlecloudsdk.corer   r   r   r   r"   r&   r)   r,   r5   r>   rA   rE   r   r   r   <module>rI      sL      &  ' * )
D;="0 ;$").,%(r   