
                             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	lmZ ej                   G d
 dej                               Zddde_        y)z'logging write' command.    )absolute_import)division)unicode_literals)encoding)util)arg_parsers)base)logc                   .    e Zd ZdZdZdZed        Zd Zy)WritezWrite a log entry.)	DEFAULTDEBUGINFONOTICEWARNINGERRORCRITICALALERT	EMERGENCY)textjsonc                    | j                  dd       | j                  dd       | j                  dt        j                  dd	       | j                  d
dt        j                  dd       | j                  ddd       | j                  dt	        j
                         di d       t        j                  | d       y)z Register flags for this command.log_namez4Name of the log where the log entry will be written.)helpmessagezUMessage to put in the log entry. It can be JSON if you include `--payload-type=json`.z--payload-typer   zType of the log entry payload.)choicesdefaultr   z
--severityFr   z Severity level of the log entry.)requiredr   r   r   z--monitored-resource-typeglobalz-Monitored Resource type to add to the payload)r   r   z--monitored-resource-labelszKEY=VALUE, ...z/Monitored Resource labels to add to the payload)typemetavarr   r   zlog entries to writeN)add_argumentr   PAYLOAD_TYPESEVERITY_ENUMr   ArgDictr   AddParentArgs)parsers    lib/surface/logging/write.pyArgsz
Write.Args&   s      (  *  F  H ""F.  1 u##Y/  1 #<  
 %  " >   	v56    c                    t        j                         }t        |j                  j                  |j
                  j                               }|j                  |j                        }|j                  r9t        j                  |j                  j                  |j                        |_        |j                  t        j                  t        j                  |      |j                         ||      }|j"                  dk(  rt        j$                  |j&                        }|j                  j)                         }|j*                  D cg c]=  }|j                  j(                  j-                  |j.                  |j0                        ? c}|_        ||_        n|j&                  |_        t        j8                         j:                  j=                  |j?                  |g             t@        jB                  jE                  d       yc c}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.
    )r    )logNameresourceseverityr   )keyvalue)entrieszCreated log entry.
N)#r   GetMessagesgetattrLogEntrySeverityValueValuesEnumr.   upperMonitoredResourcemonitored_resource_typemonitored_resource_labelsr   PyValueToMessageLabelsValuelabelsCreateLogResourceNameGetParentFromArgsr   payload_typeConvertToJsonObjectr   JsonPayloadValue
propertiesAdditionalPropertyr/   r0   additionalPropertiesjsonPayloadtextPayload	GetClientr1   r   WriteLogEntriesRequestr
   statuswrite)	selfargsmessagesseverity_valuemonitored_resourceentryjson_objectstructjson_propertys	            r(   Runz	Write.RunF   s    !HX..FF!]]0024N "33)) 4  %%"*";";

$
$
0
0$2P2P# **""4($--
 $  E F",,T\\:k  113f  +55	%  6m 


,
,
?
?##!'' @ )  6	%f! !e,,eNN""'''8:JJ+,%s   	AH
N)	__name__
__module____qualname____doc__r$   r#   staticmethodr)   rT    r*   r(   r   r      s*    >- ",7 7>.-r*   r   a          {index}
        If the destination log does not exist, it will be created.
        By default, all log entries written with this command are written with
        the "global" resource type.

        {command} should be used for simple testing purposes.
        Check Cloud Logging agent for a proper way to send log entries:
        [](https://cloud.google.com/logging/docs/agent/)
    a&          To create a log entry in a given log, run:

          $ {command} LOG_NAME "A simple entry"

        To create a high severity log entry, run:

          $ {command} LOG_NAME "Urgent message" --severity=ALERT

        To create a structured log, run:

          $ {command} LOG_NAME '{"key": "value"}' --payload-type=json

        To create a log entry with a custom resource type, run:

          $ {command} LOG_NAME "A simple entry" --monitored-resource-type=gce_instance --monitored-resource-labels=zone=us-centra1-a,instance_id=1234
    )DESCRIPTIONEXAMPLESN)rX   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   UniverseCompatibleSilentCommandr   detailed_helprZ   r*   r(   <module>re      sa      &  ' % / / ( # V-D V- V-r	 r*   