
    {                         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
dZe	j                   G d de	j                               Zee_        y)z'logging views update' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)
exceptionsz/
        Updates the properties of a view.
    z
     To update a view in your project, run:

        $ {command} my-view --bucket=my-bucket --location=global
     --description=my-new-description
    )DESCRIPTIONEXAMPLESc                   &    e Zd ZdZed        Zd Zy)UpdatezKUpdate a view.

  Changes one or more properties associated with a view.
  c                 "   | j                  dd       | j                  dd       | j                  dd       t        j                  | d       t        j                  | d	d
       | j                  dd	t	        j
                  dd      d       y)z Register flags for this command.VIEW_IDzId of the view to update.)help--descriptionzNew description for the view.--log-filterzNew filter for the view.zview to updateTz.Location of the bucket that contains the view.z--bucketz.+zmust be non-emptyz$ID of the bucket that holds the view)requiredtyper   N)add_argumentr   AddParentArgsAddBucketLocationArgr   RegexpValidator)parsers    #lib/surface/logging/views/update.pyArgszUpdate.Args/   s     3  5
,  . '  ) 	v/0FH
T((0CD3  5    c                    i }g }ddg}|j                  d      r |j                  |d<   |j                  d       |j                  d      r |j                  |d<   |j                  d       |st	        j
                  |d      t        j                         j                  j                  t        j                         j                  t        j                  t        j                  t        j                  t        j                  |j                        j                         d|j                         d|j"                        d	|j$                         t        j                         j&                  di |d
j)                  |                  S )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 view.
    r   r   
log_filterfilterdescriptionz.Please specify at least one property to update	locationsbucketsviews,)namelogView
updateMask )IsSpecifiedr   appendr    calliope_exceptionsMinimumArgumentExceptionr   	GetClient projects_locations_buckets_viewsPatchGetMessages0LoggingProjectsLocationsBucketsViewsPatchRequestCreateResourceNameGetProjectResourceprojectRelativeNamelocationbucketr   LogViewjoin)selfargs	view_dataupdate_maskparameter_namess        r   Runz
Update.RunB   sX    IK%7O% OOi"&!%!1!1i'88

:< < >><<BBKK(()@)@''++DLL9FFHMM# 4;;*(
 *1$,,@ /D$$&..;;xx, 	L 	.	/ 	/r   N)__name__
__module____qualname____doc__staticmethodr   r?   r(   r   r   r   r   (   s     
 5 5$"/r   r   N)rC   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   r	   r+   DETAILED_HELPUniverseCompatibleUpdateCommandr   detailed_helpr(   r   r   <module>rL      sb     & &  ' / / ( E	
 ;/T ;/ ;/z % r   