
    
                         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	 e	j                   G d d	e	j                               Zy
)z'logging views create' command.    )absolute_import)division)unicode_literals)util)arg_parsers)basec                   &    e Zd ZdZed        Zd Zy)CreatezCreate a log view on a log bucket.

  ## EXAMPLES

  To create a view that matches all Google Compute Engine logs in a bucket, run:

    $ {command} my-view --bucket=my-bucket --location=global
    --log-filter='resource.type="gce_instance"'
  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 create.)helpz--descriptionz#A textual description for the view.z--log-filterzA filter for the view.zview to createTz/Location of the bucket that will hold the view.z--bucketz.+zmust be non-emptyz(ID of the bucket that will hold the view)requiredtyper   N)add_argumentr   AddParentArgsAddBucketLocationArgr   RegexpValidator)parsers    #lib/surface/logging/views/create.pyArgszCreate.Args(   s     	(CD
C   -EFv/0G ((0CD7	      c                    i }|j                  d      r|j                  |d<   |j                  d      r|j                  |d<   t        j                         j
                  j                  t        j                         j                  |j                  t        j                  t        j                  |      d|j                         t        j                         j                  di |            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 created view.
    description
log_filterfilterbuckets)viewIdparentlogView )IsSpecifiedr   r   r   	GetClient projects_locations_buckets_viewsr
   GetMessages1LoggingProjectsLocationsBucketsViewsCreateRequestr   CreateResourceNameGetBucketLocationFromArgsbucketLogView)selfargs	view_datas      r   Runz
Create.Run;   s     I&!%!1!1i% OOi>><<CCLL<<**..t4i /D$$&..;; 	M 	
 r   N)__name__
__module____qualname____doc__staticmethodr   r-   r    r   r   r
   r
      s       $r   r
   N)r1   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   UniverseCompatibleCreateCommandr
   r    r   r   <module>r8      sC     & &  ' / / ( 7T 7 7r   