
    F                       S r SSKrSSKrSSKrSSKJr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	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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K$J%r%  SSK&J'r'  SSK(r(Sr)Sr*\+" 1 Sk5      r,      SCS jr-S r.S r/SDS jr0SDS jr1SDS jr2S r3     SES  jr4S! r5S" r6S# r7S$ r8S% r9S& r:S' r;S( r<S) r=   SFS* jr>S+ r?S, r@S- rA  SGS. jrBS/ rCS0 rDS1 rES2 rFS3 rGS4 rHS5 rIS6 rJ\"R                  R                  R                  R                  5       rMS7\M S83rOS9 rPS: rQS; rRS< rSS= rTS> rU " S? S@5      rV " SA SB\W5      rXg)Hz1Utilities for building the dataproc clusters CLI.    N)DictList)encoding)utils)compute_helpers)	constants)
exceptions)storage_helpers)util)actions)arg_parsers)flags)resource_args)	arg_utils)labels_util)log)
properties)yaml)
console_io)timeszgoog-dataproc-)hyperdisk-balancedhyperdisk-extremehyperdisk-mlhyperdisk-throughput>   iopssizetype
throughputc                    [         R                  " U 5        [        R                  " U SS9  [        R                  " XS9  [        R
                  " U 5        U R                  SS9nUR                  SS9n	[        R                  " U	5        U	R                  S[        R                  " S	S
9SSSSS9  U	R                  S[        R                  " S	S
9SSSSS9  U R                  SS9n
U
R                  SSSS9  U
R                  SS9nUR                  S[        SS9  UR                  SS9nUR                  S[        SS9  UR                  S[        SSSS9  UR                  S S!/ S"QS#S$S%9  UR                  SS9nUR                  S&[        R                  " S&S'S(9[        SS)S*9  UR                  S+[        S,S9  U R                  SS9nUR                  S-S.S9  UR                  S/S0S1[!        5       S[        R"                  " 5       S29  U R                  SS9nUR                  S3S4S9  UR                  S5S6S1[!        5       [        R"                  " 5       S79  U R                  S8S9[        S:9  [$        R&                  " U S;S<S=9  U R                  S>[        S?S9  U R                  S@[        SAS9  U R                  SBSCS1[!        5       [        R"                  " 5       S79  U R                  SDS!/ SEQSFSG9  U R                  SHSISJSK/SLSG9  U R)                  5       nUR                  SMSNSOSP9  UR                  SQSRSSSP9  U R                  STSUS9  U R                  SVSWS9  U	R                  SS9nUR                  SXSYS9  UR                  SZS[S9  U R                  S\[        S]S9  U R                  S^[        S_S9  U R                  SS9nUR                  S`[        S[        R                  " S`SaS(9SbSc9  UR                  Sd[        SeS9  U R                  SfSgS9  U R                  ShSiS9  U R                  SjSkS9  U R                  Sl[        R*                  " S	S
9SmSnSo9  U R                  Sp[        R,                  " 5       SqSrSsSt9  U R                  Su[        R.                  " Sv Sw[        R0                  " S	Sx5      Sy9SzS9  U R                  S{[        R                  " 5       [        R2                  0 S|S}S~9  U	R                  SSS9  U	R                  S[        R*                  " S	S
9SSR5                  SR7                  [8        R:                  5      SR7                  [8        R<                  5      [>        R@                  S9So9  U(       a  [C        X5        O[E        X5        U R)                  5       nUR                  SSSS9  UR                  SSSS9  U R                  S/ SQSS9  SnU R                  SUS9  U R                  SUS9  U R                  SS9nUR                  SUS[        R                  " SSS(9S9  UR                  SUS9  SnU R                  SU[        S:9  U R                  SU[        S:9  U R                  SU[        SS9  SnU R                  SU[        S:9  U R                  SU[        S:9  U R                  SU[        SS9  SnU R                  SU[G        5       SS9  U R                  SU[G        5       SS9  U R                  SU[G        5       SS9  U(       ap  [        RH                  " U 5        U R                  SUS9  U R                  S[        SS9  U R                  SSS9  U R                  S[        SS9  U R                  SSS9  U R                  SS[        RJ                  " SSS9S9  U R                  SSS9  U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  U(       d  U R                  SSSS9  U R                  SS9nUR                  S[        RJ                  " SSS9S9  U(       d  U(       a@  UR                  SS9nUR                  SSS9  UR                  SSS9  UR                  SSSS9  U R                  SSS[L        S9  U R                  5       n[        RN                  " USS9  U(       Ga  U R)                  5       nUR                  S[        R,                  " 5       SSS9  UR                  S[        R,                  " 5       SS9  U R)                  5       nUR                  S[        R,                  " 5       SSS9  UR                  S[        RP                  RR                  SSS9  UR                  S[        R,                  " 5       SS9  UR                  S[        RP                  RR                  SS9  U R                  S[        R,                  " 5       SS9  U R)                  5       nUR                  S[        R,                  " 5       SS9  UR                  S[        RP                  RR                  SS9  [U        U 5        U(       d  [W        U 5        [        RX                  " X5        [[        X5        U(       d  []        X5        [_        U	SSS9  U(       aF  UR                  S[        RJ                  " SSS9S9nUR                  SSSS9  UR                  SSSS9  gg)a  Register flags for creating a dataproc cluster.

Args:
  parser: The argparse.ArgParser to configure with dataproc cluster arguments.
  dataproc: Dataproc object that contains client, messages, and resources.
  beta: whether or not this is a beta command (may affect flag visibility)
  alpha: whether or not this is a alpha command (may affect flag visibility)
  include_deprecated: whether deprecated flags should be included
  include_ttl_config: whether to include Scheduled Delete and Stop (TTL) args
  include_gke_platform_args: whether to include GKE-based cluster args
  include_driver_pool_args: whether to include driver pool cluster args
35m)default)short_flagsTmutexz6    Compute Engine options for Dataproc clusters.
    helpz
--metadata   )
min_lengthappendNzTMetadata to be made available to the guest operating system running on the instancesz	KEY=VALUE)r   actionr!   r&   metavarz--resource-manager-tagszcSpecifies a list of resource manager tags to apply to each cluster node (master and worker nodes). z--single-node
store_truez      Create a single node cluster.

      A single node cluster has all master and worker components.
      It cannot have any separate worker nodes. If this flag is not
      specified, a cluster with separate workers is created.
      r*   r&   zMulti-node cluster flagsz--num-workerszHThe number of worker nodes in the cluster. Defaults to server-specified.r   r&   z--min-num-workerszTMinimum number of primary worker nodes to provision for cluster creation to succeed.z--min-worker-fractionz[0-1]zMinimum fraction of worker nodes required to create the cluster. If it is not met, cluster creation will fail. Must be a decimal value between 0 and 1. The number of required workers will be calculated by ceil(min-worker-fraction * num_workers).)r   hiddenr+   r&   z--secondary-worker-typeTYPE)preemptiblenon-preemptiblespotr1   z'The type of the secondary worker group.)r+   choicesr!   r&   z--num-preemptible-workerszcThe `--num-preemptible-workers` flag is deprecated. Use the `--num-secondary-workers` flag instead.warnz6The number of preemptible worker nodes in the cluster.r*   r   r/   r&   z--num-secondary-workersz4The number of secondary worker nodes in the cluster.z--master-machine-typezHThe type of machine to use for the master. Defaults to server-specified.z--master-machine-typeszTypes of machines with optional rank for master nodes to use. Defaults to server-specified.eg. --master-machine-types="type=e2-standard-8,type=t2d-standard-8,rank=0"z4type=MACHINE_TYPE[,type=MACHINE_TYPE...][,rank=RANK])r&   r+   r   r/   r*   z--worker-machine-typezMThe type of machine to use for primary workers. Defaults to server-specified.z--worker-machine-typesa  [Machine types](https://cloud.google.com/dataproc/docs/concepts/compute/supported-machine-types) for primary worker nodes to use with optional rank. A lower rank number is given higher preference. Based on availablilty, Dataproc tries to create primary worker VMs using the worker machine type with the lowest rank, and then tries to use machine types with higher ranks as necessary. Machine types with the same rank are given the same preference. Example use: --worker-machine-types="type=e2-standard-8,type=n2-standard-8,rank=0". For more information, see [Dataproc Flexible VMs](https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/flexible-vms))r&   r+   r   r*   z--min-secondary-worker-fractiona,  Minimum fraction of secondary worker nodes required to create the cluster. If it is not met, cluster creation will fail. Must be a decimal value between 0 and 1. The number of required secondary workers is calculated by ceil(min-secondary-worker-fraction * num_secondary_workers). Defaults to 0.0001.)r&   r   clusterz	--kms-key)namez)--secondary-worker-standard-capacity-basea{  This flag sets the base number of Standard VMs to use for [secondary workers](https://cloud.google.com/dataproc/docs/concepts/compute/secondary-vms#preemptible_and_non-preemptible_secondary_workers). Dataproc will create only standard VMs until it reaches this number, then it will mix Spot and Standard VMs according to ``SECONDARY_WORKER_STANDARD_CAPACITY_PERCENT_ABOVE_BASE''.z7--secondary-worker-standard-capacity-percent-above-basea  When combining Standard and Spot VMs for [secondary-workers](https://cloud.google.com/dataproc/docs/concepts/compute/secondary-vms#preemptible_and_non-preemptible_secondary_workers) once the number of Standard VMs specified by ``SECONDARY_WORKER_STANDARD_CAPACITY_BASE'' has been used, this flag specifies the percentage of the total number of additional Standard VMs secondary workers will use. Spot VMs will be used for the remaining percentage.z --secondary-worker-machine-typeszTypes of machines with optional rank for secondary workers to use. Defaults to server-specified.eg. --secondary-worker-machine-types="type=e2-standard-8,type=t2d-standard-8,rank=0"z--cluster-type)standardsingle-node
zero-scalezThe type of cluster.)r+   r4   r&   z--tierTIERpremiumr:   zCluster tierz--imageIMAGEzThe custom image used to create the cluster. It can be the image name, the image URI, or the image family URI, which selects the latest image from the family.)r+   r&   z--image-versionVERSIONzIThe image version to use for the cluster. Defaults to the latest version.z--bucketz      The Google Cloud Storage bucket to use by default to stage job
      dependencies, miscellaneous config files, and job driver console output
      when using this cluster.
      z--temp-bucketz      The Google Cloud Storage bucket to use by default to store
      ephemeral cluster and jobs data, such as Spark and MapReduce history files.
      z	--networkz      The Compute Engine network that the VM instances of the cluster will be
      part of. This is mutually exclusive with --subnet. If neither is
      specified, this defaults to the "default" network.
      z--subnetzs      Specifies the subnet that the cluster will be part of. This is mutally
      exclusive with --network.
      z--num-worker-local-ssdsz?The number of local SSDs to attach to each worker in a cluster.z--num-master-local-ssdsz>The number of local SSDs to attach to the master in a cluster.z#--num-preemptible-worker-local-ssdszwThe `--num-preemptible-worker-local-ssds` flag is deprecated. Use the `--num-secondary-worker-local-ssds` flag instead.z\      The number of local SSDs to attach to each secondary worker in
      a cluster.
      )r   r/   r*   r&   z!--num-secondary-worker-local-ssdsz^      The number of local SSDs to attach to each preemptible worker in
      a cluster.
      z--master-local-ssd-interfacezR      Interface to use to attach local SSDs to master node(s) in a cluster.
      z--worker-local-ssd-interfacezO      Interface to use to attach local SSDs to each worker in a cluster.
      z&--secondary-worker-local-ssd-interfacez_      Interface to use to attach local SSDs to each secondary worker
      in a cluster.
      z--initialization-actionsCLOUD_STORAGE_URIzVA list of Google Cloud Storage URIs of executables to run on each node in the cluster.r   r+   r&   z--initialization-action-timeoutTIMEOUT10mzuThe maximum duration of each initialization action. See $ gcloud topic datetimes for information on duration formats.)r   r+   r!   r&   z--num-mastersc                     [        U 5      S;   $ )N)r'      )int)ns    3lib/googlecloudsdk/command_lib/dataproc/clusters.py<lambda>#ArgsForClusterRef.<locals>.<lambda>  s    CFf$    z?Number of masters must be 1 (Standard) or 3 (High Availability)rF   parserz      The number of master nodes in the cluster.

      Number of Masters | Cluster Mode
      --- | ---
      1 | Standard
      3 | High Availability
      z--propertieszPREFIX:PROPERTY=VALUEa  Specifies configuration properties for installed packages, such as Hadoop
and Spark.

Properties are mapped to configuration files by specifying a prefix, such as
"core:io.serializations". The following are supported prefixes and their
mappings:

Prefix | File | Purpose of file
--- | --- | ---
capacity-scheduler | capacity-scheduler.xml | Hadoop YARN Capacity Scheduler configuration
core | core-site.xml | Hadoop general configuration
distcp | distcp-default.xml | Hadoop Distributed Copy configuration
hadoop-env | hadoop-env.sh | Hadoop specific environment variables
hdfs | hdfs-site.xml | Hadoop HDFS configuration
hive | hive-site.xml | Hive configuration
mapred | mapred-site.xml | Hadoop MapReduce configuration
mapred-env | mapred-env.sh | Hadoop MapReduce specific environment variables
pig | pig.properties | Pig configuration
spark | spark-defaults.conf | Spark configuration
spark-env | spark-env.sh | Spark specific environment variables
yarn | yarn-site.xml | Hadoop YARN configuration
yarn-env | yarn-env.sh | Hadoop YARN specific environment variables

See https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/cluster-properties
for more information.

)r   r*   r!   r+   r&   z--service-accountz<The Google Cloud IAM service account to be authenticated as.z--scopesSCOPEad  Specifies scopes for the node instances. Multiple SCOPEs can be specified,
separated by commas.
Examples:

  $ {{command}} example-cluster --scopes https://www.googleapis.com/auth/bigtable.admin

  $ {{command}} example-cluster --scopes sqlservice,bigquery

The following *minimum scopes* are necessary for the cluster to function
properly and are always added, even if not explicitly specified:

  {minimum_scopes}

If the `--scopes` flag is not specified, the following *default scopes*
are also included:

  {additional_scopes}

If you want to enable all scopes use the 'cloud-platform' scope.

{scopes_help}
z
  )minimum_scopesadditional_scopesscopes_helpz--no-addressa        If provided, the instances in the cluster will not be assigned external
      IP addresses.

      If omitted, then the Dataproc service will apply a default policy to determine if each instance in the cluster gets an external IP address or not.

      Note: Dataproc VMs need access to the Dataproc API. This can be achieved
      without external IP addresses using Private Google Access
      (https://cloud.google.com/compute/docs/private-google-access).
      z--public-ip-addressa        If provided, cluster instances are assigned external IP addresses.

      If omitted, the Dataproc service applies a default policy to determine
      whether or not each instance in the cluster gets an external IP address.

      Note: Dataproc VMs need access to the Dataproc API. This can be achieved
      without external IP addresses using Private Google Access
      (https://cloud.google.com/compute/docs/private-google-access).
      z!--private-ipv6-google-access-type)inherit-subnetworkoutboundbidirectionalzA      The private IPv6 Google access type for the cluster.
      )r4   r&   zj      The type of the boot disk. The value must be `pd-balanced`,
      `pd-ssd`, or `pd-standard`.
      z--master-boot-disk-typez--worker-boot-disk-typez#--preemptible-worker-boot-disk-typezwThe `--preemptible-worker-boot-disk-type` flag is deprecated. Use the `--secondary-worker-boot-disk-type` flag instead.)r&   r/   r*   z!--secondary-worker-boot-disk-typea@        Indicates the [IOPS](https://cloud.google.com/compute/docs/disks/hyperdisks#iops)
      to provision for the disk. This sets the limit for disk I/O operations per
      second. This is only supported if the bootdisk type is
      [hyperdisk-balanced](https://cloud.google.com/compute/docs/disks/hyperdisks).
      z#--master-boot-disk-provisioned-iopsz#--worker-boot-disk-provisioned-iopsz---secondary-worker-boot-disk-provisioned-iops)r&   r   r/   aJ        Indicates the [throughput](https://cloud.google.com/compute/docs/disks/hyperdisks#throughput)
      to provision for the disk. This sets the limit for throughput in MiB per
      second. This is only supported if the bootdisk type is
      [hyperdisk-balanced](https://cloud.google.com/compute/docs/disks/hyperdisks).
      z)--master-boot-disk-provisioned-throughputz)--worker-boot-disk-provisioned-throughputz3--secondary-worker-boot-disk-provisioned-throughputa        A list of disk configurations to attach to nodes.
      Each configuration should be a string with the format:
      type=<disk_type>,(optional)size=<size>,(optional)iops=<iops>,
      (optional)throughput=<throughput>, separated by semicolon.

      Allowed disk types are: hyperdisk-balanced, hyperdisk-extreme,
      hyperdisk-ml, hyperdisk-throughput.

      Example:
      type=hyperdisk-balanced,iops=1000,throughput=500,size=100G;type=hyperdisk-throughput,size=2000G'
      z--master-attached-disksz--worker-attached-disksz!--secondary-worker-attached-disksz--driver-pool-boot-disk-typez--driver-pool-sizez$The size of the cluster driver pool.z--driver-pool-machine-typez[The type of machine to use for the cluster driver pool nodes. Defaults to server-specified.z--num-driver-pool-local-ssdszU        The number of local SSDs to attach to each cluster driver pool node.
        z!--driver-pool-local-ssd-interfacezV        Interface to use to attach local SSDs to cluster driver pool node(s).
        z--enable-component-gatewayzaEnable access to the web UIs of selected components on the cluster through the component gateway.z;Component gateway is only supported in the default universer!   universe_helpz--node-groupz        The name of the sole-tenant node group to create the cluster on. Can be
        a short name ("node-group-name") or in the format
        "projects/{project-id}/zones/{zone}/nodeGroups/{node-group-name}".
        z--shielded-secure-bootzF        The cluster's VMs will boot with secure boot enabled.
        z--shielded-vtpmz        The cluster's VMs will boot with the TPM (Trusted Platform Module) enabled.
        A TPM is a hardware module that can be used for different security
        operations, such as remote attestation, encryption, and sealing of keys.
        z--shielded-integrity-monitoringaH          Enables monitoring and attestation of the boot integrity of the
        cluster's VMs. vTPM (virtual Trusted Platform Module) must also be
        enabled. A TPM is a hardware module that can be used for different
        security operations, such as remote attestation, encryption, and sealing
        of keys.
        z--confidential-computeaG          Enables Confidential VM. See https://cloud.google.com/compute/confidential-vm/docs for more information.
        Note that Confidential VM can only be enabled when the machine types
        are N2D (https://cloud.google.com/compute/docs/machine-types#n2d_machine_types)
        and the image is SEV Compatible.
        z--dataproc-metastorez          Specify the name of a Dataproc Metastore service to be used as an
          external metastore in the format:
          "projects/{project-id}/locations/{region}/services/{service-name}".
          zR          Dataproc Metastore is only supported in the default universe.
          z
BQMS flagsz--bigquery-metastore-project-idzf      The project ID of the  BigQuery metastore database to be used as an external metastore.
        z&--bigquery-metastore-database-locationz`      Location of the  BigQuery metastore database to be used as an external metastore.
        z--bigquery-metastorezA        Indicates that BigQuery metastore is to be used.
        z--enable-node-groupszp      Create cluster nodes using Dataproc NodeGroups. All the required VMs will be created using GCE MIG.
      )r/   r&   r   v1)api_versionz
--max-idlez          The duration after the last job completes to autto-delete the
          cluster, such as "2h" or "1d".
          See $ gcloud topic datetimes for information on duration formats.
          )r   r/   r&   z--delete-max-idlez          The duration after the last job completes to auto-delete the
          cluster, such as "2h" or "1d".
          See $ gcloud topic datetimes for information on duration formats.
          z	--max-agez          The lifespan of the cluster, with auto-deletion upon completion,
          such as "2h" or "1d".
          See $ gcloud topic datetimes for information on duration formats.
          z--expiration-timez          The time when the cluster will be auto-deleted, such as
          "2017-08-29T18:52:51.142Z." See $ gcloud topic datetimes for
          information on time formats.
          z--delete-max-agez--delete-expiration-timez          The time when the cluster will be auto-deleted, such as
          "2017-08-29T18:52:51.142Z."
          See $ gcloud topic datetimes for information on time formats.
          z--stop-max-idlez          The duration after the last job completes to auto-stop the cluster,
          such as "2h" or "1d".
          See $ gcloud topic datetimes for information on duration formats.
          z--stop-max-agez          The lifespan of the cluster, with auto-stop upon completion,
          such as "2h" or "1d".
          See $ gcloud topic datetimes for information on duration formats.
          z--stop-expiration-timez          The time when the cluster will be auto-stopped, such as
          "2017-08-29T18:52:51.142Z."
          See $ gcloud topic datetimes for information on time formats.
          z+Specifies the reservation for the instance.z)The type of reservation for the instance.)
group_textaffinity_texta                      Options for creating a GKE-based Dataproc cluster. Specifying any of these
                    will indicate that this cluster is intended to be a GKE-based cluster.
                    These options are mutually exclusive with GCE-based options.
                    zs                          GKE-based clusters are only supported in the default universe.
                          )r/   r&   z--gke-clusterz            Required for GKE-based clusters. Specify the name of the GKE cluster to
            deploy this GKE-based Dataproc cluster to. This should be the short name
            and not the full path name.
            z--gke-cluster-namespacez            Optional. Specify the name of the namespace to deploy Dataproc system
            components into. This namespace does not need to already exist.
            )0r   AddCreateLabelsFlagsr   AddTimeoutFlagAddZoneAndExcludedZonesFlagsAddComponentFlagadd_argument_groupinstances_flagsAddTagsArgsadd_argumentr   ArgDictrG   floatr   DeprecationActionArgMultiValueDictFlattenActionkms_resource_argsAddKmsKeyResourceArgadd_mutually_exclusive_groupArgListDurationCustomFunctionValidator
BoundedIntUpdateActionformatjoinr   MINIMUM_SCOPE_URISADDITIONAL_DEFAULT_SCOPE_URISr   SCOPES_HELP_AddDiskArgsDeprecated_AddDiskArgsDiskConfigParserAddDriverPoolIdUniverseHelpTextbool)AddAutoscalingPolicyResourceArgForClusterDatetimeParseAddKerberosGroupAddSecureMultiTenancyGroupAddMinCpuPlatformArgs_AddAcceleratorArgs_AddMetricConfigArgsAddReservationAffinityGroup) rN   dataprocbetaalphainclude_deprecatedinclude_ttl_configinclude_gke_platform_argsinclude_driver_pool_argsplatform_groupgce_platform_group
node_groupworker_groupmin_workersnum_secondary_workersmaster_machine_type_groupworker_machine_type_groupimage_parser	netparsersecondary_worker_local_ssdsip_address_parserboot_disk_type_detailed_helpsecondary_worker_boot_disk_type(boot_disk_provisioned_iops_detailed_help.boot_disk_provisioned_throughput_detailed_helpattached_disk_detailed_helpmetastore_group
bqms_groupautoscaling_groupauto_delete_idle_groupauto_delete_groupauto_stop_groupgke_based_cluster_groups                                    rI   ArgsForClusterRefr   9   s   , ""6*vu-$$VL ,,4,8.%88 ?8 	 01!!!,%  " 
 !!!,.  " 
 ((t(4*
  
 ..4N.O,	   //d/;+"	   D   84   '999E$$!&&
%@ C %  $$A %  %77d7C(( )  ((W E&&( )  %77d7C(( )  ((
e E&&(# ) ( 	'9   
 ((M1H	  
 	?'	   	(a E&&(  
 	7!	   	*%	   446,6	   	   	
   	
   !33$3?)
   
   	L  
 	K  
 !' 9 9 9 E**+&&
/J
 +   **)
 +  	$
   	$
   	.
   	 !,!<   	'!J  	 	..
$
K''1-

    	 %%%  "F !!I "  !!!,, FY%A%AB"KK55 &11  5 " !F 6<299;   	
 !    	
 !  	)A
  "
 	&B   	&B   %+$=$=D$=$I!!..+'&&
/J	 /  "..)0L / .
* 	+3  
 	+3  
 	53	  4
0 	19  
 	19  
 	;9	  !
 	&	   	&	   	)&	   	&!
&-I   3  
 $-   &   +   	"''8 L   	   	   	   	'  
 

   	 --D-9/''
	   d 333FJ)   0      	
    //111T #@@B''!!#	 ( 	 ''!!# (  ;;=""!!#	 # 	 ""!!''	 # 	 ""!!# #  """!!'' #  !!#   99;O  !!# !     !!'' !  6	v&f?f7	*>? ,??))
	
 @  (( )  ((! ) / rL   c                     U R                   R                  R                  n[        UR	                  5       5       Vs/ s H!  nUS:w  d  M  [
        R                  " U5      PM#     sn$ s  snf )NMETRIC_SOURCE_UNSPECIFIED)messagesMetricMetricSourceValueValuesEnumsortednamesr   ChoiceToEnumName)r   metric_sources_enumrH   s      rI   _GetValidMetricSourceChoicesr     sf     ))00LL )//12
2!	
)	) $i  #2
  
s   
A'
A'c           
      J   SnU R                  5       nUR                  SS[        R                  " [        R
                  [        U5      S9SSS9  UR                  5       nUR                  S[        R                  " 5       [        R                  S	US
9  UR                  SSS9  g)z5Adds DataprocMetricConfig related args to the parser.a  
  List of metrics that override the default metrics enabled for the metric
  sources. Any of the
  [available OSS metrics](https://cloud.google.com/dataproc/docs/guides/monitoring#available_oss_metrics)
  and all Spark metrics, can be listed for collection as a metric override.
  Override metric values are case sensitive, and must be provided, if
  appropriate, in CamelCase format, for example:

  *sparkHistoryServer:JVM:Memory:NonHeapMemoryUsage.committed*
  *hiveserver2:JVM:Memory:NonHeapMemoryUsage.used*

  Only the specified overridden metrics will be collected from a given metric
  source. For example, if one or more *spark:executive* metrics are listed as
  metric overrides, other *SPARK* metrics will not be collected. The collection
  of default OSS metrics from other metric sources is unaffected. For example,
  if both *SPARK* and *YARN* metric sources are enabled, and overrides are
  provided for Spark metrics only, all default YARN metrics will be collected.

  The source of the specified metric override must be enabled. For example,
  if one or more *spark:driver* metrics are provided as metric overrides,
  the spark metric source must be enabled (*--metric-sources=spark*).
  z--metric-sourcesMETRIC_SOURCE)r4   TzSpecifies a list of cluster [Metric Sources](https://cloud.google.com/dataproc/docs/guides/monitoring#available_oss_metrics) to collect custom metrics.)r+   r   requiredr&   z--metric-overridesz#METRIC_SOURCE:INSTANCE:GROUP:METRIC)r   r*   r+   r&   z--metric-overrides-filez      Path to a file containing list of Metrics that override the default metrics enabled for the metric sources.
      The path can be a Cloud Storage URL (example: `gs://path/to/file`) or a local file system path.
      r%   N)		add_grouprc   r   rl   r   r   r   rk   rp   )rN   r   metric_overrides_detailed_helpmetric_config_groupmetric_overrides_groups        rI   r   r     s    $ . ((*""

$
$.x8 ( #  /KKM%% %%3) &  %%
 & rL   c                    SnUS-  nU R                  S[        R                  " [        [        S.S9SUR                  SS9S	9  U R                  S
[        R                  " [        [        S.S9SUR                  SS9S	9  U R                  SS9nUR                  S[        R                  " [        [        S.S9SUR                  SS9S	9  UR                  S[        R                  " [        [        S.S9SUR                  SS9S[        R                  " SSS9S9  U(       a=  U R                  S[        R                  " [        [        S.S9SUR                  SS9S	9  gg)z,Adds accelerator related args to the parser.z[      Attaches accelerators, such as GPUs, to the {instance_type}
      instance(s).
      a>  
      *type*::: The specific type of accelerator to attach to the instances,
      such as `nvidia-tesla-t4` for NVIDIA T4. Use `gcloud compute
      accelerator-types list` to display available accelerator types.

      *count*::: The number of accelerators to attach to each instance. The default value is 1.
      z--master-accelerator)r   count)specztype=TYPE,[count=COUNT]master)instance_typerB   z--worker-acceleratorworkerTr#   z--secondary-worker-acceleratorsecondary-workerz --preemptible-worker-acceleratorzpreemptible-workerzqThe `--preemptible-worker-accelerator` flag is deprecated. Use the `--secondary-worker-accelerator` flag instead.r5   )r   r+   r&   r/   r*   z--driver-pool-acceleratorzdriver-poolN)	rc   r   rd   strrG   rq   r`   r   rf   )rN   r   accelerator_help_fmtsecondary_worker_accelerators       rI   r   r     s   
  
 
 	 (&&X&>  
 	 (&&X&>  
 "(!:!:!:!F++& (&&5G&H , 
 ++( (&&5I&J&&
,G , & 
#  
 *!((}(E  
 rL   c                    SnU R                  S[        R                  " SS9US9  U R                  S[        R                  " SS9US9  U R                  SS9nUR                  S	[        R                  " SS9US[        R
                  " S	S
S9S9  UR                  S[        R                  " SS9US9  U(       a$  U R                  S[        R                  " SS9US9  gg)z%Adds disk related args to the parser.aQ        The size of the boot disk. The value must be a
      whole number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      `10GB` will produce a 10 gigabyte disk. The minimum boot disk size is 10 GB. Boot disk size must be a multiple of 1 GB.
      --master-boot-disk-size10GBlower_boundr.   --worker-boot-disk-sizeTr#   #--preemptible-worker-boot-disk-sizewThe `--preemptible-worker-boot-disk-size` flag is deprecated. Use the `--secondary-worker-boot-disk-size` flag instead.r5   r   r&   r/   r*   !--secondary-worker-boot-disk-size--driver-pool-boot-disk-sizeN)rc   r   
BinarySizer`   r   rf   )rN   r   boot_disk_size_detailed_helpsecondary_worker_boot_disk_sizes       rI   rw   rw   W  s   "
 	!!f5'  
 	!!f5'  
 %+$=$=D$=$I!!..+!!f5'&&
/J /  "..)!!f5' / 
 
&##7)   rL   c                    U R                  5       nU R                  5       nUR                  S[        R                  " SSS9[        SSS9  UR                  S[        R                  " SSS9[        SS	S9  S
nUR                  S[
        R                  " SS9US9  UR                  S[
        R                  " SS9US9  U R                  SS9nUR                  S[
        R                  " SS9US[        R                  " SSS9S9  UR                  S[
        R                  " SS9US9  U(       a$  U R                  S[
        R                  " SS9US9  gg)z0Adds deprecated disk related args to the parser.z--master-boot-disk-size-gbznThe `--master-boot-disk-size-gb` flag is deprecated. Use `--master-boot-disk-size` flag with "GB" after value.r5   Tz9Use `--master-boot-disk-size` flag with "GB" after value.r7   z--worker-boot-disk-size-gbznThe `--worker-boot-disk-size-gb` flag is deprecated. Use `--worker-boot-disk-size` flag with "GB" after value.z9Use `--worker-boot-disk-size` flag with "GB" after value.a_        The size of the boot disk. The value must be a
      whole number followed by a size unit of ``KB'' for kilobyte, ``MB''
      for megabyte, ``GB'' for gigabyte, or ``TB'' for terabyte. For example,
      ``10GB'' will produce a 10 gigabyte disk. The minimum size a boot disk
      can have is 10 GB. Disk size must be a multiple of 1 GB.
      r   r   r   r.   r   r#   r   r   r   r   r   N)rk   rc   r   rf   rG   r   r   r`   )rN   r   master_boot_disk_sizeworker_boot_disk_sizer   r   s         rI   rv   rv     s    ==? ==? $$"&&
&J F %  $$"&&
&J F % "
 $$!!f5' % 
 $$!!f5' % 
 %+$=$=D$=$I!!..+!!f5'&&
/J /  "..)!!f5' / 
 
&##7)   rL   c                     g)z9Register beta-only flags for creating a Dataproc cluster.N rM   s    rI   BetaArgsForClusterRefr     s    rL   c	                 .   Sn	Sn
SnSnU R                   (       a`  SU R                   R                  5       ;   a  U R                   S   n	O[        R                  " S5      eU R                   R	                  SS5      nU R
                  (       a`  SU R
                  R                  5       ;   a  U R
                  S   n
O[        R                  " S5      eU R
                  R	                  SS5      n[        U R                  U R                  5      nU(       aB  SUR                  5       ;   a  US   nO[        R                  " S5      eUR	                  SS5      nU R                  (       a6  U R                  S:  d  U R                  S:  a  [        R                  " S	5      e[        U S
5      (       aq  U R                  (       a`  SU R                  R                  5       ;   a  U R                  S   nO[        R                  " S5      eU R                  R	                  SS5      nU R                  =(       a    UR                  U R                  SU0SS9nU R                  =(       a    UR                  U R                  SU0SS9nU R                  =(       aJ    UR                  U R                  U[         R"                  R$                  R&                  R(                  S.SS9n[*        R,                  " U R.                  5      S-   nU R0                  =(       d    /  Vs/ s H  nUR2                  R5                  UUS9PM     nnU =R6                  U R.                  [9        U5      -  -  sl        [:        R<                  " U R>                  5      nUR2                  RA                  U RB                  S9nU(       a  U RD                  nOSnU RF                  (       a   [H        RJ                  " U RF                  5      nU(       a  U RL                  nOSnU RN                  (       a   [H        RJ                  " U RN                  5      n[H        RJ                  " [        U RP                  U RR                  5      5      nSn[        U S5      (       a1  U RT                  (       a   [H        RJ                  " U RT                  5      nU RV                  (       d  U RX                  S:X  a  SU R                   [Z        R\                  '   U R^                  b>  [a        U R^                  5      Rc                  5       U R                   [Z        Rd                  '   U R                   (       aC  [f        Rh                  " U R                   UR2                  R@                  Rj                  SS9Ul        U Rl                  (       aX  UR2                  R@                  nURn                  Rq                  [s        [u        URv                  U Rl                  5      5      5        UR2                  Ry                  U=(       a    UR{                  5       U=(       a    UR{                  5       [}        XR~                  5      U R                  U[         R"                  R$                  R                  R)                  5       U R                  S9nU R                  (       a  U R                  (       + UlD        U R                  (       a  U R                  UlD        [        X5      n U UlG        U R                  (       a  U R                  UlH        U R                  (       a  [        R                  " 5       n!U R                   H"  n"U"R                  5        H  u  n#n$U$U!U#'   M     M$     [f        Rh                  " U!UR2                  Rx                  R                  5      UlN        U R                  (       a  [        R                  " 5       n%U R                   H"  n"U"R                  5        H  u  n#n$U$U%U#'   M     M$     [f        Rh                  " U%UR2                  Rx                  R                  5      UlO        / n&U	(       a)  U&R                  UR2                  R                  U	WS95        / n'U
(       a)  U'R                  UR2                  R                  U
WS95        / n(U(       a)  U(R                  UR2                  R                  UWS95        / n)U(       a)  U)R                  UR2                  R                  UWS95        UR2                  R                  U R                  U R                  [        XR                  5      [        XR                  5      UUR2                  R                  U R                  U=(       a    UR{                  5       U R                  U&[        UU R                  UU R                  U R                  SU R                  U R                  U R                  5	      U R                  [        USU R                  S5      S9UR2                  R                  U RX                  U R                  U=(       a    UR{                  5       U R                  U'[        UU R                  UU R                  U R                  SU R                  U R                  U R                  5	      U R                  [        USU R                  S5      S 9UUS!9	n*U R                  (       a2  UR2                  R                  U R                  S"9U*R                  ls        U R                  (       d#  U R                  (       d  U R                  (       Ga  UR2                  R                  5       U*lx        U R                  (       a%  [        XR                  5      U*R                  lz        OUR2                  R                  5       n+U R                  (       a  U R                  U+l|        OSU+l|        U R                  (       aR  U R                  U+l}        U R                  R                  R                  5       n,U,(       a  U,GR                  5       U+l        U+U*R                  lz        U(       Gds  [Z        GR                  U R                   ;   aL  U GR                  (       d:  U GR                  (       d(  [        R                  " S#[Z        GR                  -  5      eU GR                  (       d  U GR                  (       a  U*R                  c  UR2                  R                  5       U*lx        U GR                  (       a'  G[        XGR                  5      U*R                  l        OG[        U GR                  5      n-UR2                  GR                  5       n.[f        Rh                  " U-UR2                  GR                  GR                  5      U.l        U.U*R                  l        U GR                  (       aQ  UR2                  GR                  U R                  GR                  R                  5       GR                  5       S$9U*l        U GR                  (       a*  UR2                  GR                  U GR                  S%9Ul        U GR#                  S&5      (       d.  U GR#                  S'5      (       d  U GR#                  S(5      (       aB  UR2                  GR%                  U GR&                  U GR(                  U GR*                  S)9Ul        U(       dA  U GR#                  S*5      (       a*  UR2                  GR/                  U GR0                  S+9Ul        U GR4                  (       a+  UR2                  GR7                  U GR4                  S,9U*l        OhU(       d  U(       aZ  U GR:                  c   U GR<                  c  U GR>                  (       a,  G[A        UU 5      n/UR2                  GR7                  U/S-9U*l        U(       Ga)  UR2                  GRC                  5       n0S.n1U GRD                  b+  [*        R,                  " U GRD                  5      S-   U0l        Sn1U GRH                  b*  G[J        GRL                  " U GRH                  5      U0l        Sn1U GRP                  b+  [*        R,                  " U GRP                  5      S-   U0l        Sn1U GRT                  b+  [*        R,                  " U GRT                  5      S-   U0l        Sn1U GRV                  b*  G[J        GRL                  " U GRV                  5      U0l        Sn1U GRX                  b+  [*        R,                  " U GRX                  5      S-   U0l        Sn1U GRZ                  b+  [*        R,                  " U GRZ                  5      S-   U0l        Sn1U GR^                  b*  G[J        GRL                  " U GR^                  5      U0l        Sn1U GRb                  b+  [*        R,                  " U GRb                  5      S-   U0l        Sn1U1(       a  U0U*l        UR2                  GRi                  5       n2[        U R                  S/5      (       a  U R                  GRj                  R                  5       n3U3(       a  U3GR                  5       U2l        OCS0 H=  n4G[o        U U4GRq                  S1S25      S5      (       d  M)  [        R                  " S35      e   [        U R                  S45      (       a  U R                  GRr                  R                  5       n5U5(       a  U5GR                  5       U2l        OCS5 H=  n4G[o        U U4GRq                  S1S25      S5      (       d  M)  [        R                  " S65      e   U2GRl                  (       d  U2GRt                  (       a  U2U*l        [        U GRx                  U GRz                  5      n6[        U GR|                  U GR~                  5      n7[        U GR                  U GR                  5      n8U6cT  UcQ  U7cN  U8cK  U R                  c>  U GR                  S7:X  d-  U GR                  S8:X  d  U GR                  c  U GR                  b  [        UG[        UU GR                  U GR                  5      U GR                  S95      n9G[        X5      n:UR2                  R                  U6U([        UU7UU8U GR                  S:U GR                  U GR                  U GR                  5	      U R                  G[        XGR                  5      U9U:S;9U*l        G[        U U5      (       Ga+  UR2                  GR                  UR2                  GR                  G[        GR                  " XR2                  GR                  GR                  5      UR2                  GR                  GR                  GR                  /UR2                  R                  U GR                  U=(       a    UR{                  5       U GR                  U)[        UU GR                  UU GR                  U GR                  S<5      U GR                  S=9S>9U GR                  S?9/U*l        U GR                  (       a*  UR2                  GR                  U GR                  S@9U*l        U(       a  U GR                  b  U R                  =(       d    U R&                  n;SAGR                  UU;U GR                  5      n<UR2                  GR                  UR2                  GR                  U<U GR                  SB9SC9U*l        SU*l        SU*l        SU*lr        SU*l        U(       d   U GR                  (       a  G[        U U*U5        U*$ s  snf )Da:  Get dataproc cluster configuration.

Args:
  args: Arguments parsed from argparse.ArgParser.
  dataproc: Dataproc object that contains client, messages, and resources
  project_id: Dataproc project ID
  compute_resources: compute resource for cluster
  beta: use BETA only features
  alpha: use ALPHA only features
  include_deprecated: whether to include deprecated args
  include_ttl_config: whether to include Scheduled Delete(TTL) args
  include_gke_platform_args: whether to include GKE-based cluster args

Returns:
  cluster_config: Dataproc cluster configuration
Nr   z master-accelerator missing type!r   r'   z worker-accelerator missing type!z*secondary-worker-accelerator missing type!r   z---min-worker-fraction must be between 0 and 1driver_pool_acceleratorz%driver-pool-accelerator missing type!projectzcompute.images)params
collectionzcompute.networks)r   regionzcompute.subnetworkss)executableFileexecutionTimeout)imageVersiondriver_pool_boot_disk_sizetrueT)
sort_items)
networkUrisubnetworkUriprivateIpv6GoogleAccessserviceAccountserviceAccountScopeszoneUriautoZoneExcludeZoneUris)acceleratorTypeUriacceleratorCountMasterr   )numInstancesimageUrimachineTypeUriaccelerators
diskConfigminCpuPlatforminstanceFlexibilityPolicyWorkerr   )r   minNumInstancesr   r   r   r   r   r   )	configBucket
tempBucketclusterTypeclusterTiergceClusterConfigmasterConfigworkerConfiginitializationActionssoftwareConfigrequiredRegistrationFractionzIf %s is enabled, either --secure-multi-tenancy-user-mapping or --identity-config-file must be provided with user to service account mappings.)	policyUri)nodeGroupUrishielded_secure_bootshielded_vtpmshielded_integrity_monitoring)enableSecureBoot
enableVtpmenableIntegrityMonitoringconfidential_compute)enableConfidentialCompute)dataprocMetastoreService)bigqueryMetastoreConfigFgce_pd_kms_key)zgce-pd-kms-keyzgce-pd-kms-key-projectzgce-pd-kms-key-locationzgce-pd-kms-key-keyring-_z)--gce-pd-kms-key was not fully specified.kms_key)kms-keykms-projectkms-locationkms-keyringz"--kms-key was not fully specified.r2   r3   r   zSecondary worker)r   r   r   r   preemptibilityr   startupConfigzDriver pool)r   r   r   r   r   r   )labelsrolesnodeGroupConfig)	nodeGroupnodeGroupId)enableHttpPortAccessz'projects/{0}/locations/{1}/clusters/{2})targetGkeClusterclusterNamespace)namespacedGkeDeploymentTarget)master_acceleratorkeysr	   ArgumentErrorgetworker_accelerator_FirstNonNoner   preemptible_worker_acceleratormin_worker_fractionhasattrr   imager~   networksubnetr   VALUEScomputer   	GetOrFailsix	text_typeinitialization_action_timeoutinitialization_actionsr   NodeInitializationActiontimeoutlenr   ExpandScopeAliasesscopesSoftwareConfigimage_versionmaster_boot_disk_size_gbr   	api_utils	BytesToGbworker_boot_disk_size_gbr   r   !preemptible_worker_boot_disk_sizer   single_nodenum_workersr   ALLOW_ZERO_WORKERS_PROPERTYenable_node_groupsr   lowerENABLE_NODE_GROUPS_PROPERTYr   DictToAdditionalPropertyMessagePropertiesValue
componentsoptionalComponentsextendlistmap*OptionalComponentsValueListEntryValuesEnumGceClusterConfigSelfLink_GetPrivateIpv6GoogleAccessprivate_ipv6_google_access_typeservice_accountzoneauto_zone_exclude_zonespublic_ip_addressinternalIpOnly
no_addressGetReservationAffinityreservationAffinitytagsresource_manager_tagscollectionsOrderedDictitemsResourceManagerTagsValueresourceManagerTagsmetadataMetadataValuer)   AcceleratorConfigClusterConfigbuckettemp_bucket_GetCusterTypecluster_type_GetClusterTiertierInstanceGroupConfignum_mastersmaster_machine_typeGetDiskConfigmaster_boot_disk_typenum_master_local_ssdsmaster_local_ssd_interface!master_boot_disk_provisioned_iops'master_boot_disk_provisioned_throughputmaster_attached_disksmaster_min_cpu_platformGetInstanceFlexibilityPolicymaster_machine_typesmin_num_workersworker_machine_typeworker_boot_disk_typenum_worker_local_ssdsworker_local_ssd_interface!worker_boot_disk_provisioned_iops'worker_boot_disk_provisioned_throughputworker_attached_disksworker_min_cpu_platformworker_machine_typesStartupConfigr   r  kerberos_config_fileenable_kerberos$kerberos_root_principal_password_uriSecurityConfigsecurityConfigParseKerberosConfigFilekerberosConfigKerberosConfigenableKerberosrootPrincipalPasswordUriCONCEPTSkerberos_kms_keyRelativeName	kmsKeyUri%ENABLE_DYNAMIC_MULTI_TENANCY_PROPERTY!secure_multi_tenancy_user_mappingidentity_config_fileParseIdentityConfigFileidentityConfig6ParseSecureMultiTenancyUserServiceAccountMappingStringIdentityConfigUserServiceAccountMappingValueuserServiceAccountMappingautoscaling_policyAutoscalingConfigautoscalingConfigr   NodeGroupAffinitynodeGroupAffinityIsSpecifiedShieldedInstanceConfigr  r  r  shieldedInstanceConfigConfidentialInstanceConfigr  confidentialInstanceConfigdataproc_metastoreMetastoreConfigmetastoreConfigbigquery_metastore_project_id$bigquery_metastore_database_locationbigquery_metastoreGetBigQueryConfigLifecycleConfigmax_ageautoDeleteTtlexpiration_timer   FormatDateTimeautoDeleteTimemax_idleidleDeleteTtldelete_max_agedelete_expiration_timedelete_max_idlestop_max_ageautoStopTtlstop_expiration_timeautoStopTimestop_max_idleidleStopTtllifecycleConfigEncryptionConfigr  gcePdKmsKeyNamegetattrreplacer  kmsKeyencryptionConfigr   num_preemptible_workersr   !preemptible_worker_boot_disk_typenum_secondary_worker_local_ssds!num_preemptible_worker_local_ssdssecondary_worker_typesecondary_worker_machine_typesmin_secondary_worker_fractionGetProvisioningModelMix'secondary_worker_standard_capacity_base5secondary_worker_standard_capacity_percent_above_baseGetStartupConfig$secondary_worker_local_ssd_interface+secondary_worker_boot_disk_provisioned_iops1secondary_worker_boot_disk_provisioned_throughputsecondary_worker_attached_disks_GetInstanceGroupPreemptibilitysecondaryWorkerConfig_AtLeastOneGceNodePoolSpecifiedAuxiliaryNodeGroup	NodeGroupr   ParseCreateArgsLabelsValueRolesValueListEntryValuesEnumDRIVERdriver_pool_sizedriver_pool_machine_typedriver_pool_boot_disk_typenum_driver_pool_local_ssdsdriver_pool_local_ssd_interfacedriver_pool_min_cpu_platformdriver_pool_idauxiliaryNodeGroupsenable_component_gatewayEndpointConfigendpointConfiggke_clusterrq   GkeClusterConfigNamespacedGkeDeploymentTargetgke_cluster_namespacegkeClusterConfigr   r   metric_sources_SetDataprocMetricConfig)=argsr   
project_idcompute_resourcesr   r   r   r   r   master_accelerator_typeworker_accelerator_type!secondary_worker_accelerator_typedriver_pool_accelerator_typemaster_accelerator_countworker_accelerator_countr   "secondary_worker_accelerator_countdriver_pool_accelerator_count	image_refnetwork_refsubnetwork_reftimeout_strexeinit_actionsexpanded_scopessoftware_configr8  r;  "secondary_worker_boot_disk_size_gbdriver_pool_boot_disk_size_gbsoftware_config_clsgce_cluster_configreservation_affinity	flat_tagsentrykvflat_metadatamaster_acceleratorsworker_acceleratorssecondary_worker_acceleratorsdriver_pool_acceleratorscluster_configkerberos_configkerberos_kms_refuser_service_account_mappingidentity_configbigquery_metastore_configlifecycle_configchanged_configencryption_configgce_pd_kms_refkeywordkms_refr   r   r  instance_flexibility_policystartup_configlocationtarget_gke_clusters=                                                                rI   GetClusterConfigr    s$   6 ! &*#!%	((--// $ 7 7 ?$$%GHH#66::7AF	((--// $ 7 7 ?$$%GHH#66::7AF!.
'')L)L" "-2244*Fv*N'$$
6  *F)I)I*& 

"d&>&>&B

"
"7  T,--$2N2N--2244%)%A%A&%I"$$%LMM$($@$@$D$DWa$P! jj .44
jj)Z0=M 5 )  !2!8!8
ll$# "9 "+
 ;; #4#:#:
kk%%--44>> ' $; $. d@@ACG+
 --33	 4# 00{ 1  4	   ,,$44s<7HHH,#66t{{C/%%44%% 5 / #<<#	(2243M3MN#<<#	(2243M3MN'0':':

.
.

0
0($ #'d011

)
)$-$7$7''%! 
))Q. >DDOOI99:	(=@>eg 	OOI99: 
__!)!I!I((88"O 
__"++::&&--#NN	
  ((997!5!5!7"@~'>'>'@9
88 ))*'',,668":: : 
 
,0,B,B(B%	__(,%/?+?(	YY"ii	'')I++++-$!Q	!   , 	00..GG	
 * 
]]++-M++-$!Qa    #+"J"Jx((99GG# ++65 	, 	
 ++65 	, 	
 #%&!((++@? 	, 	
  !##++;: 	, 	
 $$22;;!! +<+<=!(II6)$$88''5!3!3!511*"((&((--44::((
 55$@d77%# 9 * $$88''..5!3!3!511*"((&((--44::((
 55$@d77%% 9 , )$e 3 3.j 
080A0A0O0O%)%=%= 1P 1N-
 					2	2	2$,$5$5$D$D$FN!  5L
--6n##2 !))88:o			)-)=)=&)-&		2	255 	0  ==99??A&6&C&C&E/
#5Dn##2	774??J666)))$$ ;;<     D$J$J$J		&	&	.(0(9(9(H(H(J%		"	"	"7N//8
%%4
 C66 	%
 #++::<44,!!00OO 	1 8G%%4	'/'8'8'J'J--2288:GGI (K (N$ 
___+3+<+<+N+N__ ,O ,(
 -..			/	*	*			9	:	: 	00!66))&*&H&H 	1 	
 - 
$""#9::44&*&?&? 	5 	
 1 
%-%6%6%F%F!%!8!8 &G &N" 	
((4		2	2	>		 	 	  1! &.%6%6%F%F 9 &G &N" ((88:N ||'*}}T\\'BS'H$n'(-(<(<


)% n}} '*}}T]]'Cc'I$n&
--++
,s
2 $ n"".(-(<(<

%
%)% n'
--,,
-
3 $ n$%(]]43D3D%E%K"n  ,&+&:&:

#
#'# n%%(]]43E3E%F%L"n'7n$''88:T]],--]]11779N*8*E*E*G'' 4c2D99((9  T]]I&&mm##))+G!(!5!5!7' 4c2D99(()MN
N &&&*;*B*B*B&7N# (
  $">"> %2
**
,,%! %2
**
,,%!
 '	+	7	(	4	(	4		%	%	1		#	#'8	8		#	#v	-		,	,	8		+	+	7">88FF	

 	++	# &h5N--.6$/2/99"@@FF44
  77:44 'B(' 	. 	
 (2 %T+HII,,!!++&66//99EE !))33QQXX %-$5$5$I$I%)%:%:!*!Cy/A/A/C'+'D'D%=#0$ ;;9 ;; @@)$ (,'H'H %J % , 2 ++7 	- 	
*N&@ 
"""$,$5$5$D$D!:: %E %N! #)dkkhDKK
h 0 0 )1(9(9(J(J(0(9(9(W(W1#99 )X ) )K )n% )-n%$(n!$(n!-1n*	$%%%T>8<	Ks   $A]5c                 D   U R                   (       a  U R                   $ U R                  (       aq  U R                  R                  S5      (       a!  [        R                  " U R                  5      nO[
        R                  " U R                  SS9nUR                  S5      $ / $ )zDGets metric overrides from from input file or metric_overrides list.gs://Fbinary
)metric_overridesmetric_overrides_file
startswithr
   
ReadObjectr   ReadFromFileOrStdinsplit)r  datas     rI   _GetMetricOverridesr(  ?  s~    	   	!!,,W55''(B(BCd++

$
$Ud ::d	)rL   c           	         S n[        5       n[        U 5       Vs/ s H)  oUR                  5       (       d  M  UR                  5       PM+     nnU(       a  / nU R                   Vs/ s H
  o" U5      PM     n	nU HN  n
U
R	                  S5      S   nX;  a  UR                  U
5        UR                  U/ 5      R                  U
5        MP     U(       a=  [        R                  " SSR                  U5      -   S-   SR                  U	5      -   5      eUR                  R                  / S9Ul        U R                   H  nU" U5      nUR                  U/ 5      nUR                  R                  R                  UR                  R                  [         R"                  " UUR                  R                  R$                  5      US95        M     g	s  snf s  snf )
a.  Method to set Metric source and the corresponding optional overrides to DataprocMetricConfig.

Metric overrides can be read from either metric-overrides or
metric-overrides-file argument.
We do basic validation on metric-overrides :
* Ensure that all entries of metric-overrides are prefixed with camel case of
the metric source.
  Example :
  "sparkHistoryServer:JVM:Memory:NonHeapMemoryUsage.used" is valid metric
  override for the metric-source spark-history-server
  but "spark-history-server:JVM:Memory:NonHeapMemoryUsage.used" is not.
* Metric overrides are passed only for the metric sources enabled via
args.metric_sources.

Args:
  args: arguments passed to create cluster command.
  cluster_config: cluster configuration to be updated with
    DataprocMetricConfig.
  dataproc: Dataproc API definition.
c                     U R                  5       R                  5       R                  SS5      R                  SS5      nUS   R                  5       USS  -   $ )Nr   r  r   r'   )rA  titler  )ms
title_cases     rI   _GetCamelCaseMetricSource;_SetDataprocMetricConfig.<locals>._GetCamelCaseMetricSourced  sN    !!#++C4<<S"EJa= :ab>11rL   :r   z Found invalid metric overrides: ,z~. Please ensure the metric overrides only have the following prefixes that correspond to the metric-sources that are enabled: )metrics)metricSourcemetricOverridesN)dictr(  stripr  r&  r)   
setdefaultr	   r   rr   r   DataprocMetricConfigdataprocMetricConfigr!  r3  r   r   ChoiceToEnumr   )r  r  r   r/  metric_source_to_overrides_dictmr!  invalid_metric_overridesr-  valid_metric_prefixesmetricprefixmetric_sourcemetric_source_in_camel_cases                 rI   r  r  N  s   ,2 %)F!)<T)BP)BAggiiaggi)BP!040C0C0C"!"%0C   #||C #f		, ''/%00<CCFK	 #
  $$
,HH-./OO HH*+	,  )1(9(9(N(N )O ).% **m";M"J6::#R ''//66  "//!!((DD - 	! 	
 +/ Qs   GG$Gc                    [        U S5      =(       a    U R                  S5      =(       d    U R                  S5      =(       d|    U R                  S5      =(       dd    US L=(       dY    U R                  S5      =(       dA    U R                  S5      =(       d)    U R                  S5      =(       d    U R                  S5      $ )Nr  r  r  r  r  r  r  )r&  r  )r  r  s     rI   r  r    s    	)	* 	

)* ,			4	5,			6	7, 
'd	2, 
		6	7	,
 
		;	<, 
		8	9, 
		*	+	rL   c                     U b  U $ U$ )Nr   )firstseconds     rI   r#  r#    s    #//rL   c                     US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ g )Nr2   NON_PREEMPTIBLEr3   SPOT)r   rh  PreemptibilityValueValuesEnum)r   r  s     rI   r  r    s^    //00NN  &00NN  
rL   c                 >   US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ Uc  g[        R                  " SU-   5      e)	zGet ClusterType enum value.

Converts cluster_type argument value to
ClusterType API enum value.

Args:
  dataproc: Dataproc API definition
  cluster_type: argument value

Returns:
  ClusterType API enum value
r:   STANDARDr;   SINGLE_NODEr<   
ZERO_SCALENz'Unsupported --cluster-type flag value: )r   ra  ClusterTypeValueValuesEnumr	   r   )r   re  s     rI   rd  rd    s     Z**EE  ]"**EE  \!**EE    /	 rL   c                     US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ Uc  g[        R                  " SU-   5      e)zGet ClusterTier enum value.

Converts cluster_tier argument value to
ClusterTier API enum value.

Args:
  dataproc: Dataproc API definition
  cluster_tier: argument value

Returns:
  ClusterTier API enum value
r>   CLUSTER_TIER_PREMIUMr:   CLUSTER_TIER_STANDARDNz'Unsupported --cluster-tier flag value: )r   ra  ClusterTierValueValuesEnumr	   r   )r   cluster_tiers     rI   rf  rf    s     Y**EE  Z**EE    /,>	 rL   c                 >   US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ US:X  a%  U R                   R                  R                  S5      $ Uc  g[        R                  " SU-   5      e)	a  Get PrivateIpv6GoogleAccess enum value.

Converts private_ipv6_google_access_type argument value to
PrivateIpv6GoogleAccess API enum value.

Args:
  dataproc: Dataproc API definition
  private_ipv6_google_access_type: argument value

Returns:
  PrivateIpv6GoogleAccess API enum value
rS   INHERIT_FROM_SUBNETWORKrT   OUTBOUNDrU   BIDIRECTIONALNz:Unsupported --private-ipv6-google-access-type flag value: )r   rK  &PrivateIpv6GoogleAccessValueValuesEnumr	   r   )r   rN  s     rI   rM  rM    s     %(<<--TT!  %
2--TT  %7--TT  %,  B'(	 rL   c                 ^    U R                   R                  UR                  UR                  S9$ )zGet BigQuery config.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  args: arguments of the request

Returns:
  bigquery_config: BigQuery config.
)	projectIdr  )r   BigqueryMetastoreConfigr  r  r   r  s     rI   r  r    s4     
			2	22288 
3 
 rL   c	           
      $   UbG  Ub"  US:w  a  [         R                  " U SU S35      eUS::  a  [         R                  " U SU S35      eUbG  Ub"  US:w  a  [         R                  " U SU S35      eUS::  a  [         R                  " U SU S35      e/ n	U(       Ga  U GH  n
U R                  R                  5       nU R                  R                  R	                  S5      Ul        U
R                  S	5      S:X  a*  U R                  R                  R	                  S
5      Ul        U
R                  S	5      S:X  a*  U R                  R                  R	                  S5      Ul        U
R                  S	5      S:X  a*  U R                  R                  R	                  S5      Ul        U
R                  S	5      S:X  a*  U R                  R                  R	                  S5      Ul        U
R                  S5      nU(       a  [        U5      Ul        U
R                  S5      nU(       a  [        U5      Ul	        U
R                  S5      nU(       a  [        U5      Ul
        U	R                  U5        GM     U R                  R                  UUUUUUU	S9$ )a]  Get dataproc cluster disk configuration.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  boot_disk_type: Type of the boot disk
  boot_disk_size: Size of the boot disk
  num_local_ssds: Number of the Local SSDs
  local_ssd_interface: Interface used to attach local SSDs
  node_type: Type of the dataproc node. One of Master, Worker, Secondary
    worker, Driver pool
  boot_disk_provisioned_iops: Provisioned IOPS of the boot disk
  boot_disk_provisioned_throughput: Provisioned throughput of the boot disk
  attached_disk_configs: Attached disks of the node.

Returns:
  disk_config: Dataproc cluster disk configuration
Raises:
  exceptions.ArgumentError: If boot_disk_provisioned_iops or
    boot_disk_provisioned_throughput is specified with boot_disk_type other
    than hyperdisk-balanced or if the value is not positive.
r   zU bootdisk IOPS can be specified only with bootdisk type hyperdisk-balanced, provided .r   z* bootdisk IOPS must be positive, provided z[ bootdisk throughput can be specified only with bootdisk type hyperdisk-balanced, provided z0 bootdisk throughput must be positive, provided DISK_TYPE_UNSPECIFIEDr   HYPERDISK_BALANCEDr   HYPERDISK_EXTREMEr   HYPERDISK_MLr   HYPERDISK_THROUGHPUTr   r   r   )bootDiskTypebootDiskSizeGbbootDiskProvisionedIopsbootDiskProvisionedThroughputnumLocalSsdslocalSsdInterfaceattachedDiskConfigs)r	   r   r   AttachedDiskConfigDiskTypeValueValuesEnumdiskTyper!  rG   
diskSizeGbprovisionedIopsprovisionedThroughputr)   
DiskConfig)r   boot_disk_typeboot_disk_sizenum_local_ssdslocal_ssd_interface	node_typeboot_disk_provisioned_iops boot_disk_provisioned_throughputattached_disk_configsattached_disk_configs_messagesattached_disk_configdisk	disk_sizer   r   s                  rI   rk  rk    s   B  +!n8L&L$$K ++9*:!= 
 "Q&$$K (), 
 &1!n8L&L$$K 00>/?qB 
 (1,$$K ./q2 
 $&  5113d



.
.
F
F% m
 
	!	!&	)-A	A00HH$ 	
 
	!	!&	)-@	@00HH# 	
 
	!	!&	)^	;00HH 	
 
	!	!&	)-C	C00HH& 	
 '**62i	i.!%%f-d	"4y'++L9j	%(_"$++D1Q !6T 
			%	%!#8$D!+8 
& 
 rL   c                 n    Uc  Uc  g/ nU(       a  [        XU5      nU R                  R                  UUS9$ )a  Get instance flexibility policy.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  provisioning_model_mix: Provisioning model mix for instance flexibility
    policy
  machine_types: Machine types with rank for instance selection
  node_type: Type of the dataproc node. One of master, worker,
    secondary-worker

Returns:
  InstanceFlexibilityPolicy of the secondary worker group.
N)instanceSelectionListprovisioningModelMix)GetInstanceSelectionListr   InstanceFlexibilityPolicy)r   provisioning_model_mixmachine_typesrx  instance_selection_lists        rI   rs  rs    sQ    ( #(=6 
			4	431 
5 
 rL   c                 h    Uc  Uc  gU R                   R                  U=(       d    SU=(       d    SS9$ )av  Get provisioning model mix from given parameters.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  standard_capacity_base: Standard capacity base for provisioning model mix
  standard_capacity_percent_above_base: Standard capacity percent above base
    for provisioning model mix

Returns:
  ProvisioningModelMix of with given parameters.
Nr   )standardCapacityBase standardCapacityPercentAboveBase)r   ProvisioningModelMix)r   standard_capacity_base$standard_capacity_percent_above_bases      rI   r  r    sA    $ $
.
6				/	/27a
.
3! 
0 
 rL   c                 d    UR                   c  gU R                  R                  UR                   S9$ )zGet startup config.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  args: arguments of the request

Returns:
  startup_config: Startup config of the secondary worker group.
Nr   )r  r   r  r^  s     rI   r  r    s:     
''/				(	(#'#E#E 
) 
 rL   c                    [         R                  " 5       nU R                  UUR                  UR                  UUS9nU R
                  R                  R                  U5      n	U(       a9  [        R                  R                  SR                  XR                  5      5        g[         R                  " U U	SUS9n	U R                  R                  UR                  UR                  UR                   S9n
U R
                  R                  R#                  U
5      nUR                  R$                  U R                  R&                  R(                  R*                  :X  GaD  U(       ae  UR,                  R.                  bN  [        R0                  " USR                  UR,                  R.                  R2                  R4                  5      S9  U$ UR6                  bp  UR6                  R8                  R.                   bL  [        R0                  " US	R                  UR6                  R8                  R.                  R:                  5      S9  U$ UR,                  R<                  R>                  nURA                  S
5      S   n[        R0                  " USR                  U5      S9   U$ [        RB                  " S5        UR                  RD                  (       a-  [        RB                  " SUR                  RD                  -   5        U$ )ag  Create a cluster.

Args:
  dataproc: Dataproc object that contains client, messages, and resources
  cluster_ref: Full resource ref of cluster with name, region, and project id
  cluster: Cluster to create
  is_async: Whether to wait for the operation to complete
  timeout: Timeout used when waiting for the operation to complete
  enable_create_on_gke: Whether to enable creation of GKE-based clusters
  action_on_failed_primary_workers: Action to be performed when primary
    workers fail during cluster creation. Should be None for dataproc of
    v1beta2 version

Returns:
  Created cluster, or None if async
)r8   r  r   
request_id action_on_failed_primary_workersz$Creating [{0}] with operation [{1}].Nz&Waiting for cluster creation operation)message	timeout_s)r\  r   clusterNamez"Cluster created on GKE cluster {0})detailsz+Virtual Cluster created on GKE cluster: {0}/zCluster placed in zone [{0}]zCreate cluster failed!z	Details:
)#r   GetUniqueIdGetCreateClusterRequestr\  r   clientprojects_regions_clustersCreater   statuswriterq   r9   WaitForOperationr   )DataprocProjectsRegionsClustersGetRequestr  GetstateClusterStatusStateValueValuesEnumRUNNINGconfigr  CreatedResourcer  r  virtualClusterConfigkubernetesClusterConfiggkeClusterTargetr   r   r&  errordetail)r   cluster_refr8   is_asyncr2  enable_create_on_gker  r  request	operationget_requestzone_urizone_short_names                rI   CreateClusterr    s}   4 !*,,&&'G - ' oo77>>wG)JJ.55	

 ##6	) !!KK%%)) L +
 OO5599+F'^^%%::BB  ? ? K	
6==nn--KK\\B 
.7 
	%	%	1

&
&
>
>
O
O 	AHH,,DDUUff	
, 
. 0088h s+B/o 

 177H	 
. II&'~~	iiw~~4445	.rL   c                 ~   U R                   (       a  [        R                  " U R                   5      n/ nU H0  nUR                  [        5      (       d  M  UR                  U5        M2     U H  nX$	 M     U(       d  SU l         g[        R                  " X!R                  R                  R                  5      U l         gg)zFilter out Dataproc-generated cluster labels.

Args:
  cluster: Cluster to filter
  dataproc: Dataproc object that contains client, messages, and resources
N)
r  r   MessageToPyValuer#  GENERATED_LABEL_PREFIXr)   rC  r   Clusterr  )r8   r   r  labels_to_deletelabels        rI   DeleteGeneratedLabelsr  B	  s     ^^&&w~~6F			0	1	1&  "
- "gn??
##++77gn rL   c                     U R                   R                  R                  (       a  [        X5         U R
                  R                  R                  R                  (       a  [        X5        gg! [         a     NIf = f! [         a     gf = f)zFilter out Dataproc-generated cluster properties.

Args:
  cluster: Cluster to filter
  dataproc: Dataproc object that contains client, messages, and resources
N)	r  r   r   !_DeleteClusterGeneratedPropertiesAttributeErrorr  r  kubernetesSoftwareConfig(_DeleteVirtualClusterGeneratedProperties)r8   r   s     rI   DeleteGeneratedPropertiesr  Z	  sw    	~~$$//':	$$<<UU``.wA 	a 
 		 
 		s"   0A/ :A? /
A<;A<?
BBc                    [         R                  " U R                  R                  R                  5      nSnUR                  5        Vs/ s H  nUR                  U5      (       d  M  UPM     nnU H  nX&	 M     U(       d  SU R                  R                  l        g[         R                  " X!R                  R                  R                  5      U R                  R                  l        gs  snf )z>Removes Dataproc generated properties from GCE-based Clusters.)z&hdfs:dfs.namenode.lifeline.rpc-addressz$hdfs:dfs.namenode.servicerpc-addressN)r   r  r  r   r   r  r#  rC  r   r6  rD  r8   r   propsprop_prefixes_to_deleteprop_keyprop_keys_to_deleteprops          rI   r  r  q	  s     
#
#GNN$A$A$L$L
M% jjl"(			4	5 "   "d "	/3GNN!!, 	00$$33CC	
 NN!!,s   	C+'C+c                    [         R                  " U R                  R                  R                  R
                  5      nSnUR                  5        Vs/ s H  nUR                  U5      (       d  M  UPM     nnU H  nX&	 M     U(       d&  SU R                  R                  R                  l        g[         R                  " X!R                  R                  R                  5      U R                  R                  R                  l        gs  snf )z<Removes Dataproc generated properties from Virtual Clusters.)z dpgke:dpgke.unstable.outputOnly.N)r   r  r  r  r  r   r  r#  rC  r   KubernetesSoftwareConfigrD  r  s          rI   r  r  	  s     
#
#""::SS^^% jjl"(			4	5 "   "d " 
   88QQ\ `h  `H  `H  99II`G  88QQ\s   D	1D	c                     U R                   R                  R                  nU(       d  gUS:X  a  US   R                  $ US   R                  $ )a  Return a cluster-generated public encryption key if there is one.

Args:
  cluster: Cluster to check for an encryption key.
  key_type: Dataproc clusters publishes both RSA and ECIES public keys.

Returns:
  The public key for the cluster if there is one, otherwise None
NECIESr   )r  r   instanceReferencespublicEciesKey	publicKey)r8   key_typemaster_instance_refss      rI   
ClusterKeyr  	  sJ     !44GG	"111	a	 	*	**rL   c                 j    U R                  US9nUR                  S/ SQSUS9  UR                  SSS9  g)	zFAdds the argument group to handle reservation affinity configurations.r%   z--reservation-affinity)anynonespecificr  )r4   r!   r&   z--reservationzO
The name of the reservation, required when `--reservation-affinity=specific`.
N)r   rc   )rN   rZ   r[   groups       rI   r   r   	  sQ    





+%)	     rL   c                     [        U SS5      nUS:X  a-  U R                  S5      (       d  [        R                  " S5      egg)z0Validates flags specifying reservation affinity.r  Nr  reservationzD--reservation must be specified with --reservation-affinity=specific)r  r  r	   r   )r  affinitys     rI    ValidateReservationAffinityGroupr  	  sJ    T148(M**$$
P  + rL   c                 r   U R                  S5      (       a  UR                  R                  R                  nSn/ nU R                  S:X  a  UR
                  nO<U R                  S:X  a   UR                  n[        nU R                  /nOUR                  nUR                  R                  UU=(       d    SUS9$ g)z=Returns the message of reservation affinity for the instance.r  Nr  r  )consumeReservationTypekeyvalues)
r  r   ReservationAffinity%ConsumeReservationTypeValueValuesEnumr  NO_RESERVATIONSPECIFIC_RESERVATIONRESERVATION_AFFINITY_KEYr  ANY_RESERVATION)r  r  	type_msgsreservation_keyreservation_valuesreservation_types         rI   rU  rU  	  s    	,--++QQ  O  F*"11		"	"j	0"77 1o ,,-"22??../#t! /   
rL   zcompute.z/reservation-namec                    U R                  S[        R                  " SSS9S9nUR                  5       nUR                  SSSS	9  UR                  S
SS9  SSSSS.n[        R
                  " USUSS9  UR                  SSS9  g)z:Adds the argument group to handle Kerberos configurations.Tz<Specifying these flags will enable Kerberos for the cluster.z3Kerberos is only supported in the default universe.rV   r$   r&   z--enable-kerberosr,   z0        Enable Kerberos on the cluster.
        r-   z&--kerberos-root-principal-password-uriz        Google Cloud Storage URI of a KMS encrypted file containing the root
        principal password. Must be a Cloud Storage URL beginning with 'gs://'.
        r%   z--kerberos-kms-keyz--kerberos-kms-key-keyringz--kerberos-kms-key-locationz--kerberos-kms-key-project)r  r  r  r  password)flag_overridesr9   z--kerberos-config-filea  Path to a YAML (or JSON) file containing the configuration for Kerberos on the
cluster. If you pass `-` as the value of the flag the file content will be read
from stdin.

The YAML file is formatted as follows:

```
  # Optional. Flag to indicate whether to Kerberize the cluster.
  # The default value is true.
  enable_kerberos: true

  # Optional. The Google Cloud Storage URI of a KMS encrypted file
  # containing the root principal password.
  root_principal_password_uri: gs://bucket/password.encrypted

  # Optional. The URI of the Cloud KMS key used to encrypt
  # sensitive files.
  kms_key_uri:
    projects/myproject/locations/global/keyRings/mykeyring/cryptoKeys/my-key

  # Configuration of SSL encryption. If specified, all sub-fields
  # are required. Otherwise, Dataproc will provide a self-signed
  # certificate and generate the passwords.
  ssl:
    # Optional. The Google Cloud Storage URI of the keystore file.
    keystore_uri: gs://bucket/keystore.jks

    # Optional. The Google Cloud Storage URI of a KMS encrypted
    # file containing the password to the keystore.
    keystore_password_uri: gs://bucket/keystore_password.encrypted

    # Optional. The Google Cloud Storage URI of a KMS encrypted
    # file containing the password to the user provided key.
    key_password_uri: gs://bucket/key_password.encrypted

    # Optional. The Google Cloud Storage URI of the truststore
    # file.
    truststore_uri: gs://bucket/truststore.jks

    # Optional. The Google Cloud Storage URI of a KMS encrypted
    # file containing the password to the user provided
    # truststore.
    truststore_password_uri:
      gs://bucket/truststore_password.encrypted

  # Configuration of cross realm trust.
  cross_realm_trust:
    # Optional. The remote realm the Dataproc on-cluster KDC will
    # trust, should the user enable cross realm trust.
    realm: REMOTE.REALM

    # Optional. The KDC (IP or hostname) for the remote trusted
    # realm in a cross realm trust relationship.
    kdc: kdc.remote.realm

    # Optional. The admin server (IP or hostname) for the remote
    # trusted realm in a cross realm trust relationship.
    admin_server: admin-server.remote.realm

    # Optional. The Google Cloud Storage URI of a KMS encrypted
    # file containing the shared password between the on-cluster
    # Kerberos realm and the remote trusted realm, in a cross
    # realm trust relationship.
    shared_password_uri:
      gs://bucket/cross-realm.password.encrypted

  # Optional. The Google Cloud Storage URI of a KMS encrypted file
  # containing the master key of the KDC database.
  kdc_db_key_uri: gs://bucket/kdc_db_key.encrypted

  # Optional. The lifetime of the ticket granting ticket, in
  # hours. If not specified, or user specifies 0, then default
  # value 10 will be used.
  tgt_lifetime_hours: 1

  # Optional. The name of the Kerberos realm. If not specified,
  # the uppercased domain name of the cluster will be used.
  realm: REALM.NAME
```
        N)r`   r   rz   rc   ri   rj   )rN   kerberos_groupkerberos_flag_groupkerberos_kms_flag_overridess       rI   r   r   
  s    ,,''LM	 - . '99;"" #  "". #  &131	! ((0	 P  SrL   c                 J   [         R                  " USS9n [        R                  " U5      nUR                  S0 5      nUR                  S5      nUR                  S5      nUR                  S5      nUR                  S	5      n	UR                  S
5      n
UR                  S0 5      nUR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      nU R                  R                  UR                  SS5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UUU	UU
UUUUS9nU$ ! [         a*  n[
        R                  " SR                  U5      5      eSnAff = f)z=Parse a kerberos-config-file into the KerberosConfig message.Fr  Cannot parse YAML:[{0}]Nsslkeystore_uritruststore_urikeystore_password_urikey_password_uritruststore_password_uricross_realm_trustrealmkdcadmin_servershared_password_urir  Troot_principal_password_urikms_key_urikdc_db_key_uritgt_lifetime_hours)r  r  r  kdcDbKeyUritgtLifetimeHoursr  keystoreUrikeystorePasswordUrikeyPasswordUritruststoreUritruststorePasswordUricrossRealmTrustRealmcrossRealmTrustKdccrossRealmTrustAdminServer crossRealmTrustSharedPasswordUri)r   r%  r   load	Exceptionr	   
ParseErrorrq   r!  r   r  )r   r  r'  kerberos_config_datae
ssl_configr  r  r  r  r  cross_realm_trust_configcross_realm_trust_realmcross_realm_trust_kdccross_realm_trust_admin_server%cross_realm_trust_shared_password_urikerberos_config_msgs                    rI   r  r  
  s   		'	'(<U	K$E99T? $''r2*/,>>"23.$..)@A^^$67&NN+DE1556I2N488A266u=#;#?#?#O *B*F*F+' !))88 *--.?F377
'  %((7&**+;<+//0DE $$W-/%"32.!?'L) 9 . 
Q 
 E


 9 @ @ C
DDEs   E. .
F"8%FF"c                     U R                  S[        R                  " SSS9S9nUR                  SSS9  UR                  S	[        R
                  " S
5      S9  g)zFAdds the argument group to handle Secure Multi-Tenancy configurations.TzHSpecifying these flags will enable Secure Multi-Tenancy for the cluster.zLSecure Multi-Tenancy for clusters is only supported in the default universe.rV   r  z--identity-config-fileaH  Path to a YAML (or JSON) file containing the configuration for Secure Multi-Tenancy
on the cluster. The path can be a Cloud Storage URL (Example: 'gs://path/to/file')
or a local file system path. If you pass "-" as the value of the flag the file content
will be read from stdin.

The YAML file is formatted as follows:

```
  # Required. The mapping from user accounts to service accounts.
  user_service_account_mapping:
    bob@company.com: service-account-bob@project.iam.gserviceaccount.com
    alice@company.com: service-account-alice@project.iam.gserviceaccount.com
```
        r%   z#--secure-multi-tenancy-user-mappingaR            A string of user-to-service-account mappings. Mappings are separated
          by commas, and each mapping takes the form of
          "user-account:service-account". Example:
          "bob@company.com:service-account-bob@project.iam.gserviceaccount.com,alice@company.com:service-account-alice@project.iam.gserviceaccount.com".N)r`   r   rz   rc   textwrapdedent)rN   secure_multi_tenancy_groups     rI   r   r   
  sz    %88''#	  9   )) * $ ))+??\ * 	rL   c                 <   UR                  S5      (       a  [        R                  " U5      nO[        R                  " USS9n [
        R                  " U5      nUR                  S0 5      (       d  [        R                  " S5      e[        R                  " UR                  S0 5      U R                  R                   R"                  5      nU R                  R!                  US9nU$ ! [         a*  n[        R                  " SR                  U5      5      eSnAff = f)	z>Parses a identity-config-file into the IdentityConfig message.r  Fr  r  Nr  zQ--identity-config-file must contain at least one user to service account mapping.)r  )r#  r
   r$  r   r%  r   r  r  r	   r  rq   r!  r   r   rC  r   r  r  )r   r  r'  identity_config_datar  r  identity_config_data_msgs          rI   r  r  
  s    $$W--%%&:;D))*>uMDE99T? 
	!	!"@"	E	E

"
"	+ 
 "*!I!I=rB&&EE"
 &..== < >  
"!% 
 E


 9 @ @ C
DDEs   C' '
D1%DDc                     [         R                  " 5       nU R                  S5      nU HC  nUR                  S5      n[        U5      S:w  a  [        R
                  " S5      eUS   XS   '   ME     U$ )zDParses a secure-multi-tenancy-user-mapping string into a dictionary.r2  r1     z*Invalid Secure Multi-Tenancy User Mapping.r'   r   )rY  rZ  r&  r3  r	   r   )#user_service_account_mapping_stringr  mapping_str_listmapping_strmappings        rI   r  r  
  s}    
 "-!8!8!: 9>>sC%k$G
7|q$$
6  07qz , & 
&%rL   c                    Uc  / $ / nU H  nSU;  d
  US   (       d  [         R                  " SU S35      eUS   nSU;  a  SnOTUS   n[        U5      S:w  d  US   R                  5       (       d  [         R                  " SU S35      e[	        US   5      nU R
                  R                  5       nXl        XVl        UR                  U5        M     U$ )z5Build List of InstanceSelection from the given flags.r   zMissing machine type for z-machine-typesrankr   r'   zInvalid value for rank in )
r	   r   r3  isdigitrG   r   InstanceSelectionmachineTypesr(  r)   )r   r  rx  r  machine_type_configr(  instance_selections          rI   r  r    s    I*((0CF0K$$%i[
?  (/M((d (d	TatAw00&&(>B
 	
 a\d!**<<>&3#"""#56+ +. 
! rL   c                   $    \ rS rSrSrS rS rSrg)rg   i.  zlConverts argument values into multi-valued mappings.

Values for the repeated keys are collected in a list.
c                 z    SnSR                  US9n[        R                  " U[        R                  5      U l        g )N=z([^{ops}]+)([{ops}]?)(.*))ops)rq   recompileDOTALLkey_op_value)selfr1  key_op_value_patterns      rI   __init__ArgMultiValueDict.__init__4  s3    
C6==#=F

#7CDrL   c                    UR                  S5       Vs/ s H  o"R                  5       PM     nn[        R                  " 5       nU H  nU R                  R                  U5      nU(       d%  [        R                  " SR                  U5      5      eUR                  S5      R                  5       UR                  S5      UR                  S5      R                  5       pnUR                  U/ 5      R                  U	5        M     U$ s  snf )Nr2  zInvalid flag value [{0}]r'   r"  rF   )r&  r7  rY  rZ  r5  matchr   ArgumentTypeErrorrq   r  r8  r)   )
r6  	arg_valueitemarg_listarg_dictargr;  r  r  values
             rI   __call__ArgMultiValueDict.__call__9  s    )2)=>)=

)=H>&&(H%%c*e++&--c2
 	
 ++a.


 
++a.
++a.


  c
 #r"))%0  O ?s   D)r5  N)__name__
__module____qualname____firstlineno____doc__r8  rC  __static_attributes__r   rL   rI   rg   rg   .  s    
D
rL   rg   c                   t    \ rS rSrSrS rS\S\\\\4      4S jr	S\S\\\4   4S jr
S	\\\4   4S
 jrSrg)rx   iK  a
  Parses and validates disk configurations provided as a string.

This class takes a string representing disk configurations, parses them,
validates each configuration, and returns a list of dictionaries, where each
dictionary represents a valid disk configuration.

The expected format for the input string is a semi-colon separated list of
disk configurations. Each disk configuration is a comma-separated list of
key-value pairs, where the key and value are separated by an equals sign (=).

Example:
    'type=pd-ssd,size=100GB,iops=2000;type=pd-standard,size=5TB'

Attributes:
    binary_size_parser: An instance of arg_parsers.BinarySize used to parse
      and validate disk sizes. It is initialized with a lower bound of '4GB'
      and suggested scales of 'GB' and 'TB'.
c                 <    [         R                  " SSS/S9U l        g )N4GBGBTB)r   suggested_binary_size_scales)r   r   binary_size_parser)r6  s    rI   r8  DiskConfigParser.__init___  s    )44tDrL   rB  returnc                    U(       d  / $ [        U[        5      (       d"  [        R                  " S[	        U5       35      eUR                  S5      n/ nU HP  nUR                  5       nU(       d  M   U R                  U5      nU R                  U5        UR                  U5        MR     U$ ! [         a"  n[        R                  " SU SU 35      UeSnAff = f)a  Parses and validates a string of disk configurations.

Args:
    value: A string containing the disk configurations, or an empty string.

Returns:
    A list of dictionaries, where each dictionary represents a valid disk
    configuration. Returns an empty list if the input string is empty.

Raises:
    exceptions.ArgumentError: If the input is not a string, if a disk
      configuration is invalid, or if any validation fails.
z0Expected string for disk configuration, but got ;zInvalid disk configuration: z. N)
isinstancer   r	   r   r   r&  r7  _ParseKeyValuePairs
ValueError_ValidateDiskDatar)   )r6  rB  disk_configsresultr  	disk_datar  s          rI   rC  DiskConfigParser.__call__d  s     ieS!!$$<T%[M
J  ;;s#LF||~f,,V4	
 Y'mmI  M  &&*6("QC8
	s   3B,,
C6CCr  c                     0 nUR                  S5      nU Hc  nSU;  a  [        SU S35      eUR                  SS5      u  pVUR                  5       nUR                  5       nXR;   a  [        SU 35      eXbU'   Me     U$ )av  Parses a single disk configuration string into a dictionary.

Args:
    config: A string representing a single disk configuration (e.g.,
      'type=pd-ssd,size=100GB').

Returns:
    A dictionary containing the key-value pairs of the disk configuration.

Raises:
    ValueError: If the input string is not in the expected key=value format,
      or if a key is duplicated.
r2  r0  zInvalid key-value pair: z$. It should follow format: key=valuer'   zDuplicate key: )r&  rX  r7  )r6  r  r\  pairspairr  rB  s          rI   rW  $DiskConfigParser._ParseKeyValuePairs  s     ILLE	D&tf - 
 	
 ::c1%jcIIKckkme		?3%011n  rL   r\  c           	         UR                  5        H<  nU[        ;  d  M  [        R                  " SU SSR	                  [        5       35      e   SU;  d
  US   (       d  [        R                  " S5      eUS   [
        ;  a2  [        R                  " SUS    SSR	                  [
        5       35      eSU;   a.  US   (       a$   [        U R                  US   5      S	-  5      US'   SU;   aQ  US   (       aG  US   R                  5       (       a  [        US   5      S::  a  [        R                  " SUS    S35      eSU;   aS  US   (       aH  US   R                  5       (       a  [        US   5      S::  a  [        R                  " SUS    S35      eggg! [        R                   a$  n[        R                  " S
US    SU 35      eSnAff = f)a-  Validates the disk data provided for attached disks.

This method checks that:
  - All keys in the disk_data dictionary are in the
  `ALLOWED_DISK_CONFIG_KEYSET`.
  - The 'type' key is present and has a valid value.
  - The 'size' value, if present, can be parsed by `binary_size_parser`.
  - The 'iops' value, if present, is a positive integer.
  - The 'throughput' value, if present, is a positive integer.

Args:
    disk_data: A dictionary representing the disk configuration.

Raises:
    exceptions.ArgumentError: If any of the validation rules fail.
zInvalid key: z. Allowed keys are: z, r   zDisk type is requiredzInvalid disk type: z. It must be one of: r   i   @zInvalid disk size: Nr   r   zInvalid iops value: z , It should be a positive numberr   zInvalid throughput value: )r  ALLOWED_DISK_CONFIG_KEYSETr	   r   rr   VALID_DISK_TYPESrG   rQ  r   r<  r)  )r6  r\  r  r  s       rI   rY  "DiskConfigParser._ValidateDiskData  s   " ~~	.	.&&C5 !		4568
 	
   Yi&7$$%<== 00$$	& 12 3  $		*: ;<>  y0
##If$56:LM
	& 	)f6"**,,If4E0F!0K$$ 6!2 3 4  
 		!l#,'//119\*+q0 $$&y'>&? @   1 $ 	" ** 
&&!)F"3!4Bqc:
 	

s   #F G/GG)rQ  N)rE  rF  rG  rH  rI  r8  r   r   r   rC  rW  rY  rJ  r   rL   rI   rx   rx   K  s\    &
"C "Dc3h$8 "H S#X <;c3h ;rL   rx   )FFTFFF)F)FFTFF)NNN)FN)YrI  rY  r2  r  typingr   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   r9  googlecloudsdk.api_lib.dataprocr   r   r	   r
   r   googlecloudsdk.callioper   r   ,googlecloudsdk.command_lib.compute.instancesr   ra   #googlecloudsdk.command_lib.dataprocgooglecloudsdk.command_lib.kmsr   ri   $googlecloudsdk.command_lib.util.apisr   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   r-  r  rd  	frozensetrc  r   r   r   r   rw   rv   r   r  r(  r  r  r#  r  rd  rf  rM  r  rk  rs  r  r  r  r  r  r  r  r  r   r  rU  r*  coreuniverse_domainr  r  r   r  r   r  r  r  rg   objectrx   r   rL   rI   <module>rw     s   8  	   % = ; 5 6 ; 0 + / Q 5 M : < # * $ 2 * 
 *   ''MN  

#"DN6rRj*ZJ^ 

#d	N?D
0	B8B.  $%)od!H>. %)^B0	.<B+$"@ ##((88<<>%o%66GH |~-`*Z">&&!> :Vv VrL   