
    ~8                        d Z ddlmZ ddlmZ ddlmZ ddl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dlmZ ej&                  j(                  dej&                  j*                  dej&                  j,                  diZej&                  j(                  dej&                  j*                  dej&                  j,                  diZej&                  j,                  fdZej&                  j(                  fdZdej&                  fdZej&                  j,                  fdej8                  fdZej&                  j(                  fdej<                  fdZej&                  j,                  fdZ dAdZ!d Z"dAdZ#dej&                  j(                  fdZ$d  Z%d! Z&dAd"Z'dAd#Z(d$dej&                  j(                  fdejR                  fd%Z*d$dej&                  j(                  fde+fd&Z,dej&                  j(                  fd'Z-dAd(Z.ej&                  j(                  fd)Z/ej&                  j(                  fd*Z0ej&                  j(                  fd+Z1ej&                  j(                  fd,Z2ej&                  j(                  fd-Z3ej&                  j(                  fd.Z4ej&                  j(                  fd/Z5ej&                  j(                  fd0Z6ej&                  j(                  fd1Z7ej&                  j(                  fd2Z8dej&                  j,                  fd3Z9dej&                  j,                  fd4Z:dAd5Z;d6ejx                  dejR                  fd7Z=d8ej|                  dejR                  fd9Z?d8ej|                  de+fd:Z@d8ej|                  fd;ZAd8ej|                  de+fd<ZBd8ej|                  dejR                  fd=ZCd8ej|                  de+fd>ZDd8ej|                  fd?ZEd8ej|                  de+fd@ZFy)BzFleet API utils.    )absolute_import)division)unicode_literalsN)types)apis)base)parser_extensions)
exceptions)	resources)gkehub_v1alpha_messagesv1alphav1betav1v2alphav2betav2c                 <    t        j                  dt        |          S Ngkehub)r   GetMessagesModuleVERSION_MAPrelease_tracks    2lib/googlecloudsdk/api_lib/container/fleet/util.pyr   r   -   s    			+m*D	EE    c                 <    t        j                  dt        |          S r   )r   r   V2_VERSION_MAPr   s    r   GetV2MessagesModuler   1   s    			.*G	HHr   r   c                     | t         j                  j                  k(  rt        S t	        dj                  | j                              )av  Dynamically load Fleet message module based on command track.

  Explicitly import message to enable type hint in Cider-V since
  `apis.GetMessagesModule()` cannot derive type to the specific Python module.

  Args:
    release_track: Determines the generated API message module to be returned.

  Returns:
    An API message module that corresponds to the release track.
  z0Fleet command has not been promoted to {} track.)r   ReleaseTrackALPHAalpha_messagesNotImplementedErrorformatnamer   s    r   FleetMessageModuler&   5   sB     d''---8??


	 r   returnc                 <    t        j                  dt        |          S r   )r   GetClientInstancer   r   s    r   r)   r)   K   s     
		+m*D	EEr   c                 <    t        j                  dt        |          S r   )r   r)   r   r   s    r   GetV2ClientInstancer+   Q   s     
		.*G	HHr   c                 <    t        j                  dt        |          S r   )r   GetClientClassr   r   s    r   r-   r-   W   s    			X{='A	BBr   globalc                 b    t         j                  j                  d| |      j                         S )Ngkehub.projects.locations
projectsIdlocationsIdr   REGISTRYCreateRelativeName)projectlocations     r   LocationResourceNamer:   [   s2    				"	"! 
# 
 LN	r   c                     t        j                  d|       }|r|j                  d      S t        j                  dj                  |             )N+projects/.*/locations/(.*)/memberships/(.*)   $Invalid membership resource name: {}researchgroupr
   Errorr$   	full_namematchess     r   MembershipLocationrG   d   sF    IICYO'==,33I>	 r   c                 d    t         j                  j                  d| ||      j                         S )N%gkehub.projects.locations.membershipsr2   r3   membershipsIdr4   )r8   
membershipr9   s      r   MembershipResourceNamerM   m   s5    				"	"-	 
# 

 LNr   c                 |    t         j                  j                  d | |||ddt        |         j	                         S )N)r2   r3   rK   
featuresIdz.gkehub.projects.locations.memberships.featureslineparams
collectionapi_version)r   r5   Parser   r7   )r8   rL   featurer9   r   s        r   MembershipFeatureResourceNamerW   w   sM     
			!	!!%	 B / 
