
                             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  \R                   " S
 S\R                  5      5       rSSS.\l        g)z'logging write' command.    )absolute_import)division)unicode_literals)encoding)util)arg_parsers)base)logc                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)	Write   zWrite a log entry.)	DEFAULTDEBUGINFONOTICEWARNINGERRORCRITICALALERT	EMERGENCY)textjsonc                 b   U R                  SSS9  U R                  SSS9  U R                  S[        R                  SSS	9  U R                  S
S[        R                  SSS9  U R                  SSSS9  U R                  S[        R
                  " 5       S0 SS9  [        R                  " U S5        g)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Args
Write.Args&   s      (  *  F  H ""F.  1 u##Y/  1 #<  
 %  " >   	v56    c                 "   [         R                  " 5       n[        UR                  R                  UR
                  R                  5       5      nUR                  UR                  S9nUR                  (       a:  [        R                  " UR                  R                  UR                  5      Ul        UR                  [         R                  " [         R                  " U5      UR                   5      UUS9nUR"                  S:X  a  [         R$                  " UR&                  5      nUR                  R)                  5       nUR*                   Vs/ s H;  nUR                  R(                  R-                  UR.                  UR0                  S9PM=     snUl        Xul        OUR&                  Ul        [         R8                  " 5       R:                  R=                  UR?                  U/S95        [@        RB                  RE                  S5        gs  snf )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SeverityValueValuesEnumr0   upperMonitoredResourcemonitored_resource_typemonitored_resource_labelsr   PyValueToMessageLabelsValuelabelsCreateLogResourceNameGetParentFromArgsr   payload_typeConvertToJsonObjectr   JsonPayloadValue
propertiesAdditionalPropertyr1   r2   additionalPropertiesjsonPayloadtextPayload	GetClientr3   r   WriteLogEntriesRequestr
   statuswrite)	selfargsmessagesseverity_valuemonitored_resourceentryjson_objectstructjson_propertys	            r)   Run	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NN""'''8:JJ+,%s   AH N)__name__
__module____qualname____firstlineno____doc__r%   r$   staticmethodr*   rV   __static_attributes__rX   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)r]   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r	   googlecloudsdk.corer
   UniverseCompatibleSilentCommandr   detailed_helprX   r,   r)   <module>rj      sa      &  ' % / / ( # V-D V- V-r	 r,   