
                             S r SSKJr  SSKJr  SSKJr  SSKJr  S rS r    SS	 jr	    SS
 jr
       SS jr      SS jrg)zBigtable clusters API helper.    )absolute_import)division)unicode_literals)utilc                     [         R                  " 5       n[         R                  " 5       nUR                  U R	                  5       S9nUR
                  R                  U5        g)zWDelete a cluster.

Args:
  cluster_ref: A resource reference to the cluster to delete.
)nameN)r   GetAdminClientGetAdminMessages3BigtableadminProjectsInstancesClustersDeleteRequestRelativeNameprojects_instances_clustersDelete)cluster_refclientmsgsmsgs       /lib/googlecloudsdk/api_lib/bigtable/clusters.pyr   r      sV      &				 $@@##% 	A 	'#$$++C0    c                    [         R                  " 5       n[         R                  " 5       nUR                  UU R	                  5       U R                  5       R                  5       S9nUR                  R                  U5      $ )zCreate a cluster.

Args:
  cluster_ref: A resource reference to the cluster to create.
  cluster: A Cluster msg object to create.

Returns:
  Long running operation.
)cluster	clusterIdparent)	r   r	   r
   3BigtableadminProjectsInstancesClustersCreateRequestNameParentr   r   Create)r   r   r   r   r   s        r   r   r   %   ss      &				 $@@  "!..0 	A 	2# 
	+	+	2	23	77r   Nc                     [         R                  " 5       nUR                  XS9nUR                  UUS9nUR	                  XVS9$ )z'Build a ClusterAutoscalingConfig field.)minServeNodesmaxServeNodes)cpuUtilizationPercentstorageUtilizationGibPerNode)autoscalingLimitsautoscalingTargets)r   r
   AutoscalingLimitsAutoscalingTargetsClusterAutoscalingConfig)	min_nodes	max_nodes
cpu_targetstorage_targetr   limitstargetss          r   BuildClusterAutoscalingConfigr-   8   sb    
 
			 $!! " 8&##&#1 $ 3' 
	&	& 
' 
< <r   c           	      ^    [         R                  " 5       nUR                  [        U UUUS9S9$ )zBuild a ClusterConfig field.)r'   r(   r)   r*   )clusterAutoscalingConfig)r   r
   ClusterConfigr-   )autoscaling_minautoscaling_maxautoscaling_cpu_targetautoscaling_storage_targetr   s        r   BuildClusterConfigr5   G   s>    
 
			 $			<##+3	 5 
 
6 6r   c                 z    U R                  XS9nUc	  Uc  Uc  Ub  [        UUUUS9Ul        U R                  XUS9$ )z$Build a PartialUpdateClusterRequest.)r   
serveNodes)r1   r2   r3   r4   )r   r   
updateMask)Clusterr5   clusterConfigABigtableadminProjectsInstancesClustersPartialUpdateClusterRequest)	r   r   nodesr1   r2   r3   r4   update_maskr   s	            r    BuildPartialUpdateClusterRequestr>   U   sd     LLdL5'!_%@( ,.''5#=	?G 
	O	O[ 
P 
: :r   c                 T   [         R                  " 5       n[         R                  " 5       nU(       aJ  Uc	  Uc  Uc  Ub  [        S5      eUR                  R                  [        UU R                  5       USS95      $ / n	Ub  U	R                  S5        Ub  U	R                  S5        Ub  U	R                  S5        Ub  U	R                  S5        Ub  U	R                  S5        S	R                  U	5      n
UR                  R                  [        UU R                  5       UUUUUU
S
95      $ )a  Partially update a cluster.

Args:
  cluster_ref: A resource reference to the cluster to update.
  nodes: int, the number of nodes in this cluster.
  autoscaling_min: int, the minimum number of nodes for autoscaling.
  autoscaling_max: int, the maximum number of nodes for autoscaling.
  autoscaling_cpu_target: int, the target CPU utilization percent for
    autoscaling.
  autoscaling_storage_target: int, the target storage utilization gibibytes
    per node for autoscaling.
  disable_autoscaling: bool, True means disable autoscaling if it is currently
    enabled. False means change nothing whether it is currently enabled or
    not.

Returns:
  Long running operation.
zEautoscaling arguments cannot be set together with disable_autoscalingz5serve_nodes,cluster_config.cluster_autoscaling_config)r   r   r<   r=   serve_nodeszLcluster_config.cluster_autoscaling_config.autoscaling_limits.min_serve_nodeszLcluster_config.cluster_autoscaling_config.autoscaling_limits.max_serve_nodeszUcluster_config.cluster_autoscaling_config.autoscaling_targets.cpu_utilization_percentz^cluster_config.cluster_autoscaling_config.autoscaling_targets.storage_utilization_gib_per_node,)r   r   r<   r1   r2   r3   r4   r=   )
r   r	   r
   
ValueErrorr   PartialUpdateClusterr>   r   appendjoin)r   r<   r1   r2   r3   r4   disable_autoscalingr   r   changed_fieldsr=   s              r   PartialUpdaterH   m   sS   2  &				 $#'B*". - . .--BB 	)))+O		
  .
-( V  V '_  +h (+		+	+	@	@&'')))!7%?!#	
$ 	$r   )NNNN)NNNNNNN)NNNNNF)__doc__
__future__r   r   r   googlecloudsdk.api_lib.bigtabler   r   r   r-   r5   r>   rH    r   r   <module>rM      s|    $ &  ' 0
18& -1,0-115< (,'+.2266 +/+/5959<@@D15:2 "&"&)--1&+J$r   