
                         r    d 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  G d	 d
e      Zy)z.API library for access context manager levels.    )absolute_import)division)unicode_literals)
list_pager)util)waiter)	resourcesc                   .    e Zd ZddZddZ	 	 	 	 	 ddZy)ClientNc                     |xs t        j                  |      | _        |xs | j                  j                  | _        y )N)version)r   	GetClientclientMESSAGES_MODULEmessages)selfr   r   r   s       9lib/googlecloudsdk/api_lib/accesscontextmanager/levels.py__init__zClient.__init__   s-    ;DNN7;DK; ; ;DM    c                     | j                   j                  |j                               }t        j                  | j
                  j                  ||dd d      S )N)parentpageSizeaccessLevels)limitbatch_size_attribute
batch_sizefield)r   9AccesscontextmanagerAccessPoliciesAccessLevelsListRequestRelativeNamer   YieldFromListr   accessPolicies_accessLevels)r   
policy_refr   reqs       r   ListzClient.List#   s\    OO**, 	P 	
 
 ##//' r   c                    | j                   j                         }g }||j                  d       ||_        ||j                  d       ||_        |O|j                  d       |j
                  xs | j                   j                         |_        ||j
                  _        |O|j                  d       |j
                  xs | j                   j                         |_        ||j
                  _        |O|j                  d       |j                  xs | j                   j                         |_	        ||j                  _        |j                          | j                   }	|	j                  }
 |
||j                         dj                  |            }| j                   j"                  j%                  |      }t'        j(                  | j                   j"                  | j                   j*                  |      }t,        j.                  j1                  |j2                  d	      }t5        j6                  ||d
j9                  |j;                                     S )a  Patch an access level.

    Args:
      level_ref: resources.Resource, reference to the level to patch
      description: str, description of the level or None if not updating
      title: str, title of the level or None if not updating
      basic_level_combine_function: ZoneTypeValueValuesEnum, combine function
        enum value of the level or None if not updating
      basic_level_conditions: list of Condition, the conditions for a basic
        level or None if not updating
      custom_level_expr: the expression of the Custom level, or none if not
        updating.

    Returns:
      AccessLevel, the updated access level
    descriptiontitlezbasic.combiningFunctionzbasic.conditionscustom,)accessLevelname
updateMaskzaccesscontextmanager.operations)
collectionz Waiting for PATCH operation [{}])r   AccessLevelappendr&   r'   basic
BasicLevelcombiningFunction
conditionsr(   CustomLevelexprsort:AccesscontextmanagerAccessPoliciesAccessLevelsPatchRequestr   joinr   r!   Patchr   OperationPoller
operationsr	   REGISTRYParser+   r   WaitForformatName)r   	level_refr&   r'   basic_level_combine_functionbasic_level_conditionscustom_level_exprlevelupdate_maskmrequest_typerequest	operationpolleroperation_refs                  r   r9   zClient.Patch2   s   2 MM%%'EK'%e!ek#/23KK=4==#;#;#=ek&Bekk#)+,KK=4==#;#;#=ek5ekk$"\\@T]]%>%>%@el+ellAOOL##%88K(G
 77==gFI!!$++"I"I"&++"8"8)EF&&,,#D - FM>>*11-2D2D2FGI Ir   )NNN)N)NNNNN)__name__
__module____qualname__r   r$   r9    r   r   r   r      s#    <$ #'!>Ir   r   N)__doc__
__future__r   r   r   apitools.base.pyr   +googlecloudsdk.api_lib.accesscontextmanagerr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer	   objectr   rP   r   r   <module>rX      s/    5 &  ' ' < . )SIV SIr   