
                         D   d 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
dZ e	j                  e	j                  j                  e	j                  j                   e	j                  j"                         G d de	j$                               Zee_        y)z!'logging metrics update' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)logzl          Update the description or the filter expression of an existing
          logs-based metric.
      a            To update the description of a metric called high_severity_count, run:

            $ {command} high_severity_count --description="Count of high-severity log entries."

          To update the filter expression of the metric, run:

            $ {command} high_severity_count --log-filter="severity >= WARNING"

          Detailed information about filters can be found at:
          [](https://cloud.google.com/logging/docs/view/logging-query-language)

          For advanced features such as user-defined labels and distribution
          metrics, update using a config file:

            $ {command} high_severity_count --config-from-file=$PATH_TO_FILE

          The config file should be in YAML format. Detailed information about
          how to configure metrics can be found at: [](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric).
          Any top-level fields in the LogMetric definition that aren't specified
          in the config file will not be updated in the metric.

          To update the bucket associated with a bucket log-based metric, run:

            $ {command} my-bucket-metric --bucket-name="NEW_BUCKET_NAME"
      )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)Updatez-Update the definition of a logs-based metric.c                 8   | j                  dd       | j                  ddd      }|j                  d      }|j                  dd	d
       |j                  dd	d       |j                  ddt        j                                |j                  dd       y)z Register flags for this command.metric_namez+The name of the log-based metric to update.)helpz Data about the metric to update.T)r   mutexrequiredzIArguments to specify information about simple counter logs-based metrics.z--descriptionFzMA new description for the metric. If omitted, the description is not changed.)r   r   z--log-filterzJA new filter string for the metric. If omitted, the filter is not changed.z--config-from-filezQA path to a YAML file specifying the updates to be made to the logs-based metric.)r   typez--bucket-namez4The Log Bucket name which owns the log-based metric.N)add_argumentadd_argument_groupr   FileContents)parserconfig_grouplegacy_mode_groups      %lib/surface/logging/metrics/update.pyArgszUpdate.ArgsD   s     I  K ,,/td - LL$77 8 ! ""< # >
 ""7 # 9
  %%'  ) ""C # E    c           	         t        j                         j                  j                  t        j                         j                  t        j                  t        j                         d|j                                    }t        j                  ||j                  |j                  |j                  |j                        }t        j                         j                  j                  t        j                         j                  t        j                  t        j                         d|j                        |            }t!        j"                  |j                         |S )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.

    Returns:
      The updated metric.
    metrics)
metricName)description
log_filterbucket_namedata)r   	logMetric)r   	GetClientprojects_metricsGetGetMessages LoggingProjectsMetricsGetRequestCreateResourceNameGetCurrentProjectParentr   UpdateLogMetricr    r!   r"   config_from_filer   #LoggingProjectsMetricsUpdateRequestr	   UpdatedResource)selfargsmetricupdated_metricresults        r   Runz
Update.Rund   s    ^^..22;;..t/K/K/M/8$:J:JL 	< 	MNF
 ))$$??$$""$N ^^..55>>..t/K/K/M/8$:J:JL$ 	? 	&'F
 (()Mr   N)__name__
__module____qualname____doc__staticmethodr   r5    r   r   r   r   ?   s      6E E>r   r   N)r9   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   DETAILED_HELPReleaseTracksReleaseTrackGABETAALPHAUpdateCommandr   detailed_helpr;   r   r   <module>rH      s     ( &  ' / / ( #	

	
!H D%%(($*;*;*@*@%%++-BT B-BJ % r   