
    Ň                        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rSSKrSSKrSSK	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  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%  SSK$J&r&  SSK'J(r(  SSK'J)r)  Sr*Sr+Sr,Sr-Sr.\,\+R_                  S5      -   \*R_                  S5      -   \--   \.R_                  S5      -   S-   r0S r1S!r2S"r3S#r4S$r5S%\3-   \1-   \2-   S&-   \4-   \5-   S'Rm                  \%Rn                  S(9-   r8S)r9\" \0\85      r:\" \,\35      r;\" \*\15      r<\" \+\25      r=\" \-\45      r>\" \.\55      r?S*S+S,.r@ " S- S.\5      rAg)/z8This module provides the notification command to gsutil.    )absolute_import)print_function)division)unicode_literalsN)datetime)metrics)AccessDeniedException)NotFoundException) PublishPermissionDeniedException)Command)NO_MAX)CommandArgument)ApiSelector)CommandException)CreateHelpText)PopulateProjectId)	PubsubApi)StorageUrlFromString)Binding)copy_helper)	shim_util)GcloudStorageFlag)GcloudStorageMapz2
  gsutil notification list gs://<bucket_name>...
zO
  gsutil notification delete (<notificationConfigName>|gs://<bucket_name>)...
z
  gsutil notification create -f (json|none) [-p <prefix>] [-t <topic>] \
      [-m <key>:<value>]... [-e <eventType>]... gs://<bucket_name>
zW
  gsutil notification watchbucket [-i <id>] [-t <token>] <app_url> gs://<bucket_name>
z>
  gsutil notification stopchannel <channel_id> <resource_id>

a  
<B>LIST</B>
  The list sub-command provides a list of notification configs belonging to a
  given bucket. The listed name of each notification config can be used with
  the delete sub-command to delete that specific notification config.

  For listing Object Change Notifications instead of Cloud Pub/Sub notification
  subscription configs, add a -o flag.

<B>LIST EXAMPLES</B>
  Fetch the list of notification configs for the bucket example-bucket:

    gsutil notification list gs://example-bucket

  The same as above, but for Object Change Notifications instead of Cloud
  Pub/Sub notification subscription configs:

    gsutil notification list -o gs://example-bucket

  Fetch the notification configs in all buckets matching a wildcard:

    gsutil notification list gs://example-*

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

    gsutil notification list gs://*
a  
<B>DELETE</B>
  The delete sub-command deletes notification configs from a bucket. If a
  notification config name is passed as a parameter, that notification config
  alone is deleted. If a bucket name is passed, all notification configs
  associated with that bucket are deleted.

  Cloud Pub/Sub topics associated with this notification config are not
  deleted by this command. Those must be deleted separately, for example with
  the gcloud command `gcloud beta pubsub topics delete`.

  Object Change Notification subscriptions cannot be deleted with this command.
  For that, see the command `gsutil notification stopchannel`.

<B>DELETE EXAMPLES</B>
  Delete a single notification config (with ID 3) in the bucket example-bucket:

    gsutil notification delete projects/_/buckets/example-bucket/notificationConfigs/3

  Delete all notification configs in the bucket example-bucket:

    gsutil notification delete gs://example-bucket
a  
<B>CREATE</B>
  The create sub-command creates a notification config on a bucket, establishing
  a flow of event notifications from Cloud Storage to a Cloud Pub/Sub topic. As
  part of creating this flow, the create command also verifies that the
  destination Cloud Pub/Sub topic exists, creating it if necessary, and verifies
  that the Cloud Storage bucket has permission to publish events to that topic,
  granting the permission if necessary.

  If a destination Cloud Pub/Sub topic is not specified with the -t flag, Cloud
  Storage chooses a topic name in the default project whose ID is the same as
  the bucket name. For example, if the default project ID specified is
  'default-project' and the bucket being configured is gs://example-bucket, the
  create command uses the Cloud Pub/Sub topic
  "projects/default-project/topics/example-bucket".

  In order to enable notifications, your project's `Cloud Storage service agent
  <https://cloud.google.com/storage/docs/projects#service-accounts>`_ must have
  the IAM permission "pubsub.topics.publish". This command checks to see if the
  destination Cloud Pub/Sub topic grants the service agent this permission. If
  not, the create command attempts to grant it.

  A bucket can have up to 100 total notification configurations and up to 10
  notification configurations set to trigger for a specific event.

<B>CREATE EXAMPLES</B>
  Begin sending notifications of all changes to the bucket example-bucket
  to the Cloud Pub/Sub topic projects/default-project/topics/example-bucket:

    gsutil notification create -f json gs://example-bucket

  The same as above, but specifies the destination topic ID 'files-to-process'
  in the default project:

    gsutil notification create -f json \
      -t files-to-process gs://example-bucket

  The same as above, but specifies a Cloud Pub/Sub topic belonging to the
  specific cloud project 'example-project':

    gsutil notification create -f json \
      -t projects/example-project/topics/files-to-process gs://example-bucket

  Create a notification config that only sends an event when a new object
  has been created:

    gsutil notification create -f json -e OBJECT_FINALIZE gs://example-bucket

  Create a topic and notification config that only sends an event when
  an object beginning with "photos/" is affected:

    gsutil notification create -p photos/ gs://example-bucket

  List all of the notificationConfigs in bucket example-bucket:

    gsutil notification list gs://example-bucket

  Delete all notitificationConfigs for bucket example-bucket:

    gsutil notification delete gs://example-bucket

  Delete one specific notificationConfig for bucket example-bucket:

    gsutil notification delete \
      projects/_/buckets/example-bucket/notificationConfigs/1

<B>OPTIONS</B>
  The create sub-command has the following options

  -e        Specify an event type filter for this notification config. Cloud
            Storage only sends notifications of this type. You may specify this
            parameter multiple times to allow multiple event types. If not
            specified, Cloud Storage sends notifications for all event types.
            The valid types are:

              OBJECT_FINALIZE - An object has been created.
              OBJECT_METADATA_UPDATE - The metadata of an object has changed.
              OBJECT_DELETE - An object has been permanently deleted.
              OBJECT_ARCHIVE - A live version of an object has become a
                noncurrent version.

  -f        Specifies the payload format of notification messages. Must be
            either "json" for a payload matches the object metadata for the
            JSON API, or "none" to specify no payload at all. In either case,
            notification details are available in the message attributes.

  -m        Specifies a key:value attribute that is appended to the set
            of attributes sent to Cloud Pub/Sub for all events associated with
            this notification config. You may specify this parameter multiple
            times to set multiple attributes.

  -p        Specifies a prefix path filter for this notification config. Cloud
            Storage only sends notifications for objects in this bucket whose
            names begin with the specified prefix.

  -s        Skips creation and permission assignment of the Cloud Pub/Sub topic.
            This is useful if the caller does not have permission to access
            the topic in question, or if the topic already exists and has the
            appropriate publish permission assigned.

  -t        The Cloud Pub/Sub topic to which notifications should be sent. If
            not specified, this command chooses a topic whose project is your
            default project and whose ID is the same as the Cloud Storage bucket
            name.

<B>NEXT STEPS</B>
  Once the create command has succeeded, Cloud Storage publishes a message to
  the specified Cloud Pub/Sub topic when eligible changes occur. In order to
  receive these messages, you must create a Pub/Sub subscription for your
  Pub/Sub topic. To learn more about creating Pub/Sub subscriptions, see `the
  Pub/Sub Subscriber Overview <https://cloud.google.com/pubsub/docs/subscriber>`_.

  You can create a simple Pub/Sub subscription using the ``gcloud`` command-line
  tool. For example, to create a new subscription on the topic "myNewTopic" and
  attempt to pull messages from it, you could run:

    gcloud beta pubsub subscriptions create --topic myNewTopic testSubscription
    gcloud beta pubsub subscriptions pull --auto-ack testSubscription
a  
<B>WATCHBUCKET</B>
  The watchbucket sub-command can be used to watch a bucket for object changes.
  A service account must be used when running this command.

  The app_url parameter must be an HTTPS URL to an application that will be
  notified of changes to any object in the bucket.

  The optional id parameter can be used to assign a unique identifier to the
  created notification channel. If not provided, a random UUID string is
  generated.

  The optional token parameter can be used to validate notifications events.
  To do this, set this custom token and store it to later verify that
  notification events contain the client token you expect.

<B>WATCHBUCKET EXAMPLES</B>
  Watch the bucket example-bucket for changes and send notifications to an
  application server running at example.com:

    gsutil notification watchbucket https://example.com/notify \
      gs://example-bucket

  Assign identifier my-channel-id to the created notification channel:

    gsutil notification watchbucket -i my-channel-id \
      https://example.com/notify gs://example-bucket

  Set a custom client token that is included with each notification event:

    gsutil notification watchbucket -t my-client-token \
      https://example.com/notify gs://example-bucket
a  
<B>STOPCHANNEL</B>
  The stopchannel sub-command can be used to stop sending change events to a
  notification channel.

  The channel_id and resource_id parameters should match the values from the
  response of a bucket watch request.

<B>STOPCHANNEL EXAMPLES</B>
  Stop the notification event channel with channel identifier channel1 and
  resource identifier SoGqan08XDIFWr1Fv_nGpRJBHh8:

    gsutil notification stopchannel channel1 SoGqan08XDIFWr1Fv_nGpRJBHh8
a  
  You can use the ``notification`` command to configure
  `Pub/Sub notifications for Cloud Storage
  <https://cloud.google.com/storage/docs/pubsub-notifications>`_
  and `Object change notification
  <https://cloud.google.com/storage/docs/object-change-notification>`_ channels.

<B>CLOUD PUB/SUB</B>
  The "create", "list", and "delete" sub-commands deal with configuring Cloud
  Storage integration with Google Cloud Pub/Sub.
aP  
<B>OBJECT CHANGE NOTIFICATIONS</B>
  Object change notification is a separate, older feature within Cloud Storage
  for generating notifications. This feature sends HTTPS messages to a client
  application that you've set up separately. This feature is generally not
  recommended, because Pub/Sub notifications are cheaper, easier to use, and
  more flexible. For more information, see
  `Object change notification
  <https://cloud.google.com/storage/docs/object-change-notification>`_.

  The "watchbucket" and "stopchannel" sub-commands enable and disable Object
  change notifications.
aY  
<B>NOTIFICATIONS AND PARALLEL COMPOSITE UPLOADS</B>
  gsutil supports `parallel composite uploads
  <https://cloud.google.com/storage/docs/uploads-downloads#parallel-composite-uploads>`_.
  If enabled, an upload can result in multiple temporary component objects
  being uploaded before the actual intended object is created. Any subscriber
  to notifications for this bucket then sees a notification for each of these
  components being created and deleted. If this is a concern for you, note
  that parallel composite uploads can be disabled by setting
  "parallel_composite_upload_threshold = 0" in your .boto config file.
  Alternately, your subscriber code can filter out gsutil's parallel
  composite uploads by ignoring any notification about objects whose names
  contain (but do not start with) the following string:
    "{composite_namespace}".

)composite_namespacea_  
Watch bucket attempt failed:
  {watch_error}

