
    C1                         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 G d de      Z G d de      Zy)z=Base class for gkemulticloud API clients for Azure resources.    )absolute_import)division)unicode_literals)client)update_mask)resource_args)flagsc                   j    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zy)_AzureClientBasez/Base class for Azure gkemulticloud API clients.c                    t        |d      r4|j                  d      r#t        j                  |      j	                         nd }| j
                  j                  }| j                  ||      | j                  |      || j                  |      t        j                  |      | j                  |      t        j                  |      | j                  |      t        j                  |      t        j                   |      |j"                  | j%                  |      t        j&                  |      d}t)        |j+                               r | j
                  j                  di |S d S )Nr   )annotationsauthorizationazureClientazureServicesAuthenticationazureRegioncontrolPlanedescriptionfleetloggingConfigmonitoringConfigname
networkingresourceGroupId )hasattrIsSpecifiedr   ParseAzureClientResourceArgRelativeName	_messages&GoogleCloudGkemulticloudV1AzureCluster_Annotations_Authorization_AzureServicesAuthenticationr	   GetAzureRegion_ControlPlaneGetDescription_Fleet
GetLoggingGetMonitoringConfigazureClustersId_ClusterNetworkingGetResourceGroupIdanyvalues)selfcluster_refargsazure_clientcluster_typekwargss         ;lib/googlecloudsdk/api_lib/container/gkemulticloud/azure.py_Clusterz_AzureClientBase._Cluster   s2    4"t'7'7'A 	11$7DDF 
 >>HHL((|<,,T2#'+'H'H'N++D1**40++D1T"))$/!55d;++--d3 33D9F" v}} 	>==GG     c                     t        j                  |      t        j                  |      d}t        |j	                               sy  | j
                  j                  di |S )N)applicationIdtenantIdr   )r	   GetAzureApplicationIDGetAzureTenantIDr-   r.   r   5GoogleCloudGkemulticloudV1AzureServicesAuthenticationr/   r1   r4   s      r5   r#   z-_AzureClientBase._AzureServicesAuthentication:   sY    44T:**40F v}}O4>>OO 
 r7   c                     t        |dd       |j                  t        |dd       d}t        |j                               r | j                  j
                  di |S d S )Napp_id	tenant_id)r9   r   r:   r   )getattrazureClientsIdr-   r.   r   %GoogleCloudGkemulticloudV1AzureClient)r/   
client_refr1   r4   s       r5   _Clientz_AzureClientBase._ClientE   sb     x6))D+t4F v}} 	=<<FvF r7   c                    | j                   j                  }| j                  ||      | j                  |      t	        j
                  |      | j                  |      | j                  |      | j                  |      |j                  t	        j                  |      t	        j                  |      d	}t        |j                               r | j                   j                  di |S d S )N)	r   autoscalingazureAvailabilityZoneconfig
managementmaxPodsConstraintr   subnetIdversionr   )r   'GoogleCloudGkemulticloudV1AzureNodePoolr!   _Autoscalingr	   GetAzureAvailabilityZone_NodeConfig_NodeManagement_MaxPodsConstraintazureNodePoolsIdGetSubnetIDGetNodeVersionr-   r.   )r/   node_pool_refr1   nodepool_typer4   s        r5   	_NodePoolz_AzureClientBase._NodePoolQ   s    NNJJM((}=((.!&!?!?!E""4(**40!44T:..%%d+''-
F v}} 	?>>HH r7   c                     i }|dk(  rt        j                  |      |d<   n|dk(  rt        j                  |      |d<   t        |j	                               r | j
                  j                  di |S d S )NrootsizeGibmainr   )r	   GetRootVolumeSizeGetMainVolumeSizer-   r.   r   +GoogleCloudGkemulticloudV1AzureDiskTemplate)r/   r1   kindr4   s       r5   _DiskTemplatez_AzureClientBase._DiskTemplated   sx    Fv~11$7fY	11$7fY v}} 	CBBLVL r7   c                     t        j                  |      t        j                  |      d}t        |j	                               r | j
                  j                  di |S d S )N)r   secretIdr   )r	   GetProxyResourceGroupIdGetProxySecretIdr-   r.   r   *GoogleCloudGkemulticloudV1AzureProxyConfigr>   s      r5   _ProxyConfigz_AzureClientBase._ProxyConfigp   s^     88>**40F v}} 	BAAKFK r7   c                     t        j                  |      t        j                  |      d}t        |j	                               r | j
                  j                  di |S d S )N)keyId	publicKeyr   )r	   GetConfigEncryptionKeyIdGetConfigEncryptionPublicKeyr-   r.   r   /GoogleCloudGkemulticloudV1AzureConfigEncryptionr>   s      r5   _ConfigEncryptionz"_AzureClientBase._ConfigEncryption{   s^    //577=F v}} 	GFFPP 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	   GetAdminUsersGetAdminGroupsr   *GoogleCloudGkemulticloudV1AzureClusterUser+GoogleCloudGkemulticloudV1AzureClusterGroupr-   r.   ,GoogleCloudGkemulticloudV1AzureAuthorization)r/   r1   admin_usersadmin_groupsr4   ugs          r5   r"   z_AzureClientBase._Authorization   s    %%d+K''-L|F
 	 a ..
