
                         L    d Z ddlmZ ddlmZ ddlmZ ddlmZ dZdZ	d Z
d	 Zy
)z7Convenience functions for dealing with alias IP ranges.    )absolute_import)division)unicode_literals)
exceptionszAn alias IP range must contain range name and IP range separated by a colon, or only the IP range.  The IP range portion can be expressed as a full IP CIDR range (e.g. 10.1.1.0/24), or a single IP address (e.g. 10.1.1.1), or an IP CIDR net mask (e.g. /24)zAn alias IP range must contain range name and IP CIDR net mask (e.g. /24) separated by a colon, or only the IP CIDR net mask (e.g. /24).c                 l    |sg S |j                  d      }|D cg c]  }t        | ||       c}S c c}w )a  Returns a list of AliasIpRange messages by parsing the input string.

  Args:
    messages: GCE API messages.
    instance: If True, this call is for parsing instance flags; otherwise
        it is for instance template.
    alias_ip_ranges_string: Command line string that specifies a list of
        alias IP ranges. Alias IP ranges are separated by semicolons.
        Each alias IP range has the format <alias-ip-range> or
        {range-name}:<alias-ip-range>.  The range-name is the name of the
        range within the network interface's subnet from which to allocate
        an alias range. alias-ip-range can be a CIDR range, an IP address,
        or a net mask (e.g. "/24"). Note that the validation is done on
        the server. This method just creates the request message by parsing
        the input string.
        Example string:
        "/24;range2:192.168.100.0/24;range3:192.168.101.0/24"

  Returns:
    A list of AliasIpRange messages.
  ;)split$_CreateAliasIpRangeMessageFromString)messagesinstancealias_ip_ranges_stringalias_ip_range_stringsss        :lib/googlecloudsdk/api_lib/compute/alias_ip_range_utils.py$CreateAliasIpRangeMessagesFromStringr   "   sK    . 
 I177<%
'%! /x1
E%
' ' 
's   1c                    | j                         }|j                  d      }t        |      dk(  r|d   |_        |S t        |      dk(  r|d   |_        |d   |_        |S t        j                  d|r
t              t              )z?Returns a new AliasIpRange message by parsing the input string.:   r      aliases)	AliasIpRanger	   lenipCidrRangesubnetworkRangeNamecalliope_exceptionsInvalidArgumentException$_INVALID_FORMAT_MESSAGE_FOR_INSTANCE-_INVALID_FORMAT_MESSAGE_FOR_INSTANCE_TEMPLATE)r   r   alias_ip_range_stringalias_ip_rangetokenss        r   r
   r
   @   s     ((*. &&s+&[A!'N 
 6{a)/N&!'N 
	 
6
608,< < ;< <    N)__doc__
__future__r   r   r   googlecloudsdk.callioper   r   r   r   r   r
    r"   r   <module>r'      s6    > &  ' EA %J .
'<r"   