
    v                     b    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K
Jr  S rS rS	 rg
)z,Common sql utility functions for validating.    )absolute_import)division)unicode_literals)
exceptions)	instancesc                     SU ;   a>  U R                  S5      nUS   nUS   n[        R                  " SR                  X#S95      eg )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      s^    M#))#.O&q)'+

&
& (
 F#F@B B	     c                 T    U b  U (       d  U(       d  [         R                  " S5      eg g )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                    U R                  S5      (       a-  U R                  S5      (       d  [        R                  " SS5      eU R                  S5      (       a  U R                  S5      (       a  U R                  U R                  :X  a  [        R
                  " S5      e[        R                  " U R                  5      n[        R                  " U R                  5      nX:w  a  [        R
                  " S5      eggg)zConstruct 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@0H0H

.
. &' ' 
&''D,<,<V,D,DyyD'''44
IK K  11$))<!)!;!;"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   