C
C D  	f\   a ..
D
D1
D
Mf] v}}CCC 	
	
s   #C'#Cc                    t        j                  |      t        j                  |      t        j                  |      t        j                  |      d}t        |j                               sy  | j                  j                  di |S )N)podAddressCidrBlocksserviceAddressCidrBlocksserviceLoadBalancerSubnetIdvirtualNetworkIdr   )	r	   GetPodAddressCidrBlocksGetServiceAddressCidrBlocksGetServiceLoadBalancerSubnetId	GetVnetIdr-   r.   r   0GoogleCloudGkemulticloudV1AzureClusterNetworkingr>   s      r5   r+   z#_AzureClientBase._ClusterNetworking   sx     % = =d C$)$E$Ed$K','K'K(
 "OOD1F v}}J4>>JJ 
 r7   c                 P   | j                   j                  }| j                  |      | j                  |      t	        j
                  |      | j                  |d      | j                  |      t	        j                  |      | j                  |d      | j                  |      t	        j                  |      | j                  ||      t	        j                  |      t	        j                  |      d}t        |j                               r | j                   j                  di |S d S )Nr^   r\   )configEncryptiondatabaseEncryptionendpointSubnetId
mainVolumeproxyConfigreplicaPlacements
rootVolume	sshConfigrM   tagsrN   vmSizer   )r   +GoogleCloudGkemulticloudV1AzureControlPlanerp   _DatabaseEncryptionr	   GetEndpointSubnetIdrc   ri   GetReplicaPlacements
_SshConfigrV   _TagsGetClusterVersion	GetVMSizer-   r.   )r/   r1   control_plane_typer4   s       r5   r%   z_AzureClientBase._ControlPlane   s    BB  !2248"66t<!55d;((v6((."77=((v6__T*%%d+

4!34**40//$'F  v}} 	CBBLVL r7   c                     dt        j                  |      i}t        |j                               r | j                  j
                  di |S d S )NauthorizedKeyr   )r	   GetSSHPublicKeyr-   r.   r   (GoogleCloudGkemulticloudV1AzureSshConfigr>   s      r5   r   z_AzureClientBase._SshConfig   sR    ..t4F
 v}} 	@??I&I r7   c                     dt        j                  |      i}t        |j                               sy  | j                  j
                  di |S )Nrk   r   )r	   GetDatabaseEncryptionKeyIdr-   r.   r   1GoogleCloudGkemulticloudV1AzureDatabaseEncryptionr>   s      r5   r   z$_AzureClientBase._DatabaseEncryption   sM    11$7F v}}K4>>KK 
 r7   c                     t        j                  |      t        j                  |      d}t        |j	                               sy  | j
                  j                  di |S )N)minNodeCountmaxNodeCountr   )r	   GetMinNodesGetMaxNodesr-   r.   r   2GoogleCloudGkemulticloudV1AzureNodePoolAutoscalingr>   s      r5   rP   z_AzureClientBase._Autoscaling   sY    ))$/))$/F v}}L4>>LL 
 r7   c                    | j                   j                  }| j                  |      t        j                  |      | j                  ||      | j                  |      | j                  |d      | j                  |      | j                  ||      t        j                  |      t        j                  |      d	}t        |j                               r | j                   j                  di |S d S )Nr\   )	r   	imageTypelabelsr   r   r   r   taintsr   r   )r   )GoogleCloudGkemulticloudV1AzureNodeConfigrp   r	   GetImageType_Labelsri   rc   r   r   GetNodeTaintsr   r-   r.   )r/   r1   node_config_typer4   s       r5   rR   z_AzureClientBase._NodeConfig   s    ~~OO 2248''-,,t%56((.((v6__T*

4!12%%d+//$'
F v}} 	A@@J6J r7   c                     dt        j                  |      i}t        |j                               r | j                  j
                  di |S d S )N
autoRepairr   )r	   GetAutoRepairr-   r.   r   -GoogleCloudGkemulticloudV1AzureNodeManagementr>   s      r5   rS   z _AzureClientBase._NodeManagement   sR    e))$/F
 v}} 	EDDNvN r7   N)__name__
__module____qualname____doc__r6   r#   rF   rZ   rc   ri   rp   r"   r+   r%   r   r   rP   rR   rS   r   r7   r5   r   r      sP    78	
&
		40	&r7   r   c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )ClustersClientz3Client for Azure Clusters in the gkemulticloud API.c                 p    t        t        | 
  di | | j                  j                  | _        d| _        y )NazureClustersr   )superr   __init___client projects_locations_azureClusters_service_list_result_fieldr/   r4   	__class__s     r5   r   zClustersClient.__init__  s.    	.$(262LLAADM-Dr7   c                    | j                   j                  |j                  | j                  ||      |j	                         j                         t        j                  |            }| j                  j                  |      S )z&Creates a new Anthos cluster on Azure.)azureClusterId&googleCloudGkemulticloudV1AzureClusterparentvalidateOnly)
