
                  
       (   d Z ddlmZ ddlmZ ddlmZ ddl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 Zd Zd Zd Z ej.                  d ej0                         j2                  j4                  d       ZdZdj;                  dj=                  ej>                  D  cg c]
  }  e|        c}             Z dZ!ejD                  ejF                  gZ$ejJ                  ejD                  ejF                  gZ& ej.                  d ej0                         jN                  jP                  d       Z)d Z*d Z+d Z,d Z-ddZ.d Z/d Z0d Z1d  Z2dd!Z3d" Z4dd#Z5d$ Z6dd%Z7d& Z8d' Z9d( Z:dd)Z;d* Z<d+ Z=d, Z>dd-Z?d. Z@dd/ZAd0 ZBd1 ZCd2 ZDd3 ZEd4 ZFd5 ZGd6 ZHd7 ZId8 ZJdd9ZKd: ZLd; ZMd< ZNd= ZOd> ZPd? ZQd@ ZRdA ZSdB ZTdC ZUdD ZVdE ZWdF ZXdG ZYdH ZZdI Z[dJ Z\dK Z]dL Z^dM Z_dN Z`dO ZadP ZbdQ ZcdR ZddS ZedT ZfdU ZgdV ZhdW ZidX ZjdY ZkdZ Zldd[Zmd\ Znd] Zod^ Zpd_ Zqd` ZrddaZsddbZtdc Zudd Zvde Zwdf Zxdg Zydh Zzdi Z{dj Z|dk Z}dl Z~dm Zdn ZddoZdp Zdq Zdr Z	 ddsZdt Zdu Zdv Zdw Zdx Zdy Zdz Zd{ Zd| Zd} Zd~ ZddZd Zd Zd Zd Zd Zyc c} w )z;Helpers for flags in commands working with GKE Multi-cloud.    )absolute_import)division)unicode_literalsN)util)arg_parsers)	constants)	arg_utils)
propertiesc                 T    | j                  d      }dj                  d |D              S )z'Converts hyphen-case name to CamelCase.- c              3   <   K   | ]  }|j                           y w)N)title).0xs     ?lib/googlecloudsdk/command_lib/container/gkemulticloud/flags.py	<genexpr>z_ToCamelCase.<locals>.<genexpr>"   s     *EqEs   )splitjoinnamepartss     r   _ToCamelCaser      s$    
**S/%	*E*	**    c                 b    | j                  d      }dj                  |      j                         S )z(Converts hyphen-case name to SNAKE_CASE.r   _)r   r   upperr   s     r   _ToSnakeCaseUpperr   %   &    
**S/%	%			  r   c                 b    | j                  d      }dj                  |      j                         S )z#Converts SNAKE_CASE to hyphen-case.r   r   )r   r   lowerr   s     r   _ToHyphenCaser"   +   r   r   c                 N    t        j                  dj                  | ||            S )Nz&Invalid value [{}] for argument {}. {})r   ArgumentTypeErrorformat)valueflagdetails      r   _InvalidValueErrorr)   1   s'    		&	&.55eT6J
 r   --node-taintsc                 
    d| vS NUNSPECIFIED )effects    r   <lambda>r0   :   s	    -v"=r   )include_filterz)Node taint is of format key=value:effect.zEffect must be one of: {}.z, zIReplica placement is of format subnetid:zone, for example subnetid12345:1--binauthz-evaluation-modec                 
    d| vS r,   r.   )modes    r   r0   r0   R   s	    T 9r   c                 ,    | j                  ddd       y)z(Adds the --pod-address-cidr-blocks flag.z--pod-address-cidr-blocksTzQIP address range for the pods in this cluster in CIDR notation (e.g. 10.0.0.0/8).requiredhelpNadd_argumentparsers    r   AddPodAddressCidrBlocksr=   V   s     !(	  r   c                 *    t        | dd      }|r|gS g S )z1Gets the value of --pod-address-cidr-blocks flag.pod_address_cidr_blocksNgetattrargscidr_blockss     r   GetPodAddressCidrBlocksrE   b   s     7>+%+-2-r   c                 ,    | j                  ddd       y)z+Add the --service-address-cidr-blocks flag.z--service-address-cidr-blocksTzIIP address range for the services IPs in CIDR notation (e.g. 10.0.0.0/8).r6   Nr9   r;   s    r   AddServiceAddressCidrBlocksrG   h   s     %	  r   c                 *    t        | dd      }|r|gS g S )z5Gets the value of --service-address-cidr-blocks flag.service_address_cidr_blocksNr@   rB   s     r   GetServiceAddressCidrBlocksrJ   t   s     ;TB+%+-2-r   c                 J    | j                  d|dj                  |             y)zAdd the --subnet-id flag.z--subnet-idz,Subnet ID of an existing VNET to use for {}.r6   Nr:   r%   )r<   	help_textr7   s      r   AddSubnetIDrN   z   s)    9@@K  r   c                     t        | dd       S )N	subnet_idr@   rC   s    r   GetSubnetIDrR          	{D	))r   c                 H    | j                  ddj                  |             y)zAdd an output file argument.

  Args:
    parser: The argparse.parser to add the output file argument to.
    help_action: str, describes the action of what will be stored.
  z--output-filezPath to the output file {}.r8   NrL   r<   help_actions     r   AddOutputFilerX      s(     	9@@M  r   c                 J    | j                  dddj                  |             y)zAdd the --validate-only argument.

  Args:
    parser: The argparse.parser to add the argument to.
    help_action: str, describes the action that will be validated.
  z--validate-only