" 
 LNr   c                     t        j                  d|       }|r&|j                  d      dz   |j                  d      z   S t        j                  dj                  |             )Nr<   r=   /   r>   r?   rD   s     r   MembershipPartialNamer[      sY    IICYO'==c!GMM!$444,33I>	 r   c                 `    t         j                  j                  | d      j                         S )NrI   rS   )r   r5   ParseRelativeNameName)rE   s    r   MembershipShortnamer`      s-    				-	-C 
. 
DFr   c                 d    t         j                  j                  d| ||      j                         S )Nz"gkehub.projects.locations.features)r2   r3   rO   r4   )r8   rV   r9   s      r   FeatureResourceNamerb      s5    				"	"*	 
# 

 LNr   c                 d    t         j                  j                  d| ||      j                         S )N$gkehub.projects.locations.operations)r2   r3   operationsIdr4   )r8   	operationr9   s      r   OperationResourceNamerg      s5    				"	",	 
# 

 LNr   defaultc                 ^    t         j                  j                  d | ||ddt        |         S )N)r2   r3   fleetsIdz gkehub.projects.locations.fleetsrP   )r   r5   rU   r   r8   fleetr9   r   s       r   FleetRefrm      s@     
			!	!!
 4m, 
" 	
 	r   c                 :    t        | |||      j                         S N)rm   r7   rk   s       r   FleetResourceNamerp      s     
'5(M	:	G	G	IIr   c                 x    t         j                  j                  d | |ddt        |         j	                         S )Nr1   r0   rP   r   r5   rU   r   r7   )r8   r9   r   s      r   FleetParentNamers      sF     
			!	!! -m, 
" 
 LNr   c                 &    dj                  | |      S )Nzorganizations/{0}/locations/{1})r$   )organizationr9   s     r   FleetOrgParentNamerv      s    	*	1	1,	IIr   c                 x    t         j                  j                  d | dddt        |         j	                         S Nr.   r1   r0   rP   rr   r8   r   s     r   ScopeParentNamerz      D    				!	!! -m, 
" 
 LNr   c                 x    t         j                  j                  d | dddt        |         j	                         S rx   rr   ry   s     r   NamespaceParentNamer}      r{   r   c                 z    t         j                  j                  d | d|ddt        |         j	                         S Nr.   )r2   r3   namespacesIdz$gkehub.projects.locations.namespacesrP   rr   )r8   r%   r   s      r   NamespaceResourceNamer      sG    				!	!!
 8m, 
" 	
 LN	r   c                 z    t         j                  j                  d | d|ddt        |         j	                         S Nr.   r2   r3   scopesId gkehub.projects.locations.scopesrP   rr   r8   scoper   s      r   ScopeNamespaceParentNamer     I     
			!	!!
 4m, 
" 	
 LN	r   c                 |    t         j                  j                  d | d||ddt        |         j	                         S )Nr.   )r2   r3   r   r   z+gkehub.projects.locations.scopes.namespacesrP   rr   r8   r   r%   r   s       r   ScopeNamespaceResourceNamer     sL     
			!	!!	 ?m, 
" 

 LN
r   c                 z    t         j                  j                  d | d|ddt        |         j	                         S r   rr   )r8   	namespacer   s      r   RBACRoleBindingParentNamer   (  sI     
			!	!!#
 8m, 
" 	
 LN	r   c                 z    t         j                  j                  d | d|ddt        |         j	                         S r   rr   r   s      r   ScopeRBACRoleBindingParentNamer   8  r   r   c                 |    t         j                  j                  d | d||ddt        |         j	                         S )Nr.   )r2   r3   r   rbacrolebindingsIdz5gkehub.projects.locations.namespaces.rbacrolebindingsrP   rr   )r8   r   r%   r   s       r   RBACRoleBindingResourceNamer   H  sM     
			!	!!# $	 Im, 
" 

 LN
r   c                 |    t         j                  j                  d | d||ddt        |         j	                         S )Nr.   )r2   r3   r   r   z1gkehub.projects.locations.scopes.rbacrolebindingsrP   rr   r   s       r    ScopeRBACRoleBindingResourceNamer   Y  sM     
			!	!! $	 Em, 
" 

 LN