You attempted to watch a bucket with an application URL of:

  {watch_url}

which is not authorized for your project. Please ensure that you are using
Service Account authentication and that the Service Account's project is
authorized for the application URL. Notification endpoint URLs must also be
whitelisted in your Cloud Console project. To do that, the domain must also be
verified using Google Webmaster Tools. For instructions, please see
`Notification Authorization
<https://cloud.google.com/storage/docs/object-change-notification#_Authorization>`_.
NONEJSON_API_V1)nonejsonc                      \ rS rSrSrS rSr\R                  " S/ SQ\	S\
SS	S	S
\R                  /\R                  \R                  " 5       \R                  " 5       // \R                  " 5       /\R                   " 5       /\R                  " 5       \R"                  " S
5      /S.S9r\R&                  " S/ SQSS\\\\\\S.S9r\" \" / SQ\" S\R<                  R>                  S9\" S\R<                  R@                  S9\" S5      \" S5      \" S5      \" S5      S.S9\" / SQ0 S9\" / SQ0 SS9S .0 S9r!S! r"S" r#S# r$S$ r%S% r&S.S& jr'S' r(S( r)S) r*S* r+S+ r,\%\(\*\"\#S.r-S, r.S-r/g)/NotificationCommandiy  z.Implementation of gsutil notification command.c                     [         R                  (       d  [        R                  " S5      [         l        [         R                  $ )Nz]/?(projects/[^/]+/)?b(uckets)?/(?P<bucket>[^/]+)/notificationConfigs/(?P<notification>[0-9]+))r!   _notification_path_regexrecompileselfs    .platform/gsutil/gslib/commands/notification.py_GetNotificationPathRegex-NotificationCommand._GetNotificationPathRegex  s0    7757ZZ:6<2 777    Nnotification)notifynotifyconfignotificationsnotif   zi:t:m:t:of:e:p:sF   )watchbucketstopchannellistdeletecreate)command_name_aliasesusage_synopsismin_argsmax_argssupported_sub_argsfile_url_okprovider_url_okurls_start_arggs_api_supportgs_default_apiargparse_arguments)r3   r4   r.   command_helpz$Configure object change notification)r7   r5   r6   r3   r4   )	help_namehelp_name_aliases	help_typehelp_one_line_summary	help_textsubcommand_help_text)storagebucketsr/   r7   z--custom-attributes)repeat_typez--event-typesz--object-prefixz--payload-formatz--skip-topic-setupz--topic)-m-e-p-f-s-t)gcloud_commandflag_map)rJ   rK   r/   r6   )rJ   rK   r/   r5   z--human-readableT)rS   rT   supports_output_translation)r7   r6   r5   c                    U R                  5         SnSnU R                  (       a'  U R                   H  u  p4US:X  a  UnUS:X  d  M  UnM     U=(       d    [        [        R                  " 5       5      nU R
                  S   nU R
                  S   nUR                  5       R                  S5      (       d  [        S5      e[        U5      nUR                  5       (       a  UR                  S:X  d  [        S	U R                  -  5      eUR                  5       (       d  [        S
U R                  -  5      eU R                  R                  SXu5         U R                  R!                  UR"                  UUUUR                  S9nUR,                  n
UR.                  nUR0                  nU R                  R                  S5        U R                  R                  SU
5        U R                  R                  SU5        U R                  R                  SU5        g! [$         a<  n	U R                  R'                  [(        R+                  [        U	5      US95        e Sn	A	ff = f)z/Creates a watch on a bucket given in self.args.Nz-irR   r   zhttps://z,The application URL must be an https:// URL.gs7The %s command can only be used with gs:// bucket URLs.*URL must name a bucket for the %s command.z.Watching bucket %s with application URL %s ...)tokenprovider)watch_error	watch_urlz0Successfully created watch notification channel.zWatch channel identifier: %sz%Canonicalized resource identifier: %szClient state token: %s)CheckArgumentssub_optsstruuiduuid4argslower
startswithr   r   IsBucketschemecommand_nameloggerinfo
gsutil_apiWatchBucketbucket_namer	   warn)NOTIFICATION_AUTHORIZATION_FAILED_MESSAGEformatid
resourceIdr[   )r'   
identifierclient_tokenoar^   
bucket_arg
bucket_urlchannele
channel_idresource_ids               r(   _WatchBucket NotificationCommand._WatchBucket  s   JL}}--$!9*9,	   0s4::<0J		!I2J??''
33KLL%j1J!!j&7&74&?
C


    I!../ 0 0 	KKE,
++J,B,B,5,62>5?5F5F	 , Hg J$$K==LKKGHKK3Z@KK<kJKK-|< ! 
kk
3
:
:s1vEN ; PQ 	s   1H 
I"7IIc                     U R                   S   nU R                   S   nU R                  R                  SX5        U R                  R	                  XSS9  U R                  R                  S5        g)Nr   r2   z3Removing channel %s with resource identifier %s ...rX   r\   zSuccesfully removed channel.)rd   rj   rk   rl   StopChannel)r'   r|   r}   s      r(   _StopChannel NotificationCommand._StopChannel(  sa    1J))A,KKKJ.OO
$GKK34r+   c           
         [        U5      nUR                  5       (       a  UR                  S:X  d  [        SU R                  -  5      eUR                  5       (       d  [        SU R                  -  5      eU R
                  R                  UR                  SS9R                  nU R                  R                  SUR                  5        [        U5       GH  u  pEU R                  R                  SUS-   5        U R                  R                  SUR                  5        U R                  R                  S	UR                  5        U R                  R                  S
UR                  5        U R                  R                  SUR                  5        U R                  R                  S[!        ["        R$                  " UR&                  S-  5      5      5        GM     g)z<Lists active channel watches on a bucket given in self.args.rX   rY   rZ   r   z?Bucket %s has the following active Object Change Notifications:z	Notification channel %d:r2   z		Channel identifier: %sz		Resource identifier: %sz		Application URL: %sz		Created by: %sz		Creation time: %si  r   )r   rg   rh   r   ri   rl   ListChannelsrn   itemsrj   rk   	enumerater|   r}   push_urlsubscriber_emailra   r   fromtimestampcreation_time_ms)r'   rx   ry   channelsidxrz   s         r(   _ListChannels!NotificationCommand._ListChannels3  s   %j1J!!j&7&74&?
C


    I!../ 0 0++J,B,B59 , ;;@5 KKI  "(+
kk3S1W=
kk3W5G5GH
kk4g6I6IJ
kk0'2B2BC
kk+W-E-EF
kk
!
h$$W%=%=%DE
FH , r+   c                    U R                  5         S nS n0 n/ nS nSnU R                  (       a  U R                   Hw  u  pxUS:X  a  UR                  U5        M  US:X  a  UnM(  US:X  a+  SU;  a  [        S5      eUR	                  SS5      u  pXU	'   MY  US:X  a  UnMc  US	:X  a  S
nMm  US:X  d  Mu  UnMy     U[
        ;  a  [        S5      e[
        U   nU R                  S   n[        U5      nUR                  5       (       a  UR                  5       (       d+  [        U R                  < SU R                  < SU< S35      eUR                  S:w  a  [        SU R                  -  5      eUR                  nU R                  R                  SU5        U R                   R#                  US/UR                  S9nUR$                  nU(       d  S['        S 5      < SU< 3nUR)                  S5      (       d  S['        S 5      < SU< 3nU R                  R                  SU5        S
nU(       a\  U R                   R+                  XR                  S9R,                  nU R                  R                  SUU5        U R/                  UU5      n[1        SS5       H6  n U R                   R3                  UUUUU(       a  UOS UUR                  S9n  O   S U< S!WR<                  < 3nU R                  R7                  S"U5        g! [4         aC    US:X  a;  U(       a4  U R                  R7                  S5        [8        R:                  " S5         M  e f = f)#NTrN   rP   rM   :zCCustom attributes specified with -m should be of the form key:valuer2   rO   rQ   FrR   z@Must provide a payload format with -f of either 'json' or 'none'rW    z& requires a GCS bucket name, but got ''rX   rY   z#Creating notification for bucket %sprojectNumber)fieldsr\   z	projects/z/topics/zUsing Cloud Pub/Sub topic %sr   z"Service account for project %d: %sr   r1   )pubsub_topicpayload_formatcustom_attributesevent_typesobject_name_prefixr\   zfRetrying create notification in 10 seconds (new permissions may take up to 10 seconds to take effect.)
   zprojects/_/buckets/z/notificationConfigs/zCreated notification config %s)r_   r`   appendr   splitPAYLOAD_FORMAT_MAPrd   r   
IsCloudUrlrg   ri   subcommand_namerh   rn   rj   debugrl   	GetBucketr   r   rf   GetProjectServiceAccountemail_address_CreateTopicrangeCreateNotificationConfigr   rk   timesleeprr   )r'   r   r   r   r   r   should_setup_topicrv   rw   keyvaluerx   ry   rn   bucket_metadatabucket_project_numberjust_modified_topic_permissionsservice_accountattempt_numbercreate_responsenotification_names                        r(   _CreateNotificationCommand._CreateN  s\    LNK}}--$!9


Q
$Y.$Y\"  wwsA*##(C
 $Y 
$Y$
$Y,#  & //
LN N'7N2J%j1J  ""**=*=*?*?d22J@A A D 
C


  ((KKK;ZH oo//8G7H9C9J9J 0 LO ,99 0A$0G0;=l"";// 1B$0G0<>lKK4lC&+# @@
*;*; A ==J] 
kk<-@(,(9(9
))%  1+//BB%)/'21&& C ( 	 &. 	_'')KK57HI . 	Q#B ++

LM **R.
	s   2K??AM
Mc                    [        U R                  S9n UR                  US9  U R                  R                  SU5        UR                  US9n[        SSU-  /S9nXTR                  ;  a+  UR                  R                  U5        UR                  XS	9  g
U R                  R                  SU5        g! [         aJ    U R                  R                  SU5        UR                  US9  U R                  R                  SU5         Nf = f)aE  Assures that a topic exists, creating it if necessary.

Also adds GCS as a publisher on that bucket, if necessary.

Args:
  pubsub_topic: name of the Cloud Pub/Sub topic to use/create.
  service_account: the GCS service account that needs publish permission.

Returns:
  true if we modified IAM permissions, otherwise false.
)rj   )
topic_namezTopic %s already existszCreating topic %szCreated Cloud Pub/Sub topic %szroles/pubsub.publisherzserviceAccount:%s)rolemembers)r   policyTz/GCS already has publish permission to topic %s.F)r   rj   GetTopicr   r
   CreateTopicrk   GetTopicIamPolicyr   bindingsr   SetTopicIamPolicy)r'   r   r   
pubsub_apir   bindings         r(   r    NotificationCommand._CreateTopic  s    $++.JG\2
kk1<@ ))\)BF32_DEGG oo%ooW%""l"J
kkI$&3  G
kk+\:5
kk7FGs   +B4 4ADDc              #     #    U R                  5       nU R                   GH  nUR                  U5      nU(       a  U(       d*  [        U R                  < SU R
                  < SU< 35      eUR                  S5      nUR                  S5      nSnU R                  R                  USS9 H  nUR                  U:X  d  M  XX4v   Sn  O   U(       d  [        S	U-  5      eM  [        U5      n	U	R                  5       (       d  [        S
U R                  -  5      eU	R                  S:w  a  [        S5      eSn
U	R                  5       (       a  Sn
OU	R                  5       (       a  Un
U
(       d  [        SU R                  -  5      eU R!                  U
5      R#                  S/S9 HR  nU R                  R                  UR$                  R&                  SS9 H  nUR$                  R&                  U4v   M     MT     GM     g7f)a]  Yields bucket/notification tuples from command-line args.

Given a list of strings that are bucket names (gs://foo) or notification
config IDs, yield tuples of bucket names and their associated notifications.

Args:
  accept_notification_configs: whether notification configs are valid args.
Yields:
  Tuples of the form (bucket_name, Notification)
r   z- accepts only bucket names, but you provided bucketr,   FrX   r   TzCould not find notification %szJThe %s command must be used on cloud buckets or notification config names.z+The %s command only works on gs:// buckets.Nzgs://*z<The %s command cannot be used on cloud objects, only bucketsrr   )bucket_fields)r)   rd   matchr   ri   r   grouprl   ListNotificationConfigsrr   r
   r   r   rh   
IsProviderrg   WildcardIteratorIterBucketsstorage_urlrn   )r'   accept_notification_configs
path_regex
list_entryr   rn   notification_idfoundr,   r   pathblrs               r(   _EnumerateNotificationsFromArgs3NotificationCommand._EnumerateNotificationsFromArgs  s     //1Jii
z*e	*   $"6"6
DE E kk(+++n5 OOCC$ D (L__/--E( !"BZ"OP
P  +:6%%''  $ 1 123 3 % !NO
O!!##$!!##$ L ! ! ((.::& ; "C"ooEEoo))D F :l??..==:"G  s   B9G??E G?c                    U R                  5         U R                  (       a>  S[        U R                  5      ;   a$  U R                   H  nU R	                  U5        M     gU R                  SS9 H  u  pU R                  X5        M     g)Nz-oF)r   r   )r_   r`   dictrd   r   r   _PrintNotificationDetailsr'   rn   r,   s      r(   _ListNotificationCommand._List  s}    }}	dmm$	$99K


[
) %  (,'K'K&+ (L (-
#+&&{A(- r+   c           
         [        SR                  UUR                  UR                  [	        S5      S  S95        UR
                  (       aO  [        S5        UR
                  R                   H*  n[        SUR                  < SUR                  < 35        M,     / nUR                  (       a-  UR                  SSR                  UR                  5      -  5        UR                  (       a  UR                  S	UR                  -  5        U(       a  [        S
5        U H  n[        U5        M     U R                  R                  S5        g )Nz\projects/_/buckets/{bucket}/notificationConfigs/{notification}
	Cloud Pub/Sub topic: {topic}z//pubsub.googleapis.com/)r   r,   topicz	Custom attributes:z		z: z		Event Types: %sz, z		Object name prefix: '%s'z		Filters: )printrq   rr   r   lenr   additionalPropertiesr   r   r   r   joinr   rj   rk   )r'   r   r,   attrfilterslines         r(   r   -NotificationCommand._PrintNotificationDetails)  s	   	 ++16'?? &&s+E'F'GH ,2 ,JK
 %%"#00EE$dhh

34 FGnn*YY|7789 :&&nn3!445 6L$d KKRr+   c                 l    U R                  5        H   u  pU R                  XR                  5        M"     g)Nr   )r   _DeleteNotificationrr   r   s      r(   _DeleteNotificationCommand._Delete@  s.    %)%I%I%K!
{OO< &Lr+   c                 :    U R                   R                  UUSS9  g)NrX   )r,   r\   r   )rl   DeleteNotificationConfig)r'   rn   r   s      r(   r   'NotificationCommand._DeleteNotificationE  s&    OO,,[:I6: - < r+   c                 (    [         R                   " U R                  U R                  R                  5      u  U l        U l        [
        R                  " U R                  S9  U" U 5      $ ! [         R                   a    U R                  5          g f = f)N)r`   )	getoptrd   command_specr<   r`   r   LogCommandParamsGetoptErrorRaiseInvalidArgumentException)r'   funcs     r(   _RunSubCommand"NotificationCommand._RunSubCommandK  sv    	+MM$))"&"3"3"F"FHt}y 6$Z +
((*+s   A'A* *$BBc                 d   U R                   R                  S5      U l        U R                  [        R                  ;   aK  [
        R                  " U R                  /S9  U R                  [        R                  U R                     5      $ [        SU R                  < SU R                  < S35      e)z1Command entry point for the notification command.r   )subcommandszInvalid subcommand "z
" for the z	 command.)
rd   popr   r!   SUBCOMMANDSr   r   r   r   ri   r&   s    r(   
RunCommandNotificationCommand.RunCommand_  s    99==+D2>>>D,@,@+AB  

)
)$*>*>
?A A "22D4E4EG H Hr+   )rd   r`   r   )T)0__name__
__module____qualname____firstlineno____doc__r)   r#   r   CreateCommandSpec	_SYNOPSISr   r   JSONr   MakeFreeTextArgument%MakeZeroOrMoreCloudBucketURLsArgumentMakeZeroOrMoreCloudURLsArgumentMakeNCloudBucketURLsArgumentr   HelpSpec_DETAILED_HELP_TEXT_create_help_text_list_help_text_delete_help_text_watchbucket_help_text_stopchannel_help_text	help_specr   r   r   RepeatFlagTypeDICTLISTgcloud_storage_mapr~   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes__ r+   r(   r!   r!   y  s   68 " ** +!&&' %% 224CCE "HHJL
 ==?	 224::1=##,J 
 B#%!%//)& ( "
 ,3*3*B*B*G*GI ,-*3*B*B*G*GI ,,=>+,>?+,@A+I6!	0 " 	 " .2
C,Z ]/b3j	6iV,\4>l
.

+ !!+	Hr+   r!   )Br  
__future__r   r   r   r   r   r$   r   rb   r   gslibr   gslib.cloud_apir	   r
   r   gslib.commandr   r   gslib.command_argumentr   gslib.cs_api_mapr   gslib.exceptionr   gslib.help_providerr   gslib.project_idr   gslib.pubsub_apir   gslib.storage_urlr   4gslib.third_party.pubsub_apitools.pubsub_v1_messagesr   gslib.utilsr   r   gslib.utils.shim_utilr   r   _LIST_SYNOPSIS_DELETE_SYNOPSIS_CREATE_SYNOPSIS_WATCHBUCKET_SYNOPSIS_STOPCHANNEL_SYNOPSISlstripr  _LIST_DESCRIPTION_DELETE_DESCRIPTION_CREATE_DESCRIPTION_WATCHBUCKET_DESCRIPTION_STOPCHANNEL_DESCRIPTIONrq   PARALLEL_UPLOAD_TEMP_NAMESPACE_DESCRIPTIONrp   r  r  r  r  r  r  r   r!   r  r+   r(   <module>r3     s   ? & %  '  	     1 - < !   2 ( , . . & 2 H # ! 3 2    
 D!"$     &	' *.	. 
 8 0v p  D 
 
 .
. 1D
DG, -, ":-:,= F{IIFJK%KN- )" %Y=  #%89  >#45  #%89  (*BC  (*BC 
  oH' oHr+   