
                         2   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ d Z G d dej0                        Z G d dej0                        Z G d dej0                        Zd Z G d de      Zd Zd Z d Z!d Z"d Z#d Z$d  Z%d! Z&d" Z'd# Z(d$ Z)d% Z*d& Z+d' Z,d(e
jZ                  fd)Z.d* Z/d+ Z0d;d,Z1d<d-Z2d;d.Z3d/ Z4d0 Z5d1 Z6d2e7d(dfd3Z8d4 Z9d5 Z:d=d6Z;d7 Z<d8 Z=d9 Z>d: Z?y)>z0Module for wrangling bigtable command arguments.    N)util)actions)arg_parsers)base)
exceptions)concepts)
completers)	arg_utils)	yaml_data)resource_args)concept_parsers)presentation_specs)textc                      t        j                         j                  j                  j	                         D  cg c]  } d| vrt        j                  |        c} S c c} w )NUNSPECIFIED)r   GetAdminMessagesCluster NodeScalingFactorValueValuesEnumnamesr
   EnumNameToChoicexs    4lib/googlecloudsdk/command_lib/bigtable/arguments.pyGetValidNodeScalingFactorsr   #   sZ     $$&..OOUUW
W!	a	   #W
  
s    Ac                        e Zd Z fdZ xZS )ClusterCompleterc                 2    t        t        | 
  dddd| y )N)bigtableadmin.projects.instances.clustersz!beta bigtable clusters list --uri
collectionlist_command )superr   __init__selfkwargs	__class__s     r   r$   zClusterCompleter.__init__-   s(    	
D* >8     __name__
__module____qualname__r$   __classcell__r(   s   @r   r   r   +        r)   r   c                        e Zd Z fdZ xZS )InstanceCompleterc                 2    t        t        | 
  dddd| y )N bigtableadmin.projects.instancesz"beta bigtable instances list --urir   r"   )r#   r2   r$   r%   s     r   r$   zInstanceCompleter.__init__7   s(    	
T+ 59 r)   r*   r/   s   @r   r2   r2   5   r0   r)   r2   c                        e Zd Z fdZ xZS )TableCompleterc                 2    t        t        | 
  dddd| y )N'bigtableadmin.projects.instances.tablesz)beta bigtable instances tables list --urir   r"   )r#   r6   r$   r%   s     r   r$   zTableCompleter.__init__A   s'    	.$( <@ r)   r*   r/   s   @r   r6   r6   ?   r0   r)   r6   c                    t        j                         }| j                  }|j                  j	                  | j
                        }| j                  d      s'||j                  j                  j                  k(  rd}|S ||j                  j                  j                  k(  rt        j                  dd      |dk  rt        j                  dd      |S )a5  Ensure that --instance-type and --num-nodes are consistent.

  If --instance-type is DEVELOPMENT, then no --cluster-num-nodes can be
  specified. If --instance-type is PRODUCTION, then --cluster-num-nodes defaults
  to 3 if not specified, but can be any positive value.

  Args:
    args: an argparse namespace.

  Raises:
    exceptions.InvalidArgumentException: If --cluster-num-nodes is specified
        when --instance-type is DEVELOPMENT, or --cluster-num-nodes is not
        positive.

  Returns:
    Number of nodes or None if DEVELOPMENT instance-type.
  cluster_num_nodes   --cluster-num-nodesz9Cannot set --cluster-num-nodes for DEVELOPMENT instances.   z;Clusters of PRODUCTION instances must have at least 1 node.)r   r   r:   InstanceTypeValueValuesEnuminstance_typeIsSpecified
PRODUCTIONDEVELOPMENTr   InvalidArgumentException)argsmsgs	num_nodesr@   s       r   ProcessInstanceTypeAndNodesrH   I   s    $ 
			 $$$)--33D4F4FG-			-	.99DDDi 
 99EEE//

E  
Q//

