
                         f    S r SSKrSSKJr  SrSrSrSrSrS	 r	S
 r
S rS rS rS rS rS rS rg)z/Utils for manipulating transfer resource names.    N)
propertiesz^transferJobs/.+z^transferOperations/.+z!^projects\/(.+)\/agentPools\/(.+)ztransferJobs/ztransferOperations/c                 D    [         R                  " X5      (       a  U$ X-   $ )z0Adds prefix to one resource string if necessary.)rematch)prefix_to_checkprefix_to_addresource_strings      4lib/googlecloudsdk/command_lib/transfer/name_util.py_add_single_transfer_prefixr      s"     XXo//		((    c                     [        U[        5      (       a  [        XU5      $ [        U[        5      (       a  U Vs/ s H  n[        XU5      PM     sn$ [	        S5      es  snf )zCAdds prefix to one resource string or list of strings if necessary.z+Argument must be string or list of strings.)
isinstancestrr   list
ValueError)r   r   resource_string_or_listr	   s       r
   _add_transfer_prefixr   &   su     '--&'>@ @)400  7  7O 	$O$3	56 
 	@AAs   Ac                 ,    [        [        [        U 5      $ )z,Adds prefix to transfer job(s) if necessary.)r   _JOBS_PREFIX_REGEX_JOBS_PREFIX_STRING)job_name_string_or_lists    r
   add_job_prefixr   5   s    	02E5
7 7r   c                 ,    [        [        [        U 5      $ )z2Adds prefix to transfer operation(s) if necessary.)r   _OPERATIONS_PREFIX_REGEX_OPERATIONS_PREFIX_STRING)job_operation_string_or_lists    r
   add_operation_prefixr   ;   s    	67:
< <r   c                     [         R                  R                  R                  R	                  5       nSR                  U5      n[        [        UU 5      nU(       d  X0:w  a  [        S5      eU$ )z3Adds prefix to transfer agent pool(s) if necessary.zprojects/{}/agentPools/zProject ID not found. Please set a gcloud-wide project, or use full agent pool names (e.g. "projects/[your project ID]/agentPools/[your agent pool name]").)	r   VALUEScoreprojectGetformatr   _AGENT_POOLS_PREFIX_REGEXr   )agent_pool_string_or_list
project_idr   results       r
   add_agent_pool_prefixr(   B   se      %%--113*+22:>- 9= 9;&	;
	    
-r   c                 ^    U R                  [        5      (       a  U [        [        5      S $ U $ )z.Removes prefix from transfer job if necessary.N)
startswithr   len)
job_strings    r
   remove_job_prefixr-   P   s.    .//c-./00	r   c                 ^    U R                  [        5      (       a  U [        [        5      S $ U $ )z4Removes prefix from transfer operation if necessary.N)r*   r   r+   )operation_strings    r
   remove_operation_prefixr0   W   s.      !:;;C 9:;<<	r   c                 l    [         R                  " [        U 5      nU(       a  UR                  S5      $ U $ )z5Removes prefix from transfer agent pool if necessary.   )r   searchr$   groupagent_pool_stringprefix_search_results     r
   remove_agent_pool_prefixr8   ^   s/    #<>OP%%a((	r   c                 ~    [         R                  " [        U 5      nU(       a  UR                  S5      $ [	        S5      e)N   ztFull agent pool prefix required to extract project from string (e.g. "projects/[project ID]/agentPools/[pool name]).)r   r3   r$   r4   r   r5   s     r
   "get_agent_pool_project_from_stringr;   f   s=    #<>OP%%a((?	@ @r   )__doc__r   googlecloudsdk.corer   r   r   r$   r   r   r   r   r   r   r(   r-   r0   r8   r;    r   r
   <module>r?      s_    6 
 *( 4 @ % 1 )B7<@r   