
    z                     f    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	\
5      rg
)3API helpers for interacting with platform policies.    )absolute_import)division)unicode_literals)encoding)
list_pager)apisc                   R    \ rS rSrSrSS jrS rS r  SS jrS r	S	 r
SS
 jrSrg)Client   r   Nc                 p    [         R                  " U5      U l        [         R                  " U5      U l        g N)r	   GetClientInstanceclientGetMessagesModulemessages)selfapi_versions     @lib/googlecloudsdk/api_lib/container/binauthz/platform_policy.py__init__Client.__init__   s&    ((5DK**;7DM    c                 ~    U R                   R                  US9nU R                  R                  R	                  U5      $ )z{Describes a policy.

Args:
  policy_ref: the resource name of the policy being described.

Returns:
  The policy resource.
name)r   6BinaryauthorizationProjectsPlatformsPoliciesGetRequestr   projects_platforms_policiesGet)r   
policy_refget_reqs      r   DescribeClient.Describe!   sA     	LL 	M 	
 
 ;;2266w??r   c                 X    Xl         U R                  R                  R                  U5      $ )zUpdates a policy.

Args:
  policy_ref: the resource name of the policy being updated.
  policy: the contents of the new policy.

Returns:
  The updated policy resource.
)r   r   r   ReplacePlatformPolicy)r   r   policys      r   UpdateClient.Update1   s$     K;;22HHPPr   c           	          [         R                  " U R                  R                  U R                  R                  US9SUSU=(       d    SS9$ )aX  Lists policies.

Args:
  platform_ref: the resource name of the platform whose policies are being
    listed.
  page_size: The number of policies to retrieve in one request (when None,
    use the default size).
  limit: int, The maximum number of policies to yield (when None, unlimted).

Returns:
  A list of policies for the given platform.
)parentplatformPoliciespageSized   )fieldlimitbatch_size_attribute
batch_size)r   YieldFromListr   r   r   7BinaryauthorizationProjectsPlatformsPoliciesListRequest)r   platform_ref	page_sizer.   s       r   ListClient.List>   sP    $ ##//MM 	N 	! '# r   c                     U R                   R                  UR                  5       R                  5       UR	                  5       US9nU R
                  R                  R                  U5      $ )zCreates a policy.

Args:
  policy_resource_name: Resource object representing the resource name of
    the policy to create.
  policy: The policy to create.

Returns:
  The policy resource.
)r)   policyIdplatformPolicy)r   9BinaryauthorizationProjectsPlatformsPoliciesCreateRequestParentRelativeNameNamer   r   Create)r   policy_resource_namer%   requests       r   r>   Client.CreateZ   sb     	OO'..0==?)..0! 	P 	# 
 ;;2299'BBr   c                 ~    U R                   R                  US9nU R                  R                  R	                  U5      $ )zDeletes a policy.

Args:
  policy_ref: the resource name of the policy being deleted.

Returns:
  The resource name of the deleted policy.
r   )r   9BinaryauthorizationProjectsPlatformsPoliciesDeleteRequestr   r   Delete)r   r   r@   s      r   rD   Client.Deletel   sA     	OO 	P 	
 
 ;;2299'BBr   c                 ,   [         R                  " SU0US.U R                  R                  5      nU(       a9  U R                  R                  R
                  R                  UR                  l        U R                  R                  R                  U5      $ )a-  Evaluate a policy against a Kubernetes resource.

Args:
  policy_ref: the resource name of the policy.
  resource: the Kubernetes resource in JSON or YAML form.
  generate_deploy_attestations: whether to sign results or not.

Returns:
  The result of the evaluation in EvaluateGkePolicyResponse form.
resource)evaluateGkePolicyRequestr   )r   DictToMessager   >BinaryauthorizationProjectsPlatformsGkePoliciesEvaluateRequestEvaluateGkePolicyRequestAttestationModeValueValuesEnumGENERATE_DEPLOYrH   attestationModer   projects_platforms_gke_policiesEvaluate)r   r   rG   generate_deploy_attestationsr@   s        r   rP   Client.Evaluate|   s     $$ H) 		
 	TTG $
--
0
0
O
O
_
_ &&6 ;;66??HHr   )r   r   r   )r,   N)F)__name__
__module____qualname____firstlineno____doc__r   r!   r&   r5   r>   rD   rP   __static_attributes__ r   r   r   r      s5    ;8@ Q  	8C$C Ir   r   N)rW   
__future__r   r   r   apitools.base.pyr   r   )googlecloudsdk.api_lib.container.binauthzr	   objectr   rY   r   r   <module>r^      s,    : &  ' % ' :{IV {Ir   