
    h                     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 create' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)logz          Create a logs-based metric to count the number of log entries that
          match a filter expression. Logs-based metrics can also be used to
          extract values from logs and create a distribution of the values.
      a            To create a metric that counts the number of log entries with a
          severity level higher than WARNING, run:

            $ {command} high_severity_count --description="Number of high severity log entries" --log-filter="severity > WARNING"

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

          To create a metric that uses advanced features like distribution or
          user-defined labels, run:

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

          The config file can be in YAML or JSON 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).

          To create a bucket log-based metric, run:

            $ {command} my_bucket_metric --description="DESCRIPTION" --log-filter="LOG_FILTER" --bucket-name="BUCKET_NAME"
      )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)Create;   zCreate 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S9  UR                  SS[        R                  " 5       S9  g)z Register flags for this command.metric_namezThe name of the new metric.)helpzData about the new metric.T)r   mutexrequiredzCA group of arguments to specify simple counter logs-based metrics. z--descriptionzThe metric's description.)r   r   z--log-filterzThe metric's filter expression.z--bucket-namez4The Log Bucket name which owns the log-based metric.z--config-from-filezIA path to a YAML or JSON file specifying the logs-based metric to create.)r   typeN)add_argumentadd_argument_groupr   FileContents)parserconfig_grouplegacy_mode_groups      %lib/surface/logging/metrics/create.pyArgsCreate.Args@   s     ,IJ,,2N376: - .L %77 8  ""$) # + ""/ # 1 ""C # E 2%G#.#;#;#=  ?    c                    [         R                  " 5       n[         R                  " UR                  UR                  UR
                  UR                  UR                  S9nUR                  [         R                  " 5       US9n[         R                  " 5       R                  R                  U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 created metric.
)r   description
log_filterbucket_namedata)parent	logMetric)r   GetMessagesCreateLogMetricr   r    r!   r"   config_from_file#LoggingProjectsMetricsCreateRequestGetCurrentProjectParent	GetClientprojects_metricsr   r	   CreatedResource)selfargsmessages
new_metricrequestresults         r   Run
Create.RunY   s     !H%%$$$$??$$""$J ::++- ; EG^^..55g>F(()Mr    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r4   __static_attributes__r6   r   r   r   r   ;   s     $? ?0r   r   N)r;   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   DETAILED_HELPReleaseTracksReleaseTrackGABETAALPHACreateCommandr   detailed_helpr6   r   r   <module>rJ      s     ( &  ' / / ( #	
	
@ D%%(($*;*;*@*@%%++-2T 2-2j % r   