
                              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j                        Z G d
 de      Zy)z@Base class for gkemulticloud API clients for Attached resources.    )absolute_import)division)unicode_literals)client)update_mask)flagsc                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
_AttachedClientBasez2Base class for Attached gkemulticloud API clients.c                    | j                   j                  }| j                  ||      | j                  |      t	        j
                  |      | j                  |      |j                  t        j                  |      | j                  |      t	        j                  |      | j                  |      t        j                  |d      t        j                  |      | j                  |      | j!                  |      | j#                  ||      | j%                  |      d}t'        |j)                               r | j                   j                  di |S d S )NT)annotationsbinaryAuthorizationplatformVersionfleetnamedescription
oidcConfigdistributionauthorizationloggingConfigmonitoringConfigproxyConfigsecurityPostureConfigtagssystemComponentsConfig )	_messages)GoogleCloudGkemulticloudV1AttachedCluster_Annotations_BinaryAuthorizationattached_flagsGetPlatformVersion_FleetattachedClustersIdr   GetDescription_OidcConfigGetDistribution_Authorization
GetLoggingGetMonitoringConfig_ProxyConfig_SecurityPosture_TagBindings_SystemComponentsConfiganyvalues)selfcluster_refargscluster_typekwargss        >lib/googlecloudsdk/api_lib/container/gkemulticloud/attached.py_Clusterz_AttachedClientBase._Cluster   s"   >>KKL((|<#88>)<<TBT"..++D1&&t,&66t<,,T2))$5!55d;((.!%!6!6t!<!!$5"&">">t"DF& v}} 	A@@J6J     c                     dt        j                  |      i}t        j                  |      }|r|j                  d      |d<   t	        |j                               r | j                  j                  di |S d S )N	issuerUrlzutf-8)encodingjwksr   )r    GetIssuerUrlGetOidcJwksencoder.   r/   r   ,GoogleCloudGkemulticloudV1AttachedOidcConfig)r0   r2   r4   oidcs       r5   r%   z_AttachedClientBase._OidcConfig7   s{    ^006F %%d+D{{G{4fVn v}} 	DCCMfM r7   c                     t        j                  |      }t        j                  |      }|s|r;d| j                  j	                  ||      i} | j                  j
                  di |S y )NkubernetesSecret)r   	namespacer   )r    GetProxySecretNameGetProxySecretNamespacer   *GoogleCloudGkemulticloudV1KubernetesSecret-GoogleCloudGkemulticloudV1AttachedProxyConfig)r0   r2   secret_namesecret_namespacer4   s        r5   r*   z _AttachedClientBase._ProxyConfigD   sz     33D9K%==dC&

..
C
C( D f G$..
F
F 
 r7   c                    t        j                  |      }t        j                  |      }|s|sy i }|r-|D cg c]  }| j                  j                  |        c}|d<   |r-|D cg c]  }| j                  j                  |        c}|d<   t        |j                               sy  | j                  j                  di |S c c}w c c}w )N)username
adminUsers)groupadminGroupsr   )
r    GetAdminUsersr   GetAdminGroupsr   -GoogleCloudGkemulticloudV1AttachedClusterUser.GoogleCloudGkemulticloudV1AttachedClusterGroupr.   r/   7GoogleCloudGkemulticloudV1AttachedClustersAuthorization)r0   r2   admin_usersadmin_groupsr4   ugs          r5   r'   z"_AttachedClientBase._AuthorizationV   s     ..t4K''-L|F
 	 a ..
F
F G  	f\   a ..
G
Ga
G
Pf] v}}NNN 	
	
