
                             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	KJr  SS
KJr   " S S\R                   5      rg)z1The gcloud error-reporting events report command.    )absolute_import)division)unicode_literals)util)base)
exceptions)log)
properties)filesc                   :    \ rS rSrSr\S 5       rS rS rS r	Sr
g)	Report   a  Report an error.

{command} is used to report errors using the error-reporting service.
The required arguments are a service name and either an
error-file containing details of an error or an inline error message.

The error message must contain a header (typically consisting of the
exception type name and an error message) and an exception stack trace in one
of the supported programming languages and formats. Details about supported
languages and formats can be found at
https://cloud.google.com/error-reporting/docs/formatting-error-messages

## EXAMPLES

To report an error, run:

  $ {command} --service=SERVICE_NAME --message="Error message"

or:

  $ {command} --service=SERVICE_NAME --message-file=ERROR_MESSAGE.EXT
c                     U R                  SSSS9  U R                  SSS9  U R                  SS9nUR                  S	S
S9  UR                  SSS9  g)zgGet arguments for this command.

Args:
  parser: argparse.ArgumentParser, the parser for this command.
z	--serviceTz0The name of the service that generated the error)requiredhelpz--service-versionz"The release version of the service)r   r   z	--messagezInline details of the errorz--message-filez$File containing details of the errorN)add_argumentadd_mutually_exclusive_group)parsergroups     ,lib/surface/error_reporting/events/report.pyArgsReport.Args6   s     ?  A 1  3
 ///>E	*  , 
3  5    c                 &   SnUR                   (       a#   [        R                  " UR                   5      nU$ UR                  (       a  UR                  nU$ ! [        R                   a&  n[        R
                  " UR                   U5      eSnAff = f)zGet error message.

Args:
  args: the arguments for the command

Returns:
  error_message read from error file or provided inline

Raises:
  CannotOpenFileError: When there is a problem with reading the file
 N)message_filer   ReadFileContentsErrorr   CannotOpenFileErrormessage)selfargserror_messagees       r   
GetMessageReport.GetMessageN   s     MC..t/@/@A
  
llm	 [[ C,,T->->BBCs    A B*!BBc                 d    [         R                  R                  R                  R	                  SS9$ )zGet project name.Tr   )r
   VALUEScoreprojectGet)r"   r#   s     r   
GetProjectReport.GetProjectd   s(    !!))--t-<<r   c                    U R                  U5      nUR                  nUR                  nU R                  U5      n[        R
                  " 5       nUR                  X#XE5        [        R                  R                  S5        g)z-Send an error report based on the given args.zYour error has been reported.N)
r&   serviceservice_versionr-   r   ErrorReportingReportEventr	   statusPrint)r"   r#   r$   r0   r1   r+   error_events          r   Run
Report.Runh   sg     OOD)MllG**Oood#G %%'KMOMJJ45r    N)__name__
__module____qualname____firstlineno____doc__staticmethodr   r&   r-   r7   __static_attributes__r9   r   r   r   r      s*    . 5 5.,=6r   r   N)r>   
__future__r   r   r   &googlecloudsdk.api_lib.error_reportingr   googlecloudsdk.callioper   *googlecloudsdk.command_lib.error_reportingr   googlecloudsdk.corer	   r
   googlecloudsdk.core.utilr   Commandr   r9   r   r   <module>rH      s7     8 &  ' 7 ( A # * *X6T\\ X6r   