
    v                     b    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 Zd Zd	 Zy
)z,Common sql utility functions for validating.    )absolute_import)division)unicode_literals)
exceptions)	instancesc                     d| v rA| j                  d      }|d   }|d   }t        j                  dj                  ||            y )N:r   zInstance names cannot contain the ':' character. If you meant to indicate the
project for [{instance}], use only '{instance}' for the argument, and either add
'--project {project}' to the command line or first run
  $ gcloud config set project {project}
)projectinstance)splitsql_exceptionsArgumentErrorformat)instance_namename_componentspossible_projectpossible_instances       *lib/googlecloudsdk/api_lib/sql/validate.pyValidateInstanceNamer      sa    M#))#.O&q)'+

&
& (
 F#.?F@B B	     c                 <    | | s|st        j                  d      y y )Nzqmissing URI arg, please include URI arg or set the recovery-only flag if you meant to bring database online only
)r   r   )urirecovery_onlys     r   ValidateURIr   (   s*    	k}

&
& (   (5r   c                    | j                  d      r'| j                  d      st        j                  dd      | j                  d      r| j                  d      r| j                  | j                  k(  rt        j
                  d      t        j                  | j                        }t        j                  | j                        }||k7  rt        j
                  d      yyy)a
  Construct a Cloud SQL instance from command line args.

  Args:
    args: argparse.Namespace, The CLI arg namespace.

  Raises:
    RequiredArgumentException: Zone is required.
    ConflictingArgumentsException: Zones in arguments belong to different
    regions.
  secondary_zonezonez--zonezL`--zone` is required if --secondary-zone is used while creating an instance.z=Zones in arguments --zone and --secondary-zone are identical.zKZones in arguments --zone and --secondary-zone belong to different regions.N)IsSpecifiedr   RequiredArgumentExceptionr   r   ConflictingArgumentsExceptionapi_utilGetRegionFromZone)argsregion_from_zoneregion_from_secondary_zones      r   ValidateInstanceLocationr'   /   s     
&'0@0@0H

.
. &' ' 
&'D,<,<V,DyyD'''44
IK K  11$))<!)!;!;"5544)* * 6 -E'r   N)__doc__
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r   r"   googlecloudsdk.callioper   r   r'    r   r   <module>r-      s,    3 &  ' C < .
B*r   