s   #C'#Cc                    t        j                  |      }t        j                  |      }|s|sy i }|rZ|D cg c]K  }| j                  j	                  |d   |d   | j                  |d         | j                  |d               M c}|d<   |r1|D cg c]"  }| j                  j                  |||         $ c}|d<    | j                  j                  d	i |S c c}w c c}w )
Nr            )keyvaluekeyOperatoreffecttolerations)r\   r]   labelsr   )	r    GetSystemComponentLabelsGetSystemComponentTolerationsr   $GoogleCloudGkemulticloudV1Toleration_ConvertTolerationOperator_ConvertTolerationEffectGoogleCloudGkemulticloudV1Label0GoogleCloudGkemulticloudV1SystemComponentsConfig)r0   r2   ra   r`   r4   tr\   s          r5   r-   z+_AttachedClientBase._SystemComponentsConfigp   s   44T:F >>tDK+F  a ..
=
=A$aD99!A$?221Q48	 >  f]  
 c	 ..
8
83K 9  fX K4>>JJ 
 #s   AC'C"c                 ,   |j                         dk(  r%| j                  j                  j                  d      S |j                         dk(  r%| j                  j                  j                  d      S | j                  j                  j                  d      S )NexistsKEY_OPERATOR_EXISTSequalKEY_OPERATOR_EQUALKEY_OPERATOR_UNSPECIFIED)lowerr   rd   KeyOperatorValueValuesEnum)r0   operators     r5   re   z._AttachedClientBase._ConvertTolerationOperator   s    ~~8#^^@@[[
  ~~7"^^@@[[
  >>>>YY" r7   c                 h   |j                         }|dk(  r%| j                  j                  j                  d      S |dk(  r%| j                  j                  j                  d      S |dk(  r%| j                  j                  j                  d      S | j                  j                  j                  d      S )N
noscheduleEFFECT_NO_SCHEDULE	noexecuteEFFECT_NO_EXECUTEprefernoscheduleEFFECT_PREFER_NO_SCHEDULEEFFECT_UNSPECIFIED)rp   r   rd   EffectValueValuesEnum)r0   r_   standardized_effects      r5   rf   z,_AttachedClientBase._ConvertTolerationEffect   s     ,,.l*^^@@VV
  k)^^@@VV
  00^^@@VV
%  >>>>TT r7   N)__name__
__module____qualname____doc__r6   r%   r*   r'   r-   re   rf   r   r7   r5   r
   r
      s(    :2$48r7   r
   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )ClustersClientz6Client for Attached Clusters in the gkemulticloud API.c                 p    t        t        | 
  di | | j                  j                  | _        d| _        y )NattachedClustersr   )superr   __init___client#projects_locations_attachedClusters_service_list_result_field)r0   r4   	__class__s     r5   r   zClustersClient.__init__   s.    	.$(262LLDDDM0Dr7   c                    | j                   j                  |j                         j                         | j	                  ||      |j
                  t        j                  |            }| j                  j                  |      S )zCreates an Attached cluster.)parent)googleCloudGkemulticloudV1AttachedClusterattachedClusterIdvalidateOnly)
r   ;GkemulticloudProjectsLocationsAttachedClustersCreateRequestParentRelativeNamer6   r#   r   GetValidateOnlyr   Creater0   r1   r2   reqs       r5   r   zClustersClient.Create   sr    
..
T
T!!#00226--3
 &88**40 U C ==$$r7   c                    | j                   j                  | j                  ||      |j                         t	        j
                  |t        j                        t        j                  |            }| j                  j                  |      S )zUpdates an Attached cluster.)r   r   
updateMaskr   )r   :GkemulticloudProjectsLocationsAttachedClustersPatchRequestr6   r   r   GetUpdateMask%ATTACHED_CLUSTER_ARGS_TO_UPDATE_MASKSr   r   r   Patchr   s       r5   UpdatezClustersClient.Update   s{    
..
S
S26--3
 %%',,+CC
 **40 T 	C ==s##r7   c                 v   | j                   j                  |j                         | j                   j                  |j                         t	        j
                  |      t	        j                  |      | j                  |      t        j                  |                  }| j                  j                  |      S )z-Imports an Attached cluster fleet membership.)fleetMembershipr   r   r   r   )r   6googleCloudGkemulticloudV1ImportAttachedClusterRequest)r   ;GkemulticloudProjectsLocationsAttachedClustersImportRequestr   6GoogleCloudGkemulticloudV1ImportAttachedClusterRequestr    r!   r&   r*   r   r   r   Import)r0   location_reffleet_membership_refr2   r   s        r5   r   zClustersClient.Import   s    
..
T
T((*?C~~  @E  @E0==?*==dC'77=))$/..t4 @E @
 U 	C ==$$r7   )	r}   r~   r   r   r   r   r   r   __classcell__)r   s   @r5   r   r      s    >1

%$%r7   r   N)r   
__future__r   r   r   .googlecloudsdk.api_lib.container.gkemulticloudr   r   -googlecloudsdk.command_lib.container.attachedr   r    2googlecloudsdk.command_lib.container.gkemulticloud
ClientBaser
   r   r   r7   r5   <module>r      sB    G &  ' A F Q DN&++ Nb.%( .%r7   