G  
r)   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zdd
Zd Z	 ddZd Z	 ddZddZd ZddefdZddefdZd ZddZd Zd Z	 	 	 	 	 d dZd Zd ZddZy)!ArgAdderz3A class for adding Bigtable command-line arguments.c                     || _         y N)parser)r&   rM   s     r   r$   zArgAdder.__init__r   s	    DKr)   c                     t        j                  |t        j                         j                  j
                  t                     S )N)valid_choices)r
   ChoiceToEnumr   r   r   r   r   )r&   node_scaling_factors     r   _GetNodeScalingFactorChoicez$ArgAdder._GetNodeScalingFactorChoiceu   s6    !!''HH02 r)   c                 X    t         j                  j                  | j                         | S rL   )r   
ASYNC_FLAGAddToParserrM   r&   s    r   AddAsynczArgAdder.AddAsync|   s    OO,Kr)   c                 L    | j                   j                  dt        dd       | S )zAdd cluster argument.	--clusterzID of the cluster.T	completerhelprequired)rM   add_argumentr   rV   s    r   
AddClusterzArgAdder.AddCluster   s,    KK"!	   Kr)   c                 |    | j                   j                  dt        ddt        j                  dddd             | S )z Add deprecated cluster argument.rY   zID of the clusterFEThe {flag_name} argument is deprecated; use --cluster-config instead.storewarnremovedaction)r[   r\   r]   rf   )rM   r^   r   r   DeprecationActionrV   s    r   AddDeprecatedClusterzArgAdder.AddDeprecatedCluster   sJ    KK" (( 
   Kr)   c                 |    | j                   j                  dddt        t        j                  dddd             | S )z&Add deprecated cluster nodes argument.r<   Number of nodes to serve.Fra   rb   rc   )r\   r]   typerf   )rM   r^   intr   rg   rV   s    r   AddDeprecatedClusterNodesz"ArgAdder.AddDeprecatedClusterNodes   sJ    KK(((! 
   Kr)   c                 r    t        j                  dddgdd      }|j                  | j                         | S )Nz--cluster-storage-typehddssdzStorage class for the cluster.)choicesdefaulthelp_str)r   ChoiceArgumentrU   rM   )r&   storage_arguments     r   AddClusterStoragezArgAdder.AddClusterStorage   s<    ** 1	   -Kr)   c                 ~    t        j                  ddt               d      }|j                  | j                         | S )Nz--node-scaling-factorz$Node scaling factor for the cluster.znode-scaling-factor-1x)rs   rq   rr   )r   rt   r   rU   rM   )r&   node_scaling_factor_arguments     r   AddClusterNodeScalingFactorz$ArgAdder.AddClusterNodeScalingFactor   s;    #'#6#67*,(	$  !,,T[[9Kr)   c                 J    | j                   j                  |rdnddd       | S )N--cluster-zonez--zone|ID of the zone where the cluster is located. Supported zones are listed at https://cloud.google.com/bigtable/docs/locations.Tr\   r]   rM   r^   )r&   in_instances     r   AddClusterZonezArgAdder.AddClusterZone   s3    KK'XN    Kr)   c                 r    | j                   j                  dddt        j                  dddd             | S )z%Add deprecated cluster zone argument.r{   r|   Fra   rb   rc   )r\   r]   rf   rM   r^   r   rg   rV   s    r   AddDeprecatedClusterZonez!ArgAdder.AddDeprecatedClusterZone   sL    KKN (( 
  " Kr)   Nc                 8   dj                  t        j                  |rdndd            }|rdj                  ||g      }|rdnd}t        |d}|r&|rd|d	<   nd
}t        j                         |d<   d|d<   |s||d<    | j                  j                  |fi | | S )z'Add argument for instance ID to parser.zID of the {}.   r=   instance 
--instance)r[   r\   +nargs--instancesrk   INSTANCEmetavarr]   )	formatr   	Pluralizejoinr2   r   ArgListrM   r^   )r&   
positionalr]   multipleadditional_help	help_textnamerE   s           r   AddInstancezArgAdder.AddInstance   s      &&Hq!Z8I ((I78i#:D*I>D	W"**,V$Y!d:DKKT*T*Kr)   c                 L    | j                   j                  dt        dd       | S )zAdd table argument.--tablezID of the table.TrZ   )rM   r^   r6   rV   s    r   AddTablezArgAdder.AddTable   s,    KK 	   Kr)   c                    | j                   j                  |      }|j                  d      }|j                  ddddd       |j                  d	t	        j
                         d
d       |j                  dddd       |j                  d      }|j                  dt        dd       d}|j                  ddd|       | S )z1Adds arguments for app_profile routing to parser.r]   zMulti Cluster Routing Policyz--route-any
store_trueTFz!Use Multi Cluster Routing policy.)rf   r]   rr   r\   z--restrict-toztCluster IDs to route to using the Multi Cluster Routing Policy. If unset, all clusters in the instance are eligible.RESTRICT_TO)rk   r\   r   z--row-affinityNz.Use row-affinity routing for this app profile.rf   rr   r\   zSingle Cluster Routing Policyz
--route-toz;Cluster ID to route to using Single Cluster Routing policy.)r[   r]   r\   z@Allow transactional writes with a Single Cluster Routing policy.z--transactional-writes)rM   add_mutually_exclusive_group	add_groupr^   r   r   r   )r&   r]   routing_group	any_grouproute_to_grouptransactional_write_helps         r   AddAppProfileRoutingzArgAdder.AddAppProfileRouting  s   
 KK<<h<OM''(FGI0     "D    =	   #,,-LMN"J	    	K   %	    Kr)   c                 `    | j                   j                  ddj                  |      |       | S )z'Add argument for description to parser.z--descriptionzFriendly name of the {}.r}   rM   r^   r   )r&   resourcer]   s      r   AddDescriptionzArgAdder.AddDescription6  s4    KK'..x8  
 Kr)   c                 b    | j                   j                  ddddj                  |             | S )z%Add argument for force to the parser.z--forcer   FzIgnore warnings and force {}.r   r   )r&   verbs     r   AddForcezArgAdder.AddForce?  s7    KK,33D9	   Kr)   r]   c                 B    | j                   j                  dd|       | S )z*Add argument for view query to the parser.z--queryzThe query of the view.r}   r~   r&   r]   s     r   AddViewQueryzArgAdder.AddViewQueryI  s)    KK%  
 Kr)   c                 j    | j                   j                  dt        j                         d|d       | S )z3Add argument for deletion protection to the parser.z--deletion-protectionz,Whether the view is protected from deletion.N)rk   r\   r]   rr   )rM   r^   r   
ArgBooleanr   s     r   AddDeletionProtectionzArgAdder.AddDeletionProtectionR  s8    KK##%;   Kr)   c                 H   | j                   j                         }|j                  d      }dddd}|j                  dd |dd	d
       |j                  dddd       |j                  d      }|j                  ddddd
       ddi}|j                  dd |ddd
       | S )z@Add argument for isolating this app profile's traffic to parser.zStandard Isolationz'Requests are treated with low priority.z*Requests are treated with medium priority.z(Requests are treated with high priority.)PRIORITY_LOWPRIORITY_MEDIUMPRIORITY_HIGHz
--priorityc                 B    | j                  dd      j                         S )N-_)replaceupperr   s    r   <lambda>z'ArgAdder.AddIsolation.<locals>.<lambda>k  s    qyyc*002r)   Na  Specify the request priority under standard provisioned node compute capabilities. Passing this option implies standard provisioned node compute, e.g. the `--standard` option. If not specified, the app profile uses standard provisioned node compute with PRIORITY_HIGH by default. Specifying request priority on an app profile that has Data Boost serverless compute enabled changes the compute option to standard and uses the specified priority, which might cause unexpected behavior for running applications.T)rk   rq   rr   r\   r]   z
--standardr   Fz|Use standard provisioned node compute option, rather than Data Boost compute option. If specified, `--priority` is required.r   zData Boost Read-only Isolationz--data-boosta*  Use Data Boost serverless compute option, rather than standard provisioned node compute. If specified, --data-boost-compute-billing-owner is required. Specifying Data Boost compute on an app profile that uses standard provisioned node compute may cause unexpected behavior for running applications.)rf   rr   r\   r]   	HOST_PAYSzwCompute billing should be accounted towards the host Cloud project (containing the targeted Bigtable instance / table).z"--data-boost-compute-billing-ownerc                 "    | j                         S rL   r   r   s    r   r   z'ArgAdder.AddIsolation.<locals>.<lambda>  
    qwwyr)   zQSpecify the Data Boost compute billing owner, required if --data-boost is passed.)rM   r   r   r^   )r&   isolation_groupstandard_isolation_grouprq   data_boost_isolation_groupcompute_billing_choicess         r   AddIsolationzArgAdder.AddIsolation]  s   kk>>@O.88 
 BGCG
 ))2 ! * & ))M *  "1!:!:(" ++  ,   	L ++, ''  , 
 Kr)   c                 B    | j                   j                  dd|       | S )z.Add argument group for display-name to parser.z--display-namezFriendly name of the instance.r}   r~   r   s     r   AddInstanceDisplayNamezArgAdder.AddInstanceDisplayName  s)    KK-  
 Kr)   c                     ddd}| j                   j                  ddd |ddt        j                  dd	dd
             | S )z&Add deprecated instance type argument.zProduction instances provide high availability and are suitable for applications in production. Production instances created with the --instance-type argument have 3 nodes if a value is not provided for --cluster-num-nodes.zDevelopment instances are low-cost instances meant for development and testing only. They do not provide high availability and no service level agreement applies.)rB   rC   z--instance-typerB   c                 "    | j                         S rL   r   r   s    r   r   z4ArgAdder.AddDeprecatedInstanceType.<locals>.<lambda>  r   r)   zThe type of instance to create.FzzThe {flag_name} argument is deprecated. DEVELOPMENT instances are no longer offered. All instances are of type PRODUCTION.rb   rc   )rr   rk   rq   r\   r]   rf   r   )r&   rq   s     r   AddDeprecatedInstanceTypez"ArgAdder.AddDeprecatedInstanceType  sd    7!G 	KK .((P 
  " Kr)   c                    | j                   j                  ddt        j                  t        t        t
        | j                  t        t
        t
        t
        t
        d	ddgd      dt        j                  d	      
       | S )z5Add the cluster-config argument as repeated kv dicts.z--cluster-configappend)	idzonenodesznode-scaling-factorkms-keyzautoscaling-min-nodeszautoscaling-max-nodeszautoscaling-cpu-targetzautoscaling-storage-targetr   r   	   )specrequired_keys
max_lengtha  id=ID,zone=ZONE,[nodes=NODES],[node-scaling-factor=NODE_SCALING_FACTOR],[kms-key=KMS_KEY],[autoscaling-min-nodes=AUTOSCALING_MIN_NODES,autoscaling-max-nodes=AUTOSCALING_MAX_NODES,autoscaling-cpu-target=AUTOSCALING_CPU_TARGET,autoscaling-storage-target=AUTOSCALING_STORAGE_TARGET]a          *Repeatable*. Specify cluster config as a key-value dictionary.

        This is the recommended argument for specifying cluster configurations.

        Keys can be:

          *id*: Required. The ID of the cluster.

          *zone*: Required. ID of the zone where the cluster is located. Supported zones are listed at https://cloud.google.com/bigtable/docs/locations.

          *nodes*: The number of nodes in the cluster. Default=1.

          *node-scaling-factor*: The node scaling factor for the cluster. Default=node-scaling-factor-1x. NODE_SCALING_FACTOR must be one of: node-scaling-factor-1x, node-scaling-factor-2x.

          *kms-key*: The Cloud KMS (Key Management Service) cryptokey that will be used to protect the cluster.

          *autoscaling-min-nodes*: The minimum number of nodes for autoscaling.

          *autoscaling-max-nodes*: The maximum number of nodes for autoscaling.

          *autoscaling-cpu-target*: The target CPU utilization percentage for autoscaling. Accepted values are from 10 to 80.

          *autoscaling-storage-target*: The target storage utilization gibibytes per node for autoscaling. Accepted values are from 2560 to 5120 for SSD clusters and 8192 to 16384 for HDD clusters.

        If this argument is specified, the deprecated arguments for configuring a single cluster will be ignored, including *--cluster*, *--cluster-zone*, *--cluster-num-nodes*.

        See *EXAMPLES* section.
        )rf   rk   r   r\   )	rM   r^   r   ArgDictstrrl   rR   textwrapdedentrV   s    r   AddClusterConfigzArgAdder.AddClusterConfig  s    KK  '+'G'G),),*-.1
  .
 E __  7  8t Kr)   c                    | j                   j                  |      }|j                  d      }|j                  dd||t        d       |r|j                  ddd	d
d
d
       |j                  dd
      }|j                  ddd|t        d       |j                  ddd|t        d       |j                  ddd|t        d       |j                  dddd
t        d       | S )Add scaling related arguments.r   zManual Scalingz--num-nodesrj   	NUM_NODES)r\   rr   r]   rk   r   z--disable-autoscalingz~Set this flag and --num-nodes to disable autoscaling. If autoscaling is currently not enabled, setting this flag does nothing.r   F)r\   rf   rr   r]   hiddenAutoscaling)r   z--autoscaling-min-nodesz,The minimum number of nodes for autoscaling.NAUTOSCALING_MIN_NODESz--autoscaling-max-nodesz,The maximum number of nodes for autoscaling.AUTOSCALING_MAX_NODESz--autoscaling-cpu-targetzYThe target CPU utilization percentage for autoscaling. Accepted values are from 10 to 80.AUTOSCALING_CPU_TARGETz--autoscaling-storage-targetzThe target storage utilization gibibytes per node for autoscaling. Accepted values are from 2560 to 5120 for SSD clusters and 8192 to 16384 for HDD clusters.AUTOSCALING_STORAGE_TARGET)rM   r   r   r^   rl   )	r&   r]   num_nodes_requirednum_nodes_defaultadd_disable_autoscaling&require_all_essential_autoscaling_argsscaling_groupmanual_scaling_groupautoscaling_groups	            r   AddScalingArgszArgAdder.AddScalingArgs  sA    KK<<h<OM(223CD%%(!# &  ''
!  (  &//e/L""!;7' #  ""!;7' #  """) 7( # 
 ""&* , #  Kr)   c                 *    | j                  ddd      S )r   T)r]   r   r   r   rV   s    r   AddScalingArgsForClusterUpdatez'ArgAdder.AddScalingArgsForClusterUpdateh  s!    $   r)   c                 (    | j                  dd      S )r   r;   T)r   r   r   rV   s    r   AddScalingArgsForClusterCreatez'ArgAdder.AddScalingArgsForClusterCreaten  s    D   r)   c           	          | j                   j                  ddt        j                  d      |t	        j
                         t        j                  d       | S )z&Add argument group for tags to parser.z--tagsz	KEY=VALUEaD              List of tags KEY=VALUE pairs to bind.
            Each item must be specified in either ID
            `<tag_key_id>=<tag_value_id>`
            or namespace format
            `<tag-key-namespaced-name>=<tag-value-short-name>`.
            Example: `123/environment=production,123/costCenter=marketing`
        T)r   r\   r]   rk   rf   r   )rM   r^   r   r   r   r   UpdateActionr   s     r   AddTagszArgAdder.AddTagst  sT    KK__     "''    Kr)   F)TTFN)T)FFNFF)r+   r,   r-   __doc__r$   rR   rW   r_   rh   rm   rv   ry   r   r   r   r   r   r   r   boolr   r   r   r   r   r   r   r   r   r   r"   r)   r   rJ   rJ   o   s    ;&&	, MQ0 .`4 	D 	Tl!F<@ #-2IVr)   rJ   c                  0    t        j                  dd      S )Nr   z%Bigtable instance for the {resource}.r   r   r    ResourceParameterAttributeConfigr"   r)   r   InstanceAttributeConfigr     s    		2	2!H
 r)   c                  0    t        j                  dd      S )Ntablez"Bigtable table for the {resource}.r   r   r"   r)   r   TableAttributeConfigr     s    		2	2B
 r)   c                  0    t        j                  dd      S )Nclusterz$Bigtable cluster for the {resource}.r   r   r"   r)   r   ClusterAttributeConfigr    s    		2	2 F
 r)   c                  0    t        j                  dd      S )Napp profilez0Bigtable application profile for the {resource}.r   r   r"   r)   r   AppProfileAttributeConfigr    s    		2	2B
 r)   c                  0    t        j                  dd      S )Nbackupz#Bigtable backup for the {resource}.r   r   r"   r)   r   BackupAttributeConfigr    s    		2	2D
 r)   c                  .    t        j                  d      S )Nr   )r   r   r"   r)   r   KmsKeyAttributeConfigr	    s    		2	2		BBr)   c                  0    t        j                  dd      S )Nkms-keyringz%The KMS keyring id of the {resource}.r   r   r"   r)   r   KmsKeyringAttributeConfigr    s    		2	2$K
 r)   c                  0    t        j                  dd      S )Nkms-locationz&The Cloud location for the {resource}.r   r   r"   r)   r   KmsLocationAttributeConfigr    s    		2	2%M
 r)   c                  0    t        j                  dd      S )Nkms-projectz(The Cloud project id for the {resource}.r   r   r"   r)   r   KmsProjectAttributeConfigr    s    		2	2$N
 r)   c                  b    t        j                  ddt               t         j                  d      S )z:Return the resource specification for a Bigtable instance.r4   r   Fresource_nameinstancesId
