
                         X    S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  S r	S	 r
g)
z1Shared util methods common to BQExports commands.    )absolute_import)division)unicode_literalsN)errors)utilc                    U R                   n[        R                  " S5      R                  U5      n[        R                  " S5      R                  U5      nU(       d9  U(       d2  SU;   a  [        R
                  " S5      e[        R
                  " S5      eU(       a  U$ U(       aK  [        R                  " U 5      nUc  [        R
                  " S5      e[        R                  " U 5      S-   U-   $ g)a7  Returns relative resource name for a v1 B2igQuery export.

Validates on regexes for args containing full names or short names with
resources. Localization is supported by the
ValidateAndGetBigQueryExportV2Name method.

Args:
  args: an argparse object that should contain .BIG_QUERY_EXPORT, optionally 1
    of .organization, .folder, .project

Examples:

args with BIG_QUERY_EXPORT="organizations/123/bigQueryExports/config1"
returns the BIG_QUERY_EXPORT

args with BIG_QUERY_EXPORT="config1" and projects="projects/123" returns
projects/123/bigQueryExports/config1
zT(organizations|projects|folders)/.*/bigQueryExports/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$!^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/vBigQuery export must match the full resource name, or `--organization=`, `--folder=` or `--project=` must be provided.zRBigQuery export id does not match the pattern '^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$'.N/bigQueryExports/)BIG_QUERY_EXPORTrecompilematchr   InvalidSCCInputErrorr   GetParentFromNamedArguments)argsbq_export_namelong_name_formatshort_name_formatparents        =lib/googlecloudsdk/command_lib/scc/bqexports/bqexport_util.py"ValidateAndGetBigQueryExportV1Namer      s    & ((.ZZ\	E.  jj!DEKK 
"3
n''M 
 ''1 
 --d3F~''M  
*
*4
0      c                 ,   [         R                  " S5      n[         R                  " S5      n[         R                  " S5      nU R                  n[        R                  " U S5      nUR                  U5      (       a9  [        R                  " U 5      nUc  [        R                  " S5      eU SU SU 3$ UR                  U5      (       a  U$ UR                  U5      (       a  UR                  S5      u  pxU SU SU 3$ [        R                  " S5      e)	a  Returns relative resource name for a v2 Big Query export.

Validates on regexes for args containing full names with locations or short
names with resources.

Args:
  args: an argparse object that should contain .BIG_QUERY_EXPORT, optionally 1
    of .organization, .folder, .project; and optionally .location

Examples:

args with BIG_QUERY_EXPORT="organizations/123/bigQueryExports/config1"
and location="locations/us" returns
organizations/123/locations/us/bigQueryExports/config1

args with
BIG_QUERY_EXPORT="folders/123/locations/us/bigQueryExports/config1"
and returns folders/123/locations/us/bigQueryExports/config1

args with BIG_QUERY_EXPORT="config1", projects="projects/123", and
locations="us" returns projects/123/bigQueryExports/config1
r	   zT(organizations|projects|folders)/.+/bigQueryExports/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$za(organizations|projects|folders)/.+/locations/.+/bigQueryExports/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$v2r   z/locations/r   zBigQuery export must match (organizations|projects|folders)/.+/bigQueryExports/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$ (organizations|projects|folders)/.+/locations/.+/bigQueryExports/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$ or [a-zA-Z0-9-_]{1,128}$.)
r   r   r   r   ValidateAndGetLocationr   r   r   r   split)	r   
id_pattern nonregionalized_resource_patternregionalized_resource_patternbq_export_idlocationr   parent_segment
id_segments	            r   "ValidateAndGetBigQueryExportV2Namer&   V   s$   0 zz=>*%'ZZ\&" #%**i# &&,((t4( l##--d3F~''M  X[
*;L>JJ #((66 &++L99#/#5#56I#J ^[
2CJ<PP###	 r   )__doc__
__future__r   r   r   r   googlecloudsdk.command_lib.sccr   r   r   r&    r   r   <module>r+      s'     8 &  ' 	 1 /7t<r   