r   8GkemulticloudProjectsLocationsAzureClustersCreateRequestr*   r6   Parentr   r	   GetValidateOnlyr   Creater/   r0   r1   reqs       r5   r   zClustersClient.Create  sw     	OO&6637==T4 %%'446..t4 	P 	
  ==$$r7   c                      | j                   j                  d      |j                               }| j                   j                  |      S )z/Generates an access token for an Azure cluster.GenerateAzureAccessToken)azureCluster)r   GetRequestTyper   r   )r/   r0   r   s      r5   GenerateAccessTokenz"ClustersClient.GenerateAccessToken  sA    
B$--
&
&'A
B --/C ==11#66r7   c                    | j                   j                  | j                  ||      |j                         t	        j
                  |t        j                        t        j                  |            }| j                  j                  |      S )z#Updates an Anthos cluster on Azure.)r   r   
updateMaskr   )r   7GkemulticloudProjectsLocationsAzureClustersPatchRequestr6   r   r   GetUpdateMask"AZURE_CLUSTER_ARGS_TO_UPDATE_MASKSr	   r   r   Patchr   s       r5   UpdatezClustersClient.Update!  s     	NN37==T4 ))+"00kDD ..t4 	O 		
  ==s##r7   )	r   r   r   r   r   r   r   r   __classcell__r   s   @r5   r   r     s    ;.
%7$r7   r   c                   .     e Zd ZdZ fdZd Zd Z xZS )NodePoolsClientz5Client for Azure Node Pools in the gkemulticloud API.c                 p    t        t        | 
  di | | j                  j                  | _        d| _        y )NazureNodePoolsr   )r   r   r   r   /projects_locations_azureClusters_azureNodePoolsr   r   r   s     r5   r   zNodePoolsClient.__init__5  s.    	/4)3F3LLPPDM.Dr7   c                    | j                   j                  |j                  | j                  ||      |j	                         j                         t        j                  |            }| j                  j                  |      S )z2Creates a node pool in an Anthos cluster on Azure.)azureNodePoolId'googleCloudGkemulticloudV1AzureNodePoolr   r   )
r   FGkemulticloudProjectsLocationsAzureClustersAzureNodePoolsCreateRequestrU   rZ   r   r   r	   r   r   r   r/   nodepool_refr1   r   s       r5   r   zNodePoolsClient.Create:  sr    
..
_
_$5504$1
 ""$113**40 ` C ==$$r7   c                    | j                   j                  | j                  ||      |j                         t	        j
                  |t        j                        t        j                  |            }| j                  j                  |      S )z2Updates a node pool in an Anthos cluster on Azure.)r   r   r   r   )r   EGkemulticloudProjectsLocationsAzureClustersAzureNodePoolsPatchRequestrZ   r   r   r   #AZURE_NODEPOOL_ARGS_TO_UPDATE_MASKSr	   r   r   r   r   s       r5   r   zNodePoolsClient.UpdateF  s{    
..
^
^04$1
 &&(,,+AA
 **40 _ 	C ==s##r7   )r   r   r   r   r   r   r   r   r   s   @r5   r   r   2  s    =/

%$r7   r   c                   (     e Zd ZdZ fdZd Z xZS )ClientsClientz2Client for Azure Clients in the gkemulticloud API.c                 p    t        t        | 
  di | | j                  j                  | _        d| _        y )NazureClientsr   )r   r   r   r   projects_locations_azureClientsr   r   r   s     r5   r   zClientsClient.__init__X  s.    	-'1&1LL@@DM,Dr7   c                    | j                   j                  | j                  ||      |j                  |j	                         j                         t        j                  |            }| j                  j                  |      S )zCreates a new Azure client.)%googleCloudGkemulticloudV1AzureClientazureClientIdr   r   )
r   7GkemulticloudProjectsLocationsAzureClientsCreateRequestrF   rC   r   r   r	   r   r   r   )r/   rE   r1   r   s       r5   r   zClientsClient.Create]  sw     	NN26,,D3 %33$$&335..t4 	O 	
  ==$$r7   )r   r   r   r   r   r   r   r   s   @r5   r   r   U  s    :-
%r7   r   N)r   
__future__r   r   r   .googlecloudsdk.api_lib.container.gkemulticloudr   r   *googlecloudsdk.command_lib.container.azurer   2googlecloudsdk.command_lib.container.gkemulticloudr	   
ClientBaser   r   r   r   r   r7   r5   <module>r      s^    D &  ' A F D Dfv(( fR+$% +$\ $&  $F%$ %r7   