projectsIddisable_auto_completersr   ResourceSpecr    DEFAULT_PROJECT_ATTRIBUTE_CONFIGr"   r)   r   GetInstanceResourceSpecr    s-    			()+::#
 r)   c                  t    t        j                  ddt               t               t         j                  d      S )z7Return the resource specification for a Bigtable table.r8   r   F)r  tablesIdr  r  r  )r   r  r   r   r  r"   r)   r   GetTableResourceSpecr    s3    			/#%)+::#
 r)   c                  t    t        j                  ddt               t               t         j                  d      S )z9Return the resource specification for a Bigtable cluster.r   r   F)r  
clustersIdr  r  r  )r   r  r  r   r  r"   r)   r   GetClusterResourceSpecr"    s3    			1'))+::#
 r)   c                  b    t        j                  ddt               t         j                  d      S )z=Return the resource specification for a Bigtable app profile.z,bigtableadmin.projects.instances.appProfilesr  Fr  r  r"   r)   r   GetAppProfileResourceSpecr$    s-    			4!)+::#
 r)   c                  b    t        j                  ddt               t         j                  d      S )z>Return the resource specification for a Bigtable logical view.z-bigtableadmin.projects.instances.logicalViewszlogical viewFr  r  r"   r)   r   GetLogicalViewResourceSpecr&    s-    			5")+::#
 r)   returnc                  b    t        j                  ddt               t         j                  d      S )zCReturn the resource specification for a Bigtable materialized view.z2bigtableadmin.projects.instances.materializedViewszmaterialized viewFr  r  r"   r)   r   GetMaterializedViewResourceSpecr)    s-    			:')+::#
 r)   c            	      z    t        j                  ddt               t               t	               t               d      S )Nz/cloudkms.projects.locations.keyRings.cryptoKeyskeyF)r  cryptoKeysId
