
                             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SKJr  SS	KJr  SSKJr  SS
K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.Anthos Policy Controller status API utilities.    )absolute_import)division)unicode_literals)
exceptions)apis)base)api_util)	constantsNc                 \    U [         R                  R                  :X  a  g[        SU -   5      e)Nv1alphazInvalid release track: )r   ReleaseTrackALPHA
ValueErrorrelease_tracks    Olib/googlecloudsdk/api_lib/container/fleet/policycontroller/status_api_utils.py_GetApiVersionFromReleaseTrackr      s*    d''---,}<==    c                 B    [         R                  " S[        U 5      5      $ )z9Returns the Policy Controller status API messages module.anthospolicycontrollerstatus_pa)r   GetMessagesModuler   r   s    r   r   r   $        			'$]3
5 5r   c                 B    [         R                  " S[        U 5      5      $ )z9Returns the Policy Controller status API client instance.r   )r   GetClientInstancer   r   s    r   r   r   +   r   r   c           	      <    [         R                  " UU5      n UR                  SR                  X2UR                  5      S9nU R                  R                  U5      nUR                  R                  UR                  R                  [        R                  " [         R"                  " UR$                  R&                  5      5      UUR(                  R*                  =(       d    S/ UR$                  R,                  =(       d    0 UR$                  R.                  =(       d    0 S.$ ! [        R                   a&    [        R
                  " SR                  U5      5      ef = f! [        R                   a&    [        R
                  " SR                  X$5      5      ef = f)z*Returns a formatted membership constraint.z+Membership [{}] was not found in the Fleet.z'projects/{}/membershipConstraints/{}/{}namez7Constraint [{}] was not found in Fleet membership [{}].r   )r   templateenforcementAction
membershipviolationCount
violationsmatch
parameters)fleet_api_utilGetMembershipapitools_exceptionsHttpNotFoundErrorr   ErrorformatEAnthospolicycontrollerstatusPaProjectsMembershipConstraintsGetRequestuniqueIdprojects_membershipConstraintsGetconstraintRefr   constraintTemplateNamer
   get_enforcement_action_labelsix	text_typespecr   statusnumViolationskubernetesMatchr$   )	clientmessagesconstraint_name
project_idr    r   membership_objrequestresponses	            r   GetMembershipConstraintr?   2   sb   #11*2?AN.\\6==)@)@B ] CG 4488AH 
 
 
%
%

 
 
7
7

0
0mmHMM;;<>
//
'
'
,1
--
'
'
-2
--
"
"
(b
  
	.	. 


5	
	  
	.	. .


A		,. ..s   D$ AE! $:E!:Fc                 
    UR                  SR                  X25      S9nU R                  R                  U5      nUR                  R                  UR                  R                  / UR                  =(       d    S/ UR                  =(       d    SS.nUR                  SR                  U5      S9nU R                  R                  U5      nUR                    Hk  n	USR                  U	R"                  R                  U	R"                  R                  5      :X  d  MC  US	   R%                  U	R&                  R                  5        Mm     U$ ! [        R
                   a&    [        R                  " SR                  U5      5      ef = f)
z%Returns a formatted Fleet constraint.zprojects/{}/fleetConstraints/{}r   z+Constraint [{}] was not found in the fleet.r   )r   r   r"   r!   membershipsmembershipCountzprojects/{})parentz{}/{}rA   )@AnthospolicycontrollerstatusPaProjectsFleetConstraintsGetRequestr*   projects_fleetConstraintsr.   r'   r(   r   r)   refr   r0   r6   numMembershipsFAnthospolicycontrollerstatusPaProjectsMembershipConstraintsListRequestr-   ListmembershipConstraintsr/   appendmembershipRef)
r8   r9   r:   r;   r=   r>   
constraintmembership_constraints_requestmembership_constraints_responsemembership_constraints
             r   GetFleetConstraintrQ   Z   st   "WW.55) X *G //33G<H ll,,55 ..3!!005A* $,#r#r!!*- $s $/ $*$I$I$N$N$%&!  ?TT'..++BB++002 2 &&

-
-
2
24	  U 
3 
	.	. "


5		 " ""s   9E :Fc                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ N)fleetConstraintsr>   s    r   <lambda>&ListFleetConstraints.<locals>.<lambda>   s
    H$=$=r   )rE   AAnthospolicycontrollerstatusPaProjectsFleetConstraintsListRequest	_Autopager8   msgr;   	client_fnreqs        r   ListFleetConstraintsr_   }   s/    ..)MMO#	9:=
? ?r   c                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ rT   )rJ   rV   s    r   rW   +ListMembershipConstraints.<locals>.<lambda>   s
    H$B$Br   )r-   rH   rZ   r[   s        r   ListMembershipConstraintsrc      s1    33)RRT#	9:B
D Dr   c                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ rT   )fleetConstraintTemplatesrV   s    r   rW   .ListFleetConstraintTemplates.<locals>.<lambda>   s
    H$E$Er   )!projects_fleetConstraintTemplatesIAnthospolicycontrollerstatusPaProjectsFleetConstraintTemplatesListRequestrZ   r[   s        r   ListFleetConstraintTemplatesrj      s1    66)UUW#	9:E
G Gr   c                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ rT   )membershipConstraintTemplatesrV   s    r   rW   3ListMembershipConstraintTemplates.<locals>.<lambda>   s
    H$J$Jr   )&projects_membershipConstraintTemplatesNAnthospolicycontrollerstatusPaProjectsMembershipConstraintTemplatesListRequestrZ   r[   s        r   !ListMembershipConstraintTemplatesrq      s1    ;;)ZZ\#	9:J
L Lr   c                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ rT   )#membershipConstraintAuditViolationsrV   s    r   rW    ListViolations.<locals>.<lambda>   s
    xCCr   ),projects_membershipConstraintAuditViolationsTAnthospolicycontrollerstatusPaProjectsMembershipConstraintAuditViolationsListRequestrZ   r[   s        r   ListViolationsrx      s2    AA)``b#	jC
E Er   c                 V    U R                   nUR                  5       n[        X4US 5      $ )Nc                     U R                   $ rT   )rA   rV   s    r   rW   !ListMemberships.<locals>.<lambda>   s
    H$8$8r   )projects_memberships<AnthospolicycontrollerstatusPaProjectsMembershipsListRequestrZ   r[   s        r   ListMembershipsr~      s/    )))HHJ#	9:8
: :r   c                     / nSn SU-   Ul         XQl        U R                  U5      nXC" U5      -  nUR                  (       d   U$ UR                  nMM  )a  Auto-page through the responses if the next page token is not empty and returns a list of all resources.

Args:
  client_fn: Function specific to the endpoint
  request: Request object specific to the endpoint
  project_id: Project id that will be used in populating the request object
  resource_collector: Function to be used for retrieving the relevant field
    from the response

Returns:
  List of all resources specific to the endpoint
 z	projects/)rC   	pageTokenrI   nextPageToken)r]   r=   r;   resource_collector	resourcesnext_page_tokenr>   s          r   rZ   rZ      se     )/ :-GN'~~g&H#H--I!!	 ,,O 	r   )__doc__
__future__r   r   r   apitools.base.pyr   r'   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   *googlecloudsdk.command_lib.container.fleetr	   r%   ;googlecloudsdk.command_lib.container.fleet.policycontrollerr
   googlecloudsdk.corer2   r   r   r   r?   rQ   r_   rc   rj   rq   rx   r~   rZ    r   r   <module>r      sj    5 &  ' > , ( Q Q * 
>55%P F?DGLE:r   