
                         D   S 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
S.r\	R                  " \	R                  R                  \	R                  R                   \	R                  R"                  5       " S S\	R$                  5      5       r\\l        g)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                   .    \ rS rSrSr\S 5       rS rSrg)Update?   z-Update the definition of a logs-based metric.c                    U R                  SSS9  U R                  SSSS9nUR                  SS9nUR                  SS	S
S9  UR                  SS	SS9  UR                  SS[        R                  " 5       S9  UR                  SSS9  g)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ArgsUpdate.ArgsD   s     I  K ,,/td - LL$77 8 ! ""< # >
 ""7 # 9
  %%'  ) ""C # E    c           	         [         R                  " 5       R                  R                  [         R                  " 5       R                  [         R                  " [         R                  " 5       SUR                  5      S95      n[         R                  " UUR                  UR                  UR                  UR                  S9n[         R                  " 5       R                  R                  [         R                  " 5       R                  [         R                  " [         R                  " 5       SUR                  5      US95      n[         R"                  " UR                  5        U$ )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   Run
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____firstlineno____doc__staticmethodr   r7   __static_attributes__r9   r   r   r   r   ?   s      6E E>r   r   N)r>   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   DETAILED_HELPReleaseTracksReleaseTrackGABETAALPHAUpdateCommandr   detailed_helpr9   r   r   <module>rM      s     ( &  ' / / ( #	

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