keyRingsIdlocationsIdr  r  )r   r  r	  r  r  r  r"   r)   r   GetKmsKeyResourceSpecr/    s6    			7(**,,.*,#
 r)   c            	          t        j                  ddt               t               t	               t         j
                  d      S )Nz1bigtableadmin.projects.instances.clusters.backupsr  F)r  	backupsIdr!  r  r  r  )r   r  r  r  r   r  r"   r)   r   GetBackupResourceSpecr2    s9    			9%''))+::#
 r)   c                     t         j                  j                  |rdndt               dj	                  |      |d      j                  |        y)z0Add --instances resource argument to the parser.r   r   zThe instances {}.Tr]   pluralNr   ConceptParserForResourcer  r   rU   rM   r   r   s      r   AddInstancesResourceArgr:    sH    ++jM  & ,  Kr)   c                     t         j                  j                  |rdndt               dj	                  |      |d      j                  |        y)z/Add --instance resource argument to the parser.r   r   The instance {}.Fr4  Nr6  )rM   r   r   r]   s       r   AddInstanceResourceArgr=  &  sH    ++jL% ,  Kr)   c                     t         j                  j                  |rdndt               dj	                  |      dd      j                  |        y)z,Add --table resource argument to the parser.r   r   zThe table {}.TFr4  N)r   r7  r8  r  r   rU   r9  s      r   AddTableResourceArgr?  1  sH    ++gT" ,  Kr)   c                     t         j                  j                  dt               dj	                  |      d      j                  |        y)z7Add cluster positional resource argument to the parser.r   The cluster {}.Tr   N)r   r7  r8  r"  r   rU   rM   r   s     r   AddClusterResourceArgrC  <  sA    ++t$	 , 
 Kr)   c                     t         j                  j                  dt               dj	                  |      d      j                  |        y)z;Add app profile positional resource argument to the parser.app_profilezThe app profile {}.Tr   N)r   r7  r8  r$  r   rU   rB  s     r   AddAppProfileResourceArgrF  F  sA    ++!""4(	 , 
 Kr)   c                     t         j                  j                  dt               d| dd      j	                  |        y)z<Add logical view positional resource argument to the parser.logical_viewzThe logical view .Tr   N)r   r7  r8  r&  rU   rB  s     r   AddLogicalViewResourceArgrJ  P  s?    ++ "$q!	 , 
 Kr)   r   c                     t         j                  j                  dt               d| dd      j	                  |        y)zAAdd materialized view positional resource argument to the parser.materialized_viewzThe materialized view rI  Tr   N)r   r7  r8  r)  rU   rB  s     r   AddMaterializedViewResourceArgrM  Z  s?    ++%'tfA&	 , 
 Kr)   c                    t        j                  t        j                  dt	               dj                  |      d      t        j                  dt               dj                  |      dddi	      g      j                  |        y
)z6Add backup positional resource argument to the parser.r   r<  Fr   rY   rA  r    r]   flag_name_overridesN)r   r7  r   ResourcePresentationSpecr  r   r"  rU   rB  s     r   AddBackupResourceArgrS  d  s{    11