store_truez/Validate the {}, but don't actually perform it.actionr8   NrL   rV   s     r   AddValidateOnlyr]      s.     	<CC
  r   c                     t        | dd       S )Nvalidate_onlyr@   rQ   s    r   GetValidateOnlyr`          		--r   c                 @    d}|r|dz  }| j                  ddd |       y )NzzEnable node autorepair feature for a node pool. Use --no-enable-autorepair to disable.

  $ {command} --enable-autorepair
z)
Node autorepair is disabled by default.
z--enable-autorepairrZ   r\   defaultr8   r9   r<   
for_createrM   s      r   AddEnableAutoRepairrg      s;    )
   I 	L$Y  r   c                     t        | dd       S )Nenable_autorepairr@   rQ   s    r   GetAutoRepairrj          	*D	11r   c                 ,    | j                  d|d       y )Nz--cluster-versionz*Kubernetes version to use for the cluster.r6   r9   r<   r7   s     r   AddClusterVersionrn      s    7  r   c                     t        | dd       S )Ncluster_versionr@   rQ   s    r   GetClusterVersionrq          	($	//r   c                 ,    | j                  d|d       y )Nz--descriptionzDescription for the cluster.r6   r9   rm   s     r   AddDescriptionrt      s    /M  r   c                     t        | dd       S )Ndescriptionr@   rQ   s    r   GetDescriptionrw          	}d	++r   c                 .    | j                  dddd       y)zgAdds the --clear-description flag.

  Args:
    parser: The argparse.parser to add the arguments to.
  z--clear-descriptionrZ   Nz&Clear the description for the cluster.rc   r9   r;   s    r   AddClearDescriptionrz      s#     	3	  r   c                 V    | j                  dd      }t        |       t        |       y)zoAdds description related flags for update.

  Args:
    parser: The argparse.parser to add the arguments to.
  DescriptionTmutexN)	add_grouprt   rz   r<   groups     r   AddDescriptionForUpdater      s)     

=

5%er   c                 t    | j                  dt        j                  d      ddj                  |             y )Nz--annotations   
min_length
ANNOTATIONzAnnotations for the {}.typemetavarr8   )r:   r   ArgDictr%   r<   nouns     r   AddAnnotationsr      s7    !,$++D1	  r   c                 L    | j                  ddddj                  |             y)zAdds flag for clearing the annotations.

  Args:
    parser: The argparse.parser to add the arguments to.
    noun: The resource type to which the flag is applicable.
  z--clear-annotationsrZ   Nz!Clear the annotations for the {}.rc   rL   r   s     r   AddClearAnnotationsr      s.     	.55d;	  r   c                 $    t        | dd       xs i S )Nannotationsr@   rQ   s    r   GetAnnotationsr         	}d	+	1r1r   c                 Z    | j                  dd      }t        ||       t        ||       y)zAdds annotations related flags for update.

  Args:
    parser: The argparse.parser to add the arguments to.
    noun: The resource type to which the flag is applicable.
  AnnotationsTr}   N)r   r   r   r<   r   r   s      r   AddAnnotationsForUpdater     s-     

=

5%eT"r   c                 ,    | j                  d|d       y )Nz--node-versionz,Kubernetes version to use for the node pool.r6   r9   rm   s     r   AddNodeVersionr     s    9  r   c                     t        | dd       S )Nnode_versionr@   rQ   s    r   GetNodeVersionr         	~t	,,r   c                     | j                  d|      }|j                  d|t        d       |j                  d|t        d       y)	zAdds node pool autoscaling flags.

  Args:
    parser: The argparse.parser to add the arguments to.
    required: bool, whether autoscaling flags are required.
  zNode pool autoscaling)r7   z--min-nodesz)Minimum number of nodes in the node pool.)r7   r   r8   z--max-nodesz)Maximum number of nodes in the node pool.N)add_argument_groupr:   int)r<   r7   r   s      r   AddAutoscalingr     sZ     
#
#$;h
#
O%6	   6	  r   c                 B    d}d}| j                   }| j                  }||fS )Nr   )	min_nodes	max_nodes)rC   r   r   s      r   GetAutoscalingParamsr   4  s)    ))nn)nn)
Y	r   c                     t        | dd       S )Nr   r@   rQ   s    r   GetMinNodesr   =  rS   r   c                     t        | dd       S )Nr   r@   rQ   s    r   GetMaxNodesr   A  rS   r   c                 6    | j                  dt        dd       y )Nz--max-pods-per-nodez Maximum number of pods per node.T)r   r8   r7   r:   r   r;   s    r   AddMaxPodsPerNoder   E  s!    -	  r   c                     t        | dd       S )Nmax_pods_per_noder@   rQ   s    r   GetMaxPodsPerNoder   N  rk   r   c                 *    | j                  dd       y )Nz--azure-availability-zonez<Azure availability zone where the node pool will be created.rU   r9   r;   s    r   AddAzureAvailabilityZoner   R  s    !I  r   c                     t        | dd       S )Nazure_availability_zoner@   rQ   s    r   GetAzureAvailabilityZoner   Y      	0$	77r   c                 *    | j                  dd       y )Nz	--vm-sizez1Azure Virtual Machine Size (e.g. Standard_DS1_v).rU   r9   r;   s    r   	AddVMSizer   ]  s    K  r   c                     t        | dd       S )Nvm_sizer@   rQ   s    r   	GetVMSizer   c      	y$	''r   c                 ,    | j                  d|d       y )Nz--ssh-public-keyz)SSH public key to use for authentication.r6   r9   rm   s     r   AddSSHPublicKeyr   g  s    6  r   c                     t        | dd       S )Nssh_public_keyr@   rQ   s    r   GetSSHPublicKeyr   o  s    	'	..r   c                 Z    | j                  dt        j                  g dd      d       y )Nz--root-volume-sizeGBGiBTBTiBGisuggested_binary_size_scalesdefault_unitzSize of the root volume. The value must be a whole number followed by a size unit of `GB` for gigabyte, or `TB` for terabyte. If no size unit is specified, GB is assumed.r   r8   r:   r   
BinarySizer;   s    r   AddRootVolumeSizer   s  1    !!'A
4  r   c                 >    t        | dd       }|sy t        |      dz	  S )Nroot_volume_size   rA   r   rC   sizes     r   GetRootVolumeSizer     '    	)4	0$	 
Tbr   c                 Z    | j                  dt        j                  g dd      d       y )Nz--main-volume-sizer   r   r   zSize of the main volume. The value must be a whole number followed by a size unit of `GB` for gigabyte, or `TB` for terabyte. If no size unit is specified, GB is assumed.r   r   r;   s    r   AddMainVolumeSizer     r   r   c                 >    t        | dd       }|sy t        |      dz	  S )Nmain_volume_sizer   r   r   s     r   GetMainVolumeSizer     r   r   c                     dj                  ||j                  dd      j                               }| j                  dt	        j
                  d      d|       y )	Nzz  Applies the given tags (comma separated) on the {0}. Example:

    $ {{command}} EXAMPLE_{1} --tags=tag1=one,tag2=two
   r   z--tagsr   r   TAGr   )r%   replacer   r:   r   r   )r<   r   rM   s      r   AddTagsr     sZ     fT4<<S)//12	  	!,	  r   c                 L    | j                  ddddj                  |             y)zAdds flag for clearing the tags.

  Args:
    parser: The argparse.parser to add the arguments to.
    noun: The resource type to which the flag is applicable.
  z--clear-tagsrZ   Nz/Clear any tags associated with the {}'s nodes. rc   rL   r   s     r   AddClearTagsr     s.     	<CCDI	  r   c                 Z    | j                  dd      }t        ||       t        ||       y)zAdds tags related flags for update.

  Args:
    parser: The argparse.parser to add the arguments to.
    noun: The resource type to which the flags are applicable.
  TagsTr}   N)r   r   r   r   s      r   AddTagsForUpdater     s-     

6

.%	%udr   c                 $    t        | dd       xs i S )Ntagsr@   rQ   s    r   GetTagsr     s    	vt	$	**r   c                 *    | j                  dd       y)zdAdds database encryption flags.

  Args:
    parser: The argparse.parser to add the arguments to.
  z--database-encryption-key-idzbURL the of the Azure Key Vault key (with its version) to use to encrypt / decrypt cluster secrets.rU   Nr9   r;   s    r   AddDatabaseEncryptionr     s     	$9  r   c                     t        | dd       S )Ndatabase_encryption_key_idr@   rQ   s    r   GetDatabaseEncryptionKeyIdr     s    	3T	::r   c                 P    | j                  dd       | j                  dd       y)zbAdds config encryption flags.

  Args:
    parser: The argparse.parser to add the arguments to.
  z--config-encryption-key-idz^URL the of the Azure Key Vault key (with its version) to use to encrypt / decrypt config data.rU   z--config-encryption-public-keyzLRSA key of the Azure Key Vault public key to use for encrypting config data.Nr9   r;   s    r   AddConfigEncryptionr     s<     	"5   	&  r   c                     t        | dd       S )Nconfig_encryption_key_idr@   rQ   s    r   GetConfigEncryptionKeyIdr     s    	14	88r   c                     t        | dd       S )Nconfig_encryption_public_keyr@   rQ   s    r   GetConfigEncryptionPublicKeyr     s    	5t	<<r   c                 V    | j                  dt        j                  d      dd       y)zAdds the --node-labels flag.z--node-labelsr   r   
NODE_LABELz)Labels assigned to the node pool's nodes.r   Nr:   r   r   r;   s    r   AddNodeLabelsr     s,    !,6	  r   c                 $    t        | dd       xs i S )Nnode_labelsr@   rQ   s    r   GetNodeLabelsr     r   r   c                 .    | j                  dddd       y)z"Adds the --clear-node-labels flag.z--clear-node-labelsrZ   Nz3Clear the labels assigned to the node pool's nodes.rc   r9   r;   s    r   AddClearNodeLabelsr     s!    @	  r   c                 V    | j                  dd      }t        |       t        |       y)z*Adds node labels related flags for update.zNode labelsTr}   N)r   r   r   r   s     r   AddNodeLabelsForUpdater    s'    


=

5%Ur   c                 ~    | j                  d      }t        |      dk7  rt        | dt              |d   |d   }}||fS )zValidates the node taint format.

  Node taint is of format key=value:effect.

  Args:
    taint: Node taint.

  Returns:
    The node taint value and effect if the format is valid.

  Raises:
    ArgumentError: If the node taint format is invalid.
  :   r*   r   r   )r   lenr)   _TAINT_FORMAT_HELP)taintstrsr&   r/   s       r   _ValidateNodeTaintFormatr
  "  sH     
S	$Y!^
UO5G
HHq'47%	r   c                     t        |       \  }}t        j                  D cg c]  }t        |       }}||vrt	        |dt
              | S c c}w )a  Validates the node taint.

  Node taint is of format key=value:effect. Valid values for effect include
  NoExecute, NoSchedule, PreferNoSchedule.

  Args:
    taint: Node taint.

  Returns:
    The node taint if it is valid.

  Raises:
    ArgumentError: If the node taint is invalid.
  r*   )r
  _TAINT_EFFECT_ENUM_MAPPERchoicesr   r)   _TAINT_EFFECT_HELP)r  unused_valuer/   eeffectss        r   _ValidateNodeTaintr  7  sV     2%8,&?&G&GH&G\!_&G'H7
V_6H
II	, Is   Ac           	          | j                  dt        j                  dt              ddj	                  t
        t                     y )Nr*   r   )r   
value_type
NODE_TAINTz0Taints assigned to nodes of the node pool. {} {}r   )r:   r   r   r  r%   r  r  r;   s    r   AddNodeTaintsr  M  s@    !8JK
<
C
C "4  	r   c                 n   g }t         j                  D ci c]  }t        |      | }}t        | dd      }|rw|j	                         D ]d  \  }}t        |      \  }}||   }t         j                  |      }t        j                         j                  |||      }	|j                  |	       f |S c c}w )zGets node taint objects from the arguments.

  Args:
    args: Arguments parsed from the command.

  Returns:
    The list of node taint objects.

  Raises:
    ArgumentError: If the node taint format is invalid.
  node_taintsN)keyr&   r/   )r  r  r   rA   itemsr
  GetEnumForChoiceapi_utilGetMessagesModule#GoogleCloudGkemulticloudV1NodeTaintappend)
rC   taintsr  taint_effect_mapr  kvr&   r/   r  s
             r   GetNodeTaintsr$  Z  s     &";"C"C"CQl1oq"C   mT2+!!#1.q1meV'f(99&Af((*NNuV O e mmE $ 
-s   B2c                     | j                  d      }t        |      dk7  rt        | dt              |d   |d   }}t	        j
                         j                  ||      S )aR  Converts a colon-delimited string to a GoogleCloudGkemulticloudV1ReplicaPlacement instance.

  Replica placement is of format subnetid:zone.

  Args:
    replicaplacement: Replica placement.

  Returns:
    A GoogleCloudGkemulticloudV1ReplicaPlacement instance.

  Raises:
    ArgumentError: If the Replica placement format is invalid.
  r  r  --replica-placementsr   r   )azureAvailabilityZonesubnetId)r   r  r)   _REPLICAPLACEMENT_FORMAT_HELPr  r  *GoogleCloudGkemulticloudV1ReplicaPlacement)replicaplacementr	  subnetidzones       r   _ReplicaPlacementStrToObjectr.  w  so     
			$$Y!^
02O  7DGD(  "MM $x N r   c                     | j                  dt        j                  t              ddj	                  t
                     y )Nr&  )element_typeREPLICA_PLACEMENTz1Placement info for the control plane replicas. {}r   )r:   r   ArgListr.  r%   r)  r;   s    r   AddReplicaPlacementsr3    s;    ,HI!
=
D
D+  	r   c                 (    t        | dd       }|r|S g S )Nreplica_placementsr@   )rC   r5  s     r   GetReplicaPlacementsr6    s     t%94@1	9r9r   c                 ,    | j                  ddd       y )Nz--auth-provider-cmd-pathTzAPath to the executable for the auth provider field in kubeconfig.)hiddenr8   r9   r;   s    r   AddAuthProviderCmdPathr9    s     N  r   c                 v    | j                  d      }|j                  ddd       |j                  ddd       y)	zcAdd proxy configuration flags.

  Args:
    parser: The argparse.parser to add the arguments to.
  zProxy configz--proxy-resource-group-idTz?The ARM ID the of the resource group containing proxy keyvault.r6   z--proxy-secret-idz9The URL the of the proxy setting secret with its version.N)r   r:   r   s     r   AddProxyConfigr;    sN     
#
#N
3%!L  
 F  r   c                     t        | dd       S )Nproxy_resource_group_idr@   rQ   s    r   GetProxyResourceGroupIdr>    r   r   c                     t        | dd       S )Nproxy_secret_idr@   rQ   s    r   GetProxySecretIdrA    rr   r   c                 r    | j                  dt        j                  t        j                  d      dd       y )Nz--fleet-projectz=--fleet-project must be a valid project ID or project number.TzGID or number of the Fleet host project where the cluster is registered.)r   r7   r8   )r:   r   CustomFunctionValidatorproject_utilValidateProjectIdentifierr;   s    r   AddFleetProjectrF    s<    ..

0
0
I   r   c                     t        | dd      }|sy|j                         s$dj                  t        j                  |            S dj                  |      S )a\  Gets and parses the fleet project argument.

  Project ID if specified is converted to project number. The parsed fleet
  project has format projects/<project-number>.

  Args:
    args: Arguments parsed from the command.

  Returns:
    The fleet project in format projects/<project-number>
    or None if the fleet projectnot is not specified.
  fleet_projectNzprojects/{})rA   isdigitr%   rD  GetProjectNumber)rC   ps     r   GetFleetProjectrL    sN     dOT*!	
	
 = =a @AA			a	  r   c                 .    | j                  dddd       y )Nz--private-endpointFrZ   z+If set, use private VPC for authentication.rd   r\   r8   r9   r;   s    r   AddPrivateEndpointrO    s!    8	  r   c                 .    | j                  dddd       y )Nz--exec-credentialFrZ   zBIf set, format access token as a Kubernetes execCredential object.rN  r9   r;   s    r   AddExecCredentialrQ    s!    O	  r   c                 h    d}|r|dz  }| j                  dt        j                  d      d|       y )Nz=Users that can perform operations as a cluster administrator.z> If not specified, the value of property core/account is used.z--admin-usersr   r   USERr   r:   r   r2  )r<   createhelp_txts      r   AddAdminUsersrW    s?    L(PPH!,	  r   c                     t        | d      sy | j                  r| j                  S t        j                  j                  j
                  j                         gS )Nadmin_users)hasattrrY  r
   VALUEScoreaccount	GetOrFailrQ   s    r   GetAdminUsersr_  
  sH    	}	%	



 
 
(
(
2
2
4	55r   c                 V    | j                  dd      }t        |       t        |       y)zuAdds admin group configuration flags for update.

  Args:
    parser: The argparse.parser to add the arguments to.
  zAdmin groupsTr}   N)r   AddAdminGroupsAddClearAdminGroupsr   s     r   AddAdminGroupsForUpdaterc    s)     

>

6%er   c                 X    d}| j                  dt        j                         dd|       y )NzI
Groups of users that can perform operations as a cluster administrator.
z--admin-groupsGROUPF)r   r   r7   r8   rT  )r<   rV  s     r   ra  ra    s6    ( 	   r   c                 .    | j                  dddd       y)zcAdds the --clear-admin-groups.

  Args:
    parser: The argparse.parser to add the arguments to.
  z--clear-admin-groupsrZ   Nz2Clear the admin groups associated with the clusterrc   r9   r;   s    r   rb  rb  -  s#     	?	  r   c                 N    t        | d      sy | j                  r| j                  S y )Nadmin_groups)rZ  rh  rQ   s    r   GetAdminGroupsri  ;  s'    	~	&		r   c                     d}g }|rt         }|dz  }nt        }| j                  dt        j                  d|      d|       y)	zAdds the --logging flag.z
Set the components that have logging enabled.

Examples:

  $ {command} --logging=SYSTEM
  $ {command} --logging=SYSTEM,WORKLOADz
  $ {command} --logging=NONE
	--loggingr   )r   r  	COMPONENTr   N)_ALLOW_DISABLE_LOGGING_CHOICES_LOGGING_CHOICESr:   r   r2  )r<   allow_disabledrM   logging_choicess       r   
AddLoggingrq  C  sZ    +) /4O  I 'O!_E	  r   c                    t        | dd      }|syt        j                  |v r@t        j                  |v st        j                  |v rt        dj                  |      dd      t        j                         }|j                         }|j                  }t        j                  |v r0|r|j                  |      S t        dj                  |      dd      t        j                  |vrt        dj                  |      dd      t        j                  |v r%|j                  j                  |j                         t        j                  |v r%|j                  j                  |j                         |j                  |      S )	aW  Parses and validates the value of the --logging flag.

  Args:
    args: Arguments parsed from the command.
    allow_disabled: If disabling logging is allowed for this cluster.

  Returns:
    The logging config object as GoogleCloudGkemulticloudV1LoggingConfig.

  Raises:
    ArgumentError: If the value of the --logging flag is invalid.
  loggingN,rk  zFInvalid logging config. NONE is not supported with SYSTEM or WORKLOAD.)componentConfigz.Invalid logging config. NONE is not supported.z6Must include SYSTEM logging if any logging is enabled.)rA   r   NONESYSTEMWORKLOADr)   r   r  r  0GoogleCloudGkemulticloudV1LoggingComponentConfig(EnableComponentsValueListEntryValuesEnum'GoogleCloudGkemulticloudV1LoggingConfigenableComponentsr  SYSTEM_COMPONENTS	WORKLOADS)rC   ro  rs  messagesconfigenums         r   
GetLoggingr  ^  sn    D)T*'	^^w'!Y%7%77%B
	  '')(DDF&		8	8$^^w==  >   
((7


:  W$
@ 
  
""4#9#9:7"
""4>>2		9	9 
: 
 r   c                 .    d}| j                  d|       y)zAdds the --image-type flag.z
Set the OS image type to use on node pool instances.

Examples:

  $ {command} --image-type=windows
  $ {command} --image-type=ubuntu
z--image-typerU   Nr9   r<   rM   s     r   AddImageTyper    s    ) 	n95r   c                     t        | dd       S )N
image_typer@   rQ   s    r   GetImageTyper    s    	|T	**r   c                 ,    | j                  ddd       y )Nz--azure-regionTz_Azure location to deploy the cluster. Refer to your Azure subscription for available locations.r6   r9   r;   s    r   AddAzureRegionr    s!    F	  r   c                     t        | dd       S )Nazure_regionr@   rQ   s    r   GetAzureRegionr    r   r   c                 ,    | j                  ddd       y )Nz--resource-group-idTz=ID of the Azure Resource Group to associate the cluster with.r6   r9   r;   s    r   AddResourceGroupIdr    s    J  r   c                     t        | dd       S )Nresource_group_idr@   rQ   s    r   GetResourceGroupIdr    rk   r   c                 ,    | j                  ddd       y )Nz	--vnet-idTz>ID of the Azure Virtual Network to associate with the cluster.r6   r9   r;   s    r   	AddVnetIdr    s    K  r   c                     t        | dd       S )Nvnet_idr@   rQ   s    r   	GetVnetIdr    r   r   c                 *    | j                  dd       y )Nz!--service-load-balancer-subnet-idzARM ID of the subnet where Kubernetes private service type load balancers are deployed, when the Service lacks a subnet annotation.rU   r9   r;   s    r   AddServiceLoadBalancerSubnetIdr    s    )  r   c                     t        | dd       S )Nservice_load_balancer_subnet_idr@   rQ   s    r   GetServiceLoadBalancerSubnetIdr    s    	8$	??r   c                 *    | j                  dd       y )Nz--endpoint-subnet-idzARM ID of the subnet where the control plane load balancer is deployed. When unspecified, it defaults to the control plane subnet ID.rU   r9   r;   s    r   AddEndpointSubnetIdr    s      r   c                     t        | dd       S )Nendpoint_subnet_idr@   rQ   s    r   GetEndpointSubnetIdr    s    	+T	22r   c                     | j                  d      }|j                  d|d       |j                  d|d       |st        |       yy)z8Adds --azure-tenant-id and --azure-application-id flags.zAzure services authenticationz--azure-tenant-idz1ID of the Azure Tenant to manage Azure resources.r6   z--azure-application-idz6ID of the Azure Application to manage Azure resources.N)r   r:   AddClearClient)auth_config_grouprU  r   s      r   AddAzureServicesAuthenticationr    s_    

.
./N
O%>  
 C  
 
5 
r   c                 .    | j                  dddd       y)zbAdds the --clear-client flag.

  Args:
    parser: The argparse.parser to add the arguments to.
  z--clear-clientrZ   NzClear the Azure client. This flag is required when updating to use Azure workload identity federation from Azure client to manage  Azure resources.rc   r9   r;   s    r   r  r    s%     	  	r   c                     t        | dd       S )Nazure_tenant_idr@   rQ   s    r   GetAzureTenantIDr    rr   r   c                     t        | dd       S )Nazure_application_idr@   rQ   s    r   GetAzureApplicationIDr    s    	-t	44r   c                    d}d}d}|rV| j                  ddd|       |r>| j                  dd	
      }|j                  ddd|       |j                  ddd|       yy| j                  dd	
      }|j                  dddd       |j                  dddd       |r>| j                  dd	
      }|j                  dddd       |j                  dddd       yy)z'Adds monitoring config flags to parser.aL  
  Enables managed collection for Managed Service for Prometheus in the cluster.

  See https://cloud.google.com/stackdriver/docs/managed-prometheus/setup-managed#enable-mgdcoll-gke
  for more info.

  Managed Prometheus is enabled by default for cluster versions 1.27 or greater,
  use --no-enable-managed-prometheus to disable.
  z
  Enables managed collection for Cloud Monitoring in the cluster.

  Cloud Monitoring is enabled by default for all clusters. Beginning with
  cluster version 1.31, use --disable-cloud-monitoring to disable.
  z
  Disables managed collection for Cloud Monitoring in the cluster.

  Cloud Monitoring is enabled by default for all clusters. Beginning with
  cluster version 1.31, use --disable-cloud-monitoring to disable.
  z--enable-managed-prometheusrZ   Nrc   zCloud Monitoring ConfigTr}   z--disable-cloud-monitoringz--enable-cloud-monitoringzMonitoring Configz--disable-managed-prometheusz>Disable managed collection for Managed Service for Prometheus.z=Enable managed collection for Managed Service for Prometheus.z0Disable managed collection for Cloud Monitoring.z/Enable managed collection for Cloud Monitoring.)r:   r   )r<   rf   cloud_monitoring_optionprometheus_enable_help_text!cloud_monitoring_enable_help_text"cloud_monitoring_disable_help_textr   s          r   AddMonitoringConfigr    sV   !'#($ 
%(	   8Ee
&1	   
%0	    0=E	&M	   
%L	   8Ee
&@   
%@	   r   c                    t        | dd      }t        | dd      }t        j                         }|j                         }|rd|_        n|rd|_        nd}t        | dd      }t        | dd      }t        j                         }|j                         }|rd|_        n|rd|_        nd}||y|j                  ||      S )	aA  Parses and validates the value of the managed prometheus and cloud monitoring config flags.

  Args:
    args: Arguments parsed from the command.

  Returns:
    The monitoring config object as GoogleCloudGkemulticloudV1MonitoringConfig.
    None if both enable_managed_prometheus and enable_cloud_monitoring are None.
  enable_managed_prometheusNdisable_managed_prometheusTFenable_cloud_monitoringdisable_cloud_monitoring)managedPrometheusConfigcloudMonitoringConfig)rA   r  r  1GoogleCloudGkemulticloudV1ManagedPrometheusConfigenabled/GoogleCloudGkemulticloudV1CloudMonitoringConfig*GoogleCloudGkemulticloudV1MonitoringConfig)rC   enabled_prometheusdisabled_prometheusr  prometheus_configenabled_cloud_monitoringdisabled_cloud_monitoringcloud_monitoring_configs           r   GetMonitoringConfigr  g  s     t%@$G&BDI'')(@@B   $ %$T+DdK%d,FM'')(>>@  &*# &+#"#:#B		<	</3 
= 
 r   c                 P    d}| j                  dd|j                  |             y )NzsAllow idempotent deletion of {resource}.
  The request will still succeed in case the {resource} does not exist.
  z--allow-missingrZ   )resourcer[   rL   )r<   r  rV  s      r   AddAllowMissingr    s2    ( 	??H?-  r   c                     t        | dd       S )Nallow_missingr@   rQ   s    r   GetAllowMissingr    ra   r   c                 R    d}| j                  dd|j                  ||             y )NzForce delete an {platform} {resource}.
  Deletion of the {platform} {resource} will succeed even if errors occur
  during deleting in-{resource} resources. Using this parameter may
  result in orphaned resources in the {resource}.
  z--ignore-errorsrZ   )r  platformr[   rL   )r<   r  r  rV  s       r   AddIgnoreErrorsr    s4    (
 	??Hx?@  r   c                     t        | dd       S )Nignore_errorsr@   rQ   s    r   GetIgnoreErrorsr    ra   r   c           	          | j                  dt        j                  D cg c]  }t        |       c}dd       yc c}w )z/Adds --binauthz-evaluation-mode flag to parser.r2   Nz:Set Binary Authorization evaluation mode for this cluster.)r  rd   r8   )r:   _BINAUTHZ_EVAL_MODE_ENUM_MAPPERr  r   )r<   cs     r   AddBinauthzEvaluationModer    sI    "(G(O(O(O1
A
(O G  s   <
c                 ^    t        | dd       }|y t        j                  t        |            S )Nbinauthz_evaluation_mode)rA   r  r  r"   )rC   evaluation_modes     r   GetBinauthzEvaluationModer    s5    D"<dC/	(	9	9O$
 r   c           	      Z    | j                  dddgddt        j                  d             y)z6Adds --workload-vulnerability-scanning flag to parser.z!--workload-vulnerability-scanningdisabled
enterpriseNTaS        Sets the mode of the Kubernetes security posture API's workload vulnerability scanning.
      To enable Advanced vulnerability insights mode explicitly set the flag to --workload-vulnerability-scanning=enterprise.

      To disable in an existing cluster, explicitly set the flag to --workload-vulnerability-scanning=disabled.
      )r  rd   r8  r8   )r:   textwrapdedentr;   s    r    AddWorkloadVulnerabilityScanningr    s7    )<(?? 
   r   c                     t        | dd       }|y t        j                         j                  j                  }|j
                  |j                  d}||   S )Nworkload_vulnerability_scanning)r  r  )rA   r  r  /GoogleCloudGkemulticloudV1SecurityPostureConfig VulnerabilityModeValueValuesEnumVULNERABILITY_DISABLEDVULNERABILITY_ENTERPRISE)rC   vulnerability_mode	enum_typemappings       r    GetWorkloadVulnerabilityScanningr    sa    t%FM  "RRss  2266' 
#	$$r   c                 :    d}| j                  dt        d|       y)z'Adds --max-surge-update flag to parser.aY  Maximum number of extra (surge) nodes to be created beyond the current size of
the node pool during its update process. Use --max-unavailable-update as well,
if needed, to control the overall surge settings.

To create an extra node each time the node pool is rolling updated, run:

  $ {command} --max-surge-update=1 --max-unavailable-update=0
z--max-surge-updateNr   rd   r8   r   r  s     r   AddMaxSurgeUpdater    s'    ) 	d  r   c                     t        | dd       S )Nmax_surge_updater@   rQ   s    r   GetMaxSurgeUpdater    s    	)4	00r   c                 D    |rd}nd}| j                  dt        d|       y)z-Adds --max-unavailable-update flag to parser.a  Maximum number of nodes that can be simultaneously unavailable during this node
pool's update process. Use --max-surge-update as well, if needed, to control the
overall surge settings.

To update 3 nodes in parallel (1 + 2), but keep at least 4 nodes (6 - 2)
available each time the node pool is rolling updated, run:

  $ {command} --min-nodes=6 --max-surge-update=1 --max-unavailable-update=2
a  Maximum number of nodes that can be simultaneously unavailable during this node
pool's update process. Use --max-surge-update as well, if needed, to control the
overall surge settings.

To modify a node pool with 6 nodes such that, 3 nodes are updated in parallel
(1 + 2), but keep at least 4 nodes (6 - 2) available each time this
node pool is rolling updated, run:

  $ {command} --max-surge-update=1 --max-unavailable-update=2
z--max-unavailable-updateNr  r   re   s      r   AddMaxUnavailableUpdater    s1    	I
I 	 sDy  r   c                     t        | dd       S )Nmax_unavailable_updater@   rQ   s    r   GetMaxUnavailableUpdater    s    	/	66r   c                 2    d}| j                  ddd|       y)z"Adds --respect-pdb flag to parser.zOIndicates whether the node pool rollback should respect pod disruption budget.
z--respect-pdbFrZ   rN  Nr9   r  s     r   AddRespectPodDisruptionBudgetr    s*    ) 		  r   c                     t        | dd       S )Nrespect_pdbr@   rQ   s    r   GetRespectPodDisruptionBudgetr  .  rx   r   c                 \    d}| j                  dt        j                  d      dd|       y)	zhAdds --tag-bindings flag to parser.

  Args:
    parser: The argparse.parser to add the arguments to.
  a$  Tag keys/values directly bound to this resource.

The short name of a tag key or value can have a maximum length of 256
characters. The permitted character set for the short name includes UTF-8
encoded Unicode characters except single quotes, double quotes,
backslashes, and forward slashes.
z--tag-bindingsr   r   TAG_BINDINGT)r   r   r8  r8   Nr   r  s     r   AddTagBindingsr  2  s8    ) 	!,  r   c                 $    t        | dd      xs i S )zParses and validates the value of the --tag-bindings flag.

  Args:
    args: Arguments parsed from the command.

  Returns:
    The tags object as a dictionary.
  tag_bindingsNr@   rQ   s    r   GetTagBindingsr  I  s     
~t	,	22r   )T)F)cluster)FF)__doc__
__future__r   r   r   r  .googlecloudsdk.api_lib.container.gkemulticloudr   r  googlecloudsdk.callioper   2googlecloudsdk.command_lib.container.gkemulticloudr   #googlecloudsdk.command_lib.projectsrD  $googlecloudsdk.command_lib.util.apisr	   googlecloudsdk.corer
   r   r   r"   r)   ChoiceEnumMapperr  r  EffectValueValuesEnumr  r  r%   r   r  r  r)  rw  rx  rn  rv  rm  -GoogleCloudGkemulticloudV1BinaryAuthorizationEvaluationModeValueValuesEnumr  r=   rE   rG   rJ   rN   rR   rX   r]   r`   rg   rj   rn   rq   rt   rw   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r$  r.  r3  r6  r9  r;  r>  rA  rF  rL  rO  rQ  rW  r_  rc  ra  rb  ri  rq  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )r  s   0r   <module>r     sb   B &  '  K / H D : *+!! 7I66H DDZZ=  A 188II(A(I(IJ(I1|A(IJK 
 P  $$i&8&89  NN"  #=)"<"< H NNll9# 	.	.*	 .20,2	#-. **28(/ 	+;,9=2*,
:6
:
(80!*	6	67t
6+-2(@3"$05
 7<K\,^.
.	 % 1<7,.	3S( Ks   (J