r   c                 |    t         j                  j                  d| |||ddt        |         j	                         S )a  Parses a Membership RBAC Role Binding resource.

  Args:
    project: the full project ID or number for the resource.
    location: the location of the resource.
    membership: the parent membership of the resource.
    name: the resource name for the role binding.
    release_track: the API version for the resource parsing.

  Returns:
    A Membership RBAC Role Binding resource.
  N)r2   r3   rK   r   z6gkehub.projects.locations.memberships.rbacrolebindingsrP   rr   )r8   r9   rL   r%   r   s        r   %MembershipRBACRoleBindingResourceNamer   j  sM      
			!	!!% $	 Jm, 
" 

 LN
r   c                 |    t         j                  j                  d | |||ddt        |         j	                         S )N)r2   r3   rK   
bindingsIdz.gkehub.projects.locations.memberships.bindingsrP   rr   )r8   r%   rL   r9   r   s        r   MembershipBindingResourceNamer     sM     
			!	!!%	 Bm, 
" 

 LN
r   c                 z    t         j                  j                  d | ||ddt        |         j	                         S )NrJ   rI   rP   rr   )r8   rL   r9   r   s       r   MembershipBindingParentNamer     sI     
			!	!!%
 9m, 
" 	
 LN	r   c                 d    t         j                  j                  d| ||      j                         S )Nr   r   r4   )r8   r   r9   s      r   ScopeResourceNamer     s5    				"	"(	 
# 

 LNr   rf   c                 X    t         j                  j                  | j                  d      S )z6Parses a gkehub Operation reference from an operation.rd   r]   )r   r5   r^   r%   )rf   s    r   OperationRefr     s*    				-	-nn!G 
. 
 r   argsc                 z    t        | j                  dd       r$| j                  j                  j                         S y )Nrollout)getattrCONCEPTSr   rU   r   s    r   
RolloutRefr     s0    T]]It,==  &&(( -r   c                 >    t        |       }|r|j                         S y ro   )r   r7   r   rollout_refs     r   RolloutNamer     s!    4 +##%%	r   c                 Z    t        |       }|r|j                         j                         S y ro   )r   Parentr7   r   s     r   RolloutParentNamer     s*    4 +,,..	r   c                 >    t        |       }|r|j                         S y ro   )r   r_   r   s     r   	RolloutIdr     s!    4 +	r   c                 z    t        | j                  dd       r$| j                  j                  j                         S y )Nrolloutsequence)r   r   r   rU   r   s    r   RolloutSequenceRefr     s1     T]]-t4==((..00	r   c                 >    t        |       }|r|j                         S y ro   )r   r7   r   rollout_sequence_refs     r   RolloutSequenceNamer     s"    +D1,,..	r   c                 Z    t        |       }|r|j                         j                         S y ro   )r   r   r7   r   s     r   RolloutSequenceParentNamer     s+    +D1&&(5577	r   c                 >    t        |       }|r|j                         S y ro   )r   r_   r   s     r   RolloutSequenceIdr     s"    +D1$$&&	r   )r.   )G__doc__
__future__r   r   r   r@   &googlecloudsdk.api_lib.container.fleetr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   r   4googlecloudsdk.generated_clients.apis.gkehub.v1alphar   r"   r    r!   BETAGAr   r   r   r   r&   TrackClientr)   V2TrackClientr+   r-   r:   rG   rM   rW   r[   r`   rb   rg   Resourcerm   strrp   rs   rv   rz   r}   r   r   r   r   r   r   r   r   r   r   r   	Operationr   	Namespacer   r   r   r   r   r   r   r    r   r   <module>r      s    &  ' 	 8 , ( 5 * ) j 	YH$ 	YH$ %)$5$5$8$8 F '+&7&7&=&= Id&7&7 . ##&&F
F ##))I
I "&!2!2!5!5 C ##)), ##))	
 ( ##))	J
 	J d.?.?.E.EJ ,0+<+<+B+B 
 04/@/@/F/F 
 8<7H7H7N7N  #'"3"3"9"9" )-(9(9(?(?$ '+&7&7&=&=" #'"3"3"9"9" -1,=,=,C,C$ )-(9(9(?(?$ 8<7H7H7N7NB ##&&, #+$:K:K:N:N N44 9K9K )&00 )Y5G5G )
'11 c -77 %// C 

%
%/99 c $5$?$? -77 C r   