!
#

#
#D
)	 11

 
"

"
"4
()2.!  [r)   c                    t         j                  j                  d      }t         j                  j                  d      }t        j                  ddddddid|j                               t        j                  d	d
dddd
id|j                               g}dgdgd}t        j                  ||      j                  |        y)zBAdd Table resource args (source, destination) for restore command.zbigtable.tablezbigtable.backupzto restore fromsourceTr  F)r   r   r]   prefixesattribute_overridesr   resource_datazto restore todestinationr   --destination.instance--source.instance)r[  rZ  N)	r   ResourceYAMLDataFromPathr   GetResourcePresentationSpecGetDatar   r7  rU   )rM   table_spec_databackup_spec_data	arg_specsfallthroughss        r   AddTableRestoreResourceArgrd  w  s    ..778HI///889JK // '2(002 //&6'//1)* 55!4 5, 	<8DDVLr)   c                     t         j                  j                  dt               dj	                  |      ||      j                  |        y)a	  Add a resource argument for a KMS key.

  Args:
    parser: the parser for the command.
    resource: str, the name of the resource that the cryptokey will be used to
      protect.
    flag_overrides: dict, The default flag names are 'kms-key', 'kms-keyring',
      'kms-location' and 'kms-project'. You can pass a dict of overrides where
      the keys of the dict are the default flag names, and the values are the
      override names.
    required: bool, optional. True if the flag must be parsable by the parser.
  z	--kms-keyzUThe Cloud KMS (Key Management Service) cryptokey that will be used to protect the {}.)rQ  r]   N)r   r7  r8  r/  r   rU   )rM   r   flag_overridesr]   s       r   AddKmsKeyResourceArgrg    sG     ++x(( ,  Kr)   c                     | j                   j                  j                         }|r|j                         S dD ]5  }t	        | |j                  dd      d      s!t        j                  dd       y)zDParse the KMS key resource arg, make sure the key format is correct.)r   r  r  r  r   r   Nz4--kms-project --kms-location --kms-keyring --kms-keyzSpecify fully qualified KMS key ID with --kms-key, or use combination of --kms-project, --kms-location, --kms-keyring and --kms-key to specify the key ID in pieces.)CONCEPTSkms_keyParseRelativeNamegetattrr   r   rD   )rE   kms_refkeywords      r   GetAndValidateKmsKeyNamerp    sq    MM!!'')'!! M	wsC0$	711B;
 	
 M r)   c                 |    | j                  ddt        j                  j                  dj	                  |             y )Nz--start-timeFz^Start time of the time range {}. See $ gcloud topic datetimes for information on time formats.r]   rk   r\   r^   r   Datetimerk  r   rB  s     r   AddStartTimeArgsru    s9    %%J6$<  	r)   c                 |    | j                  ddt        j                  j                  dj	                  |             y )Nz
