
                         @   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddl
mZ dd	lmZ dd
lmZ  ej                   ej"                  j$                  ej"                  j&                  ej"                  j(                         G d dej*                               Zy)zbigtable hottablets command.    )absolute_import)division)unicode_literalsN)
list_pager)util)base)	arguments)timesc                   N    e Zd ZdZd ej
                  d      iZed        Zd Z	y)ListHotTabletsz-List hot tablets in a Cloud Bigtable cluster.EXAMPLESa              Search for hot tablets in the past 24 hours:

              $ {command} my-cluster-id --instance=my-instance-id

            Search for hot tablets with start and end times by minute:

              $ {command} my-cluster-id --instance=my-instance-id --start-time="2018-08-12 03:30:00" --end-time="2018-08-13 17:00:00"

            Search for hot tablets with start and end times by day:

              $ {command} my-cluster-id --instance=my-instance-id --start-time=2018-01-01 --end-time=2018-01-05
          c                     t        j                  | d       t        j                  | d       t        j                  | d       | j                  j                  d       y)z Register flags for this command.zto list hot tablets forzto search for hot tabletsa[  
      table(
        tableName.basename():label=TABLE,
        nodeCpuUsagePercent:label=CPU_USAGE:sort=1:reverse,
        startTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'):label=START_TIME,
        endTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'):label=END_TIME,
        startKey:label=START_KEY,
        endKey:label=END_KEY
      )
    N)r	   AddClusterResourceArgAddStartTimeArgsAddEndTimeArgsdisplay_info	AddFormat)parsers    (lib/surface/bigtable/hot_tablets/list.pyArgszListHotTablets.Args5   sR     ##F,EFv'BCV%@A
 !! 	# 		    c              #     K   t        j                         }|j                  j                  j	                         }t        j
                         j                  |j                         |j                  xr t        j                  |j                        |j                  xr t        j                  |j                              }t        j                  |j                  |dd      D ]  }|  yw)zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Yields:
      Some value that we want to have printed later.
    )parent	startTimeendTime
hotTabletsN)fieldbatch_size_attribute)r   GetAdminClientCONCEPTSclusterParseGetAdminMessages;BigtableadminProjectsInstancesClustersHotTabletsListRequestRelativeName
start_timer
   FormatDateTimeend_timer   YieldFromList&projects_instances_clusters_hotTablets)selfargsclicluster_refmsg
hot_tablets         r   RunzListHotTablets.RunJ   s      


C--''--/K 		D	D++-ooO%*>*>t*OMMIe&:&:4==&I 
E 
K  !..22!	#

 #s   C0C2N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r1    r   r   r   r      s?     6 
(//  -" 	 	(r   r   )r5   
__future__r   r   r   r6   apitools.base.pyr   googlecloudsdk.api_lib.bigtabler   googlecloudsdk.callioper   #googlecloudsdk.command_lib.bigtabler	   googlecloudsdk.core.utilr
   ReleaseTracksReleaseTrackGABETAALPHAListCommandr   r:   r   r   <module>rG      s    # &  '  ' 0 ( 9 * D%%(($*;*;*@*@%%++-ET%% E-Er   