
    &                         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  ed	      Zd
 Zej                   G d dej                                Zy)zBCommand to list notification configurations belonging to a bucket.    )absolute_import)division)unicode_literals)base)#notification_configuration_iterator)resource_printer)resource_projectorz//pubsub.googleapis.com/c                 "   |j                   rGd}|j                   j                  D ]+  }|dj                  |j                  |j                        z  }- nd}|j
                  s|j                  rfd}|j
                  r-|dj                  dj                  |j
                              z  }|j                  r!|dj                  |j                        z  }nd}dj                  | j                  |j                  |j                  t        d	 ||
      S )z#Returns pretty notification string.z
	Custom attributes:z	
		{}: {} z

	Filters:z
		Event Types: {}z, z
		Object name prefix: '{}'zzprojects/_/buckets/{bucket}/notificationConfigs/{notification}
	Cloud Pub/Sub topic: {topic}{custom_attributes}{filters}

N)bucketnotificationtopiccustom_attributesfilters)r   additionalPropertiesformatkeyvalueevent_typesobject_name_prefixjoinbucket_nameidr   _PUBSUB_DOMAIN_PREFIX_LENGTH)urlconfigcustom_attributes_string	attributefilters_strings        1lib/surface/storage/buckets/notifications/list.py _get_human_readable_notificationr!      s   7--BB	."7"7
--#  C
  "644#N/66
))F&&
' n   8??

#
# n N))/yy9:;4  *0 *
    c                   6    e Zd ZdZdddZed        Zd Zd Zy)	ListzAList the notification configurations belonging to a given bucket.z
      *{command}* provides a list of notification configurations belonging to a
      given bucket. The listed name of each configuration can be used
      with the delete sub-command to delete that specific notification config.
      aR  
      Fetch the list of notification configs for the bucket `example-bucket`:

        $ {command} gs://example-bucket

      Fetch the notification configs in all buckets matching a wildcard:

        $ {command} gs://example-*

      Fetch all of the notification configs for buckets in the default project:

        $ {command}
      )DESCRIPTIONEXAMPLESc                 V    | j                  ddd       | j                  dddd	       y )
Nurls*zfGoogle Cloud Storage bucket paths. The path must begin with gs:// and may contain wildcard characters.)nargshelpz--human-readable
store_trueTzKPrints notification information in a more descriptive, unstructured format.)actionhiddenr+   )add_argument)parsers    r    Argsz	List.Args`   sC    
:  ;
 $  	r"   c                     |j                   rt        j                  |d       y t        j                  ||j                  xs d       y )Nobjectyaml)human_readabler   Printr   )selfargs	resourcess      r    DisplayzList.Displayr   s4    Y1Y(=v>r"   c              #     K   |j                   sdg}n|j                   }t        j                  |d      D ]F  }|\  }}|j                  rt	        ||       #|j
                  t        j                  |      d H y w)Nzgs://F)&accept_notification_configuration_urls)z
Bucket URLzNotification Configuration)r(   r   'get_notification_configuration_iteratorr5   r!   
url_stringr	   MakeSerializable)r7   r8   r(   *notification_configuration_iterator_resultr   r   s         r    RunzList.Runx   s     99YdYYd 	,	0	0	@ 	3
 ?kc6			.sF;; ..*<*M*M+
 	
	@s   A>B N)	__name__
__module____qualname____doc__detailed_helpstaticmethodr1   r:   rA    r"   r    r$   r$   E   s4    I

-.  "?
r"   r$   N)rE   
__future__r   r   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   googlecloudsdk.core.resourcer   r	   lenr   r!   UniverseCompatibleListCommandr$   rH   r"   r    <module>rP      s^     I &  ' ( R 9 ;  ##=> #L H
4 H
 H
r"   