--end-timeFz\End time of the time range {}. See $ gcloud topic datetimes for information on time formats.rr  rs  rB  s     r   AddEndTimeArgsrw    s9    %%J6$<  	r)   c                     t        j                  dt               ddddddd	      t        j                  d
t               ddddddd	      g}dgdgdgdgd}t        j                  ||      j                  |        y)z@Add backup resource args (source, destination) for copy command.z--sourcezThe source backup to copy from.Tz--source-projectz--source-instancez--source-clusterz--source-backup)projectr   r   r  rP  z--destinationz"The destination backup to copy to.z--destination-projectz--destination-instancez--destination-clusterz--destination-backup--destination.project--source.projectrZ  r[  )r{  rz  r[  rZ  N)r   rR  r2  r   r7  rU   )rM   rb  rc  s      r   AddCopyBackupResourceArgsr|    s     11


!
++-+)	 11


!
.020.	)6 33 2345!4 5	, 	<8DDVLr)   r   )FT)NF)@r   r   googlecloudsdk.api_lib.bigtabler   googlecloudsdk.callioper   r   r   r    googlecloudsdk.calliope.conceptsr   googlecloudsdk.command_lib.utilr	   $googlecloudsdk.command_lib.util.apisr
   r   $googlecloudsdk.command_lib.util.argsr   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.core.utilr   r   ListCommandCompleterr   r2   r6   rH   objectrJ   r   r   r  r  r  r	  r  r  r  r  r  r"  r$  r&  r  r)  r/  r2  r:  r=  r?  rC  rF  rJ  r   rM  rS  rd  rg  rp  ru  rw  r|  r"   r)   r   <module>r     s>   7  0 + / ( . 5 6 : : > D G )z66 
77 Z44 #LWv WtC
		)>)> 		  &M@.$

"Mr)   