
                            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  SS
KJr  SSKJr  SSKJr  SSKrSrSrSrSrSrSrSrSrSrSrSrSrS\S\4S jr S r!S>S jr"S?S jr#S  r$S! r%S" r& S@S# jr' S@S$ jr(S?S% jr)S& r*S' r+S( r,S) r-S* r.S+ r/S, r0  SAS- jr1S?S. jr2S?S/ jr3 S?S0 jr4S1 r5S2 r6S3 r7S?S4 jr8S5 r9S6 r:S7 r;S8 r<S9 r=S: r>S; r?S< r@SBS= jrAg)Cz:A library containing flags used by Cloud Pub/Sub commands.    )absolute_import)division)unicode_literals)subscriptions)actions)arg_parsers)
exceptions)resource_args)util)log)
propertiesNd   zBPositional argument `{0}` is deprecated. Please use `{1}` instead.zValid values are strings of the form INTEGER[UNIT], where UNIT is one of "s", "m", "h", and "d" for seconds, minutes, hours, and days, respectively. If the unit is omitted, seconds is assumed.z"Message Ordering is not available.z#Message Filtering is not available.z%Dead-Letter Topics are not available.zRetry Policy is not available.z'Exactly-Once Delivery is not available.zSchema is not available.zIngestion is not available.z0BigQuery Export Subscriptions are not available.z5Cloud Storage Export Subscriptions are not available.config_name	is_updatec                 *    U(       a  SU  SU  SU  S3$ g)zGThe help text to tell users all fields must be specified during update.z

When updating z flags, all z1 flags must be specified. Otherwise, any omitted z% flags revert to their default value.  )r   r   s     .lib/googlecloudsdk/command_lib/pubsub/flags.pyMustSpecifyAllHelpTextr   H   s1    
[Mk] C11< > 	 
 
    c                     SU  S3$ )Nz	Use --no-z to disable this flag.r   )	flag_names    r   NegativeBooleanFlagHelpTextr   S   s    YK5	66r   c           
      |    U R                   " SU-   4S[        R                  " US-   [        U5      -   U5      0UD6  g )N--help )add_argumentr   UniverseHelpTextr   )parserr   	help_textuniverse_helpkwargss        r   AddBooleanFlagr$   W   sJ    
Y''
c/7	B
B
 	r   c                 "   SR                  U5      nU nU(       aJ  U R                  SS9nUR                  SSU[        R                  " SS [
        R                  SS5      S	9S
9  UR                  SSU(       + [        R                  " 5       US9  g)z+Adds parsing and help text for ack_id flag.ac  One or more ACK_IDs to {} An ACK_ID is a [string that is returned to subscribers](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.ReceivedMessage). along with the message. The ACK_ID is different from the [message ID](https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#google.pubsub.v1.PubsubMessage).Trequiredack_id*ACK_IDc                     gNFr   _s    r   <lambda>AddAckIdFlag.<locals>.<lambda>t       5r   	--ack-idsshow_messagewarn)nargsr   action)metavarr'   typer   N)formatadd_mutually_exclusive_groupr   r   DeprecationActionDEPRECATION_FORMAT_STRr   ArgList)r    r7   add_deprecatedr!   groups        r   AddAckIdFlagrA   b   s    q F6N  %///>E	((('..xE
	  	 !!   r   c                     U R                   (       a*  [        R                  " [        R	                  SS5      5        U R                   =(       d    U R
                  n[        U[        5      (       d  U/nU$ )a  Gets the list of ack_ids from args.

This is only necessary because we are deprecating the positional `ack_id`.
Putting the positional and a flag in an argument group, will group flag
under positional args. This would be confusing.

DeprecationAction can't be used here because in order to make the positional
argument optional, we have to use `nargs='*'`. Since this means zero or more,
the DeprecationAction warn message is always triggered.

This function does not exist in util.py in order to group the explanation for
why this exists with the deprecated flags.

Once the positional is removed, this function can be removed.

Args:
  args (argparse.Namespace): Parsed arguments

Returns:
  list[str]: List of ack ids.
r*   r2   )r(   r   warningr=   r:   ack_ids
isinstancelist)argsrD   s     r   ParseAckIdsArgsrH      sP    , 
[[KK&--hDEKK'4<<'	GT	"	"iG	.r   c                 $    U R                  SSS9  g )Npolicy_filez%JSON or YAML file with the IAM policyr   r   r    s    r   AddIamPolicyFileFlagrN      s    A  r   c                     U R                  SS9nUR                  S[        R                  R                  SS9  UR                  SSS9  U R                  S	S
S9  g)z.Adds flags for the seek command to the parser.Tr&   z--timeaN            The time to seek to. Messages in the subscription that
          were published before this time are marked as acknowledged, and
          messages retained in the subscription that were published after
          this time are marked as unacknowledged.
          See $ gcloud topic datetimes for information on time formats.r9   r   z
--snapshotz\The name of the snapshot. The snapshot's topic must be the same as that of the subscription.rK   z--snapshot-projectz          The name of the project the snapshot belongs to (if seeking to
          a snapshot). If not set, it defaults to the currently selected
          cloud project.N)r;   r   r   DatetimeParse)r    seek_to_groups     r   AddSeekFlagsrT      sz    55t5D-%%K  	 )   	  r   c                 @   U(       a*  U R                  S[        SS[        R                  " SSS9S9  [	        U SSS	S
S9  U(       a  U(       a  U R                  SSS9n U(       a&  U R                  SSS[        R                  " SSSS9S9  U(       a  [	        U SSS	SS9  gg)z7Adds the main set of message pulling flags to a parser.z--max-messages   zNThe maximum number of messages that Cloud Pub/Sub can return in this response.z8`{flag_name}` is deprecated. Please use --limit instead.)r5   )r9   defaultr   r7   zauto-ack
store_trueFz>Automatically ACK every message pulled from this subscription.r    r   r7   rW   r!   TzPull timeout behavior.mutexr   z--waitz^Wait (for a bounded amount of time) for new messages from the subscription, if there are none.zc`{flag_name}` is deprecated. This flag is non-operational, as the wait behavior is now the default.)r5   r7   )rW   r   r7   zreturn-immediatelya5  If this flag is set, the system responds immediately with any messages readily available in memory buffers. If no messages are available in the buffers, returns an empty list of messages as response, even if having messages in the backlog. Do not set this flag as it adversely impacts the performance of pull.N)r   intr   r<   r$   	add_group)r    r?   add_waitadd_return_immediatelys       r   AddPullFlagsr`      s     
  ((K
   
J (D/GHF
/ ((9  
    &E r   c                 \   U nU(       d  U R                  SS[        SU5      -   SS9nUR                  SUSS9  UR                  SSS	S
S9  UR                  SSSSS9  U(       a  UR                  5       n[	        USSSS9  UnUR                  SSSS9n[	        USSSSS9  [	        USSSSS9  g)z0Adds flags for push subscriptions to the parser.Fz@Push Config Options. Configuration for a push delivery endpoint.
PushConfigr[   r   r'   z--push-endpointzsA URL to use as the endpoint for this subscription. This will also automatically set the subscription type to PUSH.r'   r   z--push-auth-service-accountSERVICE_ACCOUNT_EMAILzjService account email used as the identity for the generated Open ID Connect token for authenticated push.)r'   destr   z--push-auth-token-audienceOPTIONAL_AUDIENCE_OVERRIDEzAudience used in the generated Open ID Connect token for authenticated push. If not specified, it will be set to the push-endpoint.zclear-push-no-wrapper-configrX   z9If set, clear the NoWrapper config from the subscription.r    r   r7   r!   zNoWrapper Config Options.zpush-no-wrapperzBWhen set, the message data is delivered directly as the HTTP body.T)r    r   r!   r7   r'   zpush-no-wrapper-write-metadatazWhen true, writes the Pub/Sub message metadata to `x-goog-pubsub-<KEY>:<VAL>` headers of the HTTP request. Writes the Pub/Sub message attributes to `<KEY>:<VAL>` headers of the HTTP request.N)r]   r   r   r;   r$   )r    r'   r   is_modify_push_config_requestcurrent_groupmutual_exclusive_groupdefinition_groups          r   AddPushConfigFlagsrm      s$   
 -	&$$O
 y
9:	 % M B	   #":   "'  	 *GGI%0Q	 +M",,& - 
 !
N 0
 r   c                 0    U R                  S[        USS9  g )Nz--ack-deadlinez}The number of seconds the system will wait for a subscriber to acknowledge receiving a message before re-attempting delivery.)r9   r'   r   )r   r\   )r    r'   s     r   AddAckDeadlineFlagro   O  s$    K  r   c                     U(       a	  [         nSnO[        R                  " SSS9nSnU=(       d    [        R                  " 5       n[        U SSSS	S
9  U R	                  SUSR                  U[        5      S9  g)zEAdds flags subscription's message retention properties to the parser.zlSpecify "default" to use the default value of 7 days. The minimum is 10 minutes, and the maximum is 31 days.10m31dlower_boundupper_boundzSThe default value is 7 days, the minimum is 10 minutes, and the maximum is 31 days.zretain-acked-messagesrX   Na            Whether or not to retain acknowledged messages. If true,
          messages are not expunged from the subscription's backlog
          until they fall out of the --message-retention-duration
          window. Acknowledged messages are not retained by default. rY   --message-retention-durationa             How long to retain unacknowledged messages in the
          subscription's backlog, from the moment a message is
          published. If --retain-acked-messages is true, this also
          configures the retention of acknowledged messages. {} {}rP   )-ParseSubscriptionRetentionDurationWithDefaultr   Durationr$   r   r:   DURATION_HELP_STR)r    r   retention_parserretention_default_helps       r   $AddSubscriptionMessageRetentionFlagsr|   [  s    D	3 
 #++u	2 
 &?)=)=)?'I
 	$F GMf
 "3G  
r   c                 F    U R                  SSSS9  U R                  SSS9  g)	z3Adds --topic and --topic-project flags to a parser.z--topicTzzThe name of the topic from which this subscription is receiving messages. Each subscription is attached to a single topic.rd   z--topic-projectzwThe name of the project the provided topic belongs to. If not set, it defaults to the currently selected cloud project.rK   NrL   rM   s    r   !AddSubscriptionTopicResourceFlagsr~     s?    G	   	M  r   c           	         U nU(       a$  UR                  5       n[        USSSS[        S9  UnUR                  [        R
                  " S[        SU5      -   [        S9S	9nUR                  S
SSS9  UR                  5       n[        USSSSS9  [        USSSSS9  [        USSSSS9  [        USSSSS9  UR                  SSSS9  g)z%Adds BigQuery config flags to parser.zclear-bigquery-configrX   Nz8If set, clear the BigQuery config from the subscription.r    r   r7   rW   r!   r"   a  BigQuery Config Options. The Cloud Pub/Sub service account
         associated with the enclosing subscription's parent project (i.e.,
         service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com)
         must have permission to write to this BigQuery table.BigQueryConfigrW   r"   rK   z--bigquery-tableTzuA BigQuery table  of the form {project}:{dataset_name}.{table_name} to which to write messages for this subscription.rd   zuse-topic-schemazWhether or not to use the schema for the subscription's topic (if it exists) when writing messages to BigQuery. If --drop-unknown-fields is not set, then the BigQuery schema must contain all fields that are present in the topic schema.rY   zuse-table-schemazRWhether or not to use the BigQuery table schema when writing messages to BigQuery.zwrite-metadataah  Whether or not to write message metadata including message ID, publish timestamp, ordering key, and attributes to BigQuery. The subscription name, message_id, and publish_time fields are put in their own columns while all other message properties other than data (for example, an ordering_key, if present) are written to a JSON object in the attributes column.zdrop-unknown-fieldszIf either --use-topic-schema or --use-table-schema is set, whether or not to ignore fields in the message that do not appear in the BigQuery table schema.z --bigquery-service-account-emailzThe service account email to use when writing to BigQuery. If unspecified, uses the Pub/Sub service agent (https://cloud.google.com/iam/docs/service-account-types#service-agents).rW   r   )r;   r$   $BIGQUERY_EXPORT_NOT_SUPPORTED_IN_TPCadd_argument_groupr   r   r   r   )r    r   rj   rk   bigquery_config_group/bigquery_schema_config_mutually_exclusive_groups         r   AddBigQueryConfigFlagsr     s>   
 -*GGI%)P: +M'::''B ##3Y?	@
 = ; 	 $$?	 %  88: 2 <". <"#	 " 3 "%$
 $$(W	 % r   c           
         U nS[        SU5      -   nU(       a)  UR                  5       n[        USSSS[        S9  UnUS-  nUR	                  [
        R                  " U[        S	9S
9nUR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  S[
        R                  " SSS/ SQS9SSS9  UR                  S[
        R                  " SS S!S"9S#R                  [        5      S$9  UR                  S%[
        R                  " S&S'9SS(S9  UR                  S)[
        R                  " S* S+S+S,S-/S.9S,S/S0S19  [        US2SSS3S49  [        US5SSS6S49  UR                  S7SS8S9  g)9z*Adds Cloud Storage config flags to parser.aI  Cloud Storage Config Options. The Cloud
        Pub/Sub service account associated with the enclosing subscription's
        parent project (i.e.,
        service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com)
        must have permission to write to this Cloud Storage bucket and to read
        this bucket's metadata.CloudStorageConfigzclear-cloud-storage-configrX   Nz=If set, clear the Cloud Storage config from the subscription.r   z

Note that an update to the Cloud
          Storage config will replace it with a new config containing only the
          flags that are passed in the `update` CLI.r   rK   z--cloud-storage-bucketTzHA Cloud Storage bucket to which to write messages for this subscription.rd   z--cloud-storage-file-prefixz&The prefix for Cloud Storage filename.r   z--cloud-storage-file-suffixz&The suffix for Cloud Storage filename.z$--cloud-storage-file-datetime-formatzThe custom datetime format string for Cloud Storage filename. See the [datetime format guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).z--cloud-storage-max-bytes1000B10GBKB)Br   KiBMBMiBGBGiB)rt   ru   default_unitsuggested_binary_size_scalesz The maximum bytes that can be written to a Cloud Storage file before a new file is created. The value must be between 1000B and 10GB. If the unit is omitted, KB is assumed.r9   rW   r   z--cloud-storage-max-duration1mrq   s)rt   ru   r   zThe maximum duration that can elapse before a new Cloud Storage
          file is created. The value must be between 1m and 10m.
          {}rP   z--cloud-storage-max-messagesi  )rt   zThe maximum number of messages that can be written to a Cloud Storage file before a new file is created. The value must be greater than or equal to 1000.z--cloud-storage-output-formatc                 4    [        U 5      R                  5       $ Nstrlowerxs    r   r/   ,AddCloudStorageConfigFlags.<locals>.<lambda>a      Qr   rV   textavroelement_type
min_length
max_lengthchoicesOUTPUT_FORMATzThe output format for data written to Cloud Storage. Values: text (messages will be written as raw text, separated by a newline) or avro (messages will be written as an Avro binary).)r9   rW   r8   r   zcloud-storage-write-metadataa  Whether or not to write the subscription name, message_id, publish_time, attributes, and ordering_key as additional fields in the output. The subscription name, message_id, and publish_time fields are put in their own fields while all other message properties other than data (for example, an ordering_key, if present) are added as entries in the attributes map. This has an effect only for subscriptions with --cloud-storage-output-format=avro.rY   zcloud-storage-use-topic-schemazWhether or not to use the schema for the subscription's topic (if it exists) when writing messages to Cloud Storage. This has an effect only for subscriptions with --cloud-storage-output-format=avro.z%--cloud-storage-service-account-emailzThe service account email to use when writing to Cloud Storage. If unspecified, uses the Pub/Sub service agent (https://cloud.google.com/iam/docs/service-account-types#service-agents).)r   r;   r$   )CLOUD_STORAGE_EXPORT_NOT_SUPPORTED_IN_TPCr   r   r   r   
BinarySizerx   r:   ry   
BoundedIntr>   )r    r   rj   cloud_storage_config_group_helprk   cloud_storage_config_groups         r   AddCloudStorageConfigFlagsr     sW   -%#
 &<I&%! *GGI%.U? +M# (8 8#  -??''1A  @   ))	 *  ))#3 * 
 ))#3 * 
 )),j	 *  ))!!!(	 :% * . ))$C() *  ))$!!d3, * 	 ))%/6"	 @ *   '.1  '01 ))-W	 * r   c           	         U nU(       a  UR                  SS9n[        USSSSSS9  UnUR                  SS[        S	U5      -   S
9n[        R
                  " SSSSS9n[        R                  " XE/5        UR                  SSSS9  g)z*Adds Pubsub export config flags to parser.T)hiddenzclear-pubsub-export-configrX   Nz=If set, clear the Pubsub Export config from the subscription.)r    r   r7   rW   r   r!   a#  Cloud Pub/Sub Export Config Options. The Cloud Pub/Sub service
      account associated with the enclosing subscription's parent project
      (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com)
      must have permission to publish to the destination Cloud Pub/Sub topic.PubsubExportConfig)r   r   zto publish messages to.zpubsub-export-topicFr   
positionalr'   z--pubsub-export-topic-regionan  The Google Cloud region to which messages are published. For example, us-east1. Do not specify more than one region. If the region you specified is different from the region to which messages were published, egress fees are incurred. If the region is not specified, Pub/Sub uses the same region to which the messages were originally published on a best-effort basis.rd   )r;   r$   r   r   r
   CreateTopicResourceArgAddResourceArgsr   )r    r   rj   rk   pubsub_export_config_grouppubsub_export_topics         r   AddPubsubExportConfigFlagsr     s    -*GG H  %.K	 +M,??Q 	3Y?	@  @   &<<%	  "7 ))$:	 * r   c                     U [         R                  :X  a  U $ [        R                  " [        R
                  " SSS9" U 5      5      $ )Nrq   rr   rs   )r   DEFAULT_MESSAGE_RETENTION_VALUEr   FormatDurationr   rx   values    r   rw   rw     s=    
m;;;L			u%@G
 r   c                     U [         R                  :X  a  U $ [        R                  " [        R
                  " 5       " U 5      5      $ r   )r   NEVER_EXPIRATION_PERIOD_VALUEr   r   r   rx   r   s    r   &ParseExpirationPeriodWithNeverSentinelr     s4    
m999L			[113E:	;;r   c                    [        U 5        [        U US9  U R                  5       n[        X15        [	        X15        U(       a  [        X15        [        X5        U(       d  [        U SSSS[        S9  U(       d,  U R                  S[        [        R                  " S[        S	9S
9  U nU(       a6  UR                  5       n[        USSS[        R                  " S[        S	9S9  UnUR                  [        R                  " S[!        SU5      -   [        S	9S9n["        R$                  " SSSSS9n["        R&                  " Xg/5        UR                  S[        R(                  " SS5      SSS9  U R                  S[*        SR-                  [.        5      S
9  U nU(       a6  UR                  5       n[        USSS[        R                  " S[0        S	9S9  UnUR                  [        R                  " S[!        SU5      -   [0        S	9S9nUR                  S [        R2                  " S!S"S#9S$R-                  [.        5      S
9  UR                  S%[        R2                  " S!S"S#9S&R-                  [.        5      S
9  [        U S'SSS([4        S9  g))a   Adds the flags for creating or updating a subscription.

Args:
  parser: The argparse parser.
  is_update: Whether or not this is for the update operation (vs. create).
  enable_push_to_cps: Whether or not to enable Pubsub Export config flags
    support.
)r   zenable-message-orderingrX   NzWhether to receive messages with the same ordering key in order.
            If set, messages with the same ordering key are sent to subscribers
            in the order that Pub/Sub receives them.r   --message-filterzExpression to filter messages. If set, Pub/Sub only delivers the
        messages that match the filter. The expression must be a non-empty
        string in the [Pub/Sub filtering
        language](https://cloud.google.com/pubsub/docs/filtering).r   rP   zclear-dead-letter-policyz;If set, clear the dead letter policy from the subscription.rY   aL  Dead Letter Queue Options. The Cloud Pub/Sub service account
           associated with the enclosing subscription's parent project (i.e.,
           service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com)
           must have permission to Publish() to this topic and Acknowledge()
           messages on this subscription.DeadLetterPolicyrK   z#to publish dead letter messages to.zdead-letter-topicFr   z--max-delivery-attempts   r   zMaximum number of delivery attempts for any message. The value
          must be between 5 and 100. Defaults to 5. `--dead-letter-topic`
          must also be specified.r   z--expiration-periodzThe subscription will expire if it is inactive for the given
          period. {} This flag additionally accepts the special value "never" to
          indicate that the subscription will never expire.zclear-retry-policyz5If set, clear the retry policy from the subscription.z|Retry Policy Options. Retry policy specifies how Cloud Pub/Sub
              retries message delivery for this subscription.RetryPolicyz--min-retry-delay0s600srs   zThe minimum delay between consecutive deliveries of a given
          message. Value should be between 0 and 600 seconds. Defaults to 10
          seconds. {}z--max-retry-delayzThe maximum delay between consecutive deliveries of a given
          message. Value should be between 0 and 600 seconds. Defaults to 600
          seconds. {}zenable-exactly-once-deliverya            Whether or not to enable exactly-once delivery on the subscription.
          If true, Pub/Sub provides the following guarantees for the delivery
          of a message with a given value of `message_id` on this
          subscription: The message sent to a subscriber is guaranteed not to
          be resent before the message's acknowledgment deadline expires. An
          acknowledged message will not be resent to a subscriber.)ro   rm   r;   r   r   r   r|   r$   %MESSAGE_ORDERING_NOT_SUPPORTED_IN_TPCr   r   r   r   &MESSAGE_FILTERING_NOT_SUPPORTED_IN_TPC'DEAD_LETTER_TOPICS_NOT_SUPPORTED_IN_TPCr   r   r
   r   r   r   r   r:   ry   !RETRY_POLICY_NOT_SUPPORTED_IN_TPCrx   !EXACTLY_ONCE_NOT_SUPPORTED_IN_TPC)	r    r   enable_push_to_cpsmutex_grouprj   rk   set_dead_letter_policy_groupdead_letter_topicset_retry_policy_groups	            r   AddSubscriptionSettingsFlagsr     s    V
 335+0[4{6&v9	+8 <	 

))F A
  
 -*GGI%,..UA
	 +M!.!A!A''-
 ##5yAB @ "B 
" $::+#	 "$7 ++!!!S)%	 ,  	1??Ev
@   -*GGI%&..O;
	 +M(;;''A"=)<= :	 <  %%DfE 12 &  %%DfE 12 &  .F 6r   c                 p   SnU(       a<  U R                  SSSU[        R                  " SS [        R	                  SS5      S9S	9  U R                  SUS
9  U R                  S[
        R                  " [        S9SR	                  [        5      S9  U R                  S[
        R                  " S[        S9S
9  g)zAdds the flags for building a PubSub message to the parser.

Args:
  parser: The argparse parser.
  add_deprecated: Whether or not to add the deprecated flags.
z      The body of the message to publish to the given topic name.
      Information on message formatting and size limits can be found at:
      https://cloud.google.com/pubsub/docs/publisher#publishmessage_body?NMESSAGE_BODYc                     gr,   r   r-   s    r   r/   (AddPublishMessageFlags.<locals>.<lambda>  r1   r   	--messager3   )r6   rW   r   r7   rK   --attributer   zsComma-separated list of attributes. Each ATTRIBUTE has the form name="value". You can specify up to {0} attributes.rP   z--ordering-keyzThe key for ordering delivery to subscribers. All messages with
          the same ordering key are sent to subscribers in the order that
          Pub/Sub receives them.r   )
r   r   r<   r=   r:   r   ArgDictMAX_ATTRIBUTESr   r   )r    r?   message_help_texts      r   AddPublishMessageFlagsr   p  s    @ 
((('..~{K
  
 	k(9:.9@@FA  	 	''$ >	  r   c           
         U nU(       a$  UR                  5       n[        USSSS[        S9  UnUR                  [        R
                  " S[        SU5      -   [        S9S	9nS
n[        R                  " USSSS9n[        R                  " XF/5        UR                  S[        R                  " S SSSS/S9SSSS9  UR                  SSSS9  UR                  SSSS9  g)zAdds the flags for filling the SchemaSettings message.

Args:
  parser: The argparse parser.
  is_update: (bool) If true, add another group with clear-schema-settings as a
    mutually exclusive argument.
zclear-schema-settingsrX   Nz1If set, clear the Schema Settings from the topic.r   ztSchema settings. The schema that messages published to this topic must conform to and the expected message encoding.SchemaSettingsr   rK   z6that messages published to this topic must conform to.FT)r   pluralr'   z--message-encodingc                 4    [        U 5      R                  5       $ r   r   r   s    r   r/   (AddSchemaSettingsFlags.<locals>.<lambda>  r   r   rV   jsonbinaryr   ENCODINGz6The encoding of messages validated against the schema.)r9   r8   r   r'   z--first-revision-idzEThe id of the oldest
      revision allowed for the specified schema.r   r'   z--last-revision-idzIThe id of the most recent
      revision allowed for the specified schema)r;   r$   SCHEMA_NOT_SUPPORTED_IN_TPCr   r   r   r   r
   CreateSchemaResourceArgr   r   r>   )r    r   rj   rk   set_schema_settings_groupschema_help_textschemas          r   AddSchemaSettingsFlagsr     s3    -*GGI%)I1 +M+>>''I ##3Y?	@
 4 ? 	 N005&  98D((/8$	 G )  ((4	 )  ((3	 ) r   c           
         U nU(       a#  UR                  SS9n[        USSSS[        S9  UnUR                  [        R
                  " S[        S	U5      -   [        S
9S9nUR                  5       nUR                  [        R
                  " S[        SU5      -   [        S
9S9nUR                  SSSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  SSSSS9  UR                  [        R
                  " S[        SU5      -   [        S
9SS9nUR                  SSSSS9  UR                  S[        R                  " S SS/ S QS!9SS"S#SS$9  UR                  S%SS&SS9  UR                  S'SS(SS9  UR                  S)SS*SS9  UR                  S+SS,SS9  UR                  [        R
                  " S-[        S.U5      -   [        S
9S9nUR                  S/SS0SS9  UR                  S1SS2SS9  UR                  S3SS4SS9  UR                  S5SS6SS9  UR                  S7SS8SS9  UR                  S9SS:SS9  UR                  S;SS<SS9  UR                  [        R
                  " S=[        S>U5      -   [        S
9S9n	U	R                  S?SS@SS9  U	R                  SASSBSS9  U	R                  SCSSDSS9  U	R                  SESSFSS9  UR                  [        R
                  " SG[        SHU5      -   [        S
9S9n
U
R                  SISSJSS9  U
R                  SKSSLSS9  U
R                  SMSSNSS9  U
R                  SOSSPSS9  U
R                  SQSSRSS9  g)SzAdds the flags for Datasource Ingestion.

Args:
  parser: The argparse parser
  is_update: (bool) If true, add a wrapper group with
    clear-ingestion-data-source-settings as a mutually exclusive argument.
zPSpecify either --clear-ingestion-data-source-settings or a new ingestion source.rK   z$clear-ingestion-data-source-settingsrX   Nz@If set, clear the Ingestion Data Source Settings from the topic.r   zOFollowing flags are for specifying the data source settings for an import topicIngestionDataSourceSettingsr   zcFlags that specify settings for an import topic from Amazon Web Services (AWS) Kinesis Data StreamszAWSKinesis Sourcez--kinesis-ingestion-stream-arnz2Kinesis data stream ARN from which to ingest data.T)rW   r   r'   z --kinesis-ingestion-consumer-arnzNKinesis data streams consumer Amazon Resource Name (ARN) to use for ingestion.z--kinesis-ingestion-role-arnzKAWS role ARN to be used for Federated Identity authentication with Kinesis.z#--kinesis-ingestion-service-accountz[Google Cloud service account to be used for Federated Identity authentication with Kinesis.zBFlags that specify settings for an import topic from Cloud StoragezCloudStorage SourceF)r   	sort_argsz --cloud-storage-ingestion-bucketz/Cloud Storage bucket from which to ingest data.z&--cloud-storage-ingestion-input-formatc                 4    [        U 5      R                  5       $ r   r   r   s    r   r/   -AddIngestionDatasourceFlags.<locals>.<lambda>L  r   r   rV   )r   r   pubsub_avror   INPUT_FORMATz/Format of the data in the Cloud Storage bucket.)r9   rW   r8   r   r'   z(--cloud-storage-ingestion-text-delimiterz?Delimiter to use with text format when partitioning the object.z4--cloud-storage-ingestion-minimum-object-create-timezVOnly Cloud Storage objects with a larger or equal creation timestamp will be ingested.z$--cloud-storage-ingestion-match-globzoGlob pattern used to match Cloud Storage objects that will be ingested. If unset, all objects will be ingested.z--ingestion-log-severityz"Log severity to use for ingestion.zEFlags that specify settings for an import topic from Azure Event HubszAzureEventHubs Sourcez+--azure-event-hubs-ingestion-resource-groupzBAzure Event Hubs resource group from within an Azure subscription.z&--azure-event-hubs-ingestion-namespacez5Azure Event Hubs namespace from which to ingest data.z&--azure-event-hubs-ingestion-event-hubz*Azure event hub from which to ingest data.z&--azure-event-hubs-ingestion-client-idz0Azure Event Hubs client ID to use for ingestion.z&--azure-event-hubs-ingestion-tenant-idz0Azure Event Hubs tenant ID to use for ingestion.z,--azure-event-hubs-ingestion-subscription-idz6Azure Event Hubs subscription ID to use for ingestion.z,--azure-event-hubs-ingestion-service-accountzdGoogle Cloud service account to be used for Federated Identity authentication with Azure Event Hubs.zwFlags that specify settings for an import topic from Amazon Web Services (AWS) Managed Streaming for Apache Kafka (MSK)zAWS MSK Sourcez--aws-msk-ingestion-cluster-arnz-ARN that uniquely identifies the MSK cluster.z--aws-msk-ingestion-topicz4Name of the MSK topic that Pub/Sub will import from.z --aws-msk-ingestion-aws-role-arnzGAWS role ARN to be used for Federated Identity authentication with MSK.z#--aws-msk-ingestion-service-accountzWGoogle Cloud service account to be used for Federated Identity authentication with MSK.zDFlags that specify settings for an import topic from Confluent CloudzConfluentCloud Sourcez,--confluent-cloud-ingestion-bootstrap-serverz9Confluent Cloud bootstrap server. The format is url:port.z&--confluent-cloud-ingestion-cluster-idzConfluent Cloud cluster ID.z!--confluent-cloud-ingestion-topicz@Name of the Confluent Cloud topic that Pub/Sub will import from.z,--confluent-cloud-ingestion-identity-pool-idzWIdentity pool ID to be used for Federated Identity authentication with Confluent Cloud.z+--confluent-cloud-ingestion-service-accountzcGoogle Cloud service account to be used for Federated Identity authentication with Confluent Cloud.)	r;   r$   INGESTION_NOT_SUPPORTED_IN_TPCr   r   r   r   r   r>   )r    r   rj   clear_settings_groupingestion_source_settings_groupingestion_data_source_groupaws_kinesis_groupcloud_storage_groupazure_event_hubs_groupaws_msk_groupconfluent_cloud_groups              r   AddIngestionDatasourceFlagsr     s    -(EE! F  #8N4	 )M$1$D$D''% ##@)L	M
 7 %E 	%! &BBD  2DD''5 ##6	B	C
 7 E 	   &?	 !    (  !    $  !    +*  !  4FF'' ##8)D	E
 7  G 
 ""(<	 #  ""./1	 < #  ""0L	 #  ""<)  #  "",?  #  ".. /	 /  7II'' ##:IF	G
 7 J 	 %%3O	 &  %%.B	 &  %%.7	 &  %%.=	 &  %%.=	 &  %%4C	 &  %%43  &  .@@''M ##3Y?	@
 7 A 	- ':	   !A	   (    +&    6HH''! ##:IF	G
 7 I 	 $$4F	 %  $$.(	 %  $$)M	 %  $$42  %  $$32  % r   c                     U R                  SSSS9nUR                  S[        SS9  UR                  S[        R                  " 5       SS9  U R                  S	[        S
SS9  g)zOAdds the flags for the Schema Definition.

Args:
  parser: The argparse parser
TzSchema definitionrc   z--definitionz!The new definition of the schema.rP   z--definition-filez*File containing the new schema definition.z--typezThe type of the schema.r9   r   r'   N)r]   r   r   r   FileContents)r    rl   s     r   AddCommitSchemaFlagsr    s     %%*T &  3%H    ##%7   
 	S84  r   c                     U nU(       a  U R                  5       n[        USSSSS9  UnUR                  S[        R                  " SSS	9S
R                  [        5      S9  g)zAdd flags for the topic message retention property to the parser.

Args:
  parser: The argparse parser.
  is_update: Whether the operation is for updating message retention.
z clear-message-retention-durationrX   Nz<If set, clear the message retention duration from the topic.rY   rv   rq   rr   rs   aC            Indicates the minimum duration to retain a message after it is
          published to the topic. If this field is set, messages published to
          the topic in the last MESSAGE_RETENTION_DURATION are always available
          to subscribers. For instance, it allows any attached subscription to
          seek to a timestamp that is up to MESSAGE_RETENTION_DURATION in the
          past. If this field is not set, message retention is controlled by
          settings on individual subscriptions. The minimum is 10 minutes and
          the maximum is 31 days. {}rP   )r;   r$   r   r   rx   r:   ry   )r    r   rj   rk   s       r   AddTopicMessageRetentionFlagsr    sq     -#@@B%4T +M$EuE( )//@(A  r   c                    U nS[        SU5      -   nU(       a(  UR                  SSS9nUR                  SSSS	9  UnU S
3nUR                  US9nUR                  SS[        R
                  " 5       SSS9  UR                  SSSS	9  g)zAdd flags for the Message Storage Policy.

Args:
  parser: The argparse parser.
  is_update: Whether the operation is for updating message storage policy.
zOptions for explicitly specifying the [message storage policy](https://cloud.google.com/pubsub/docs/resource-location-restriction) for a topic.MessageStoragePolicyTzMessage storage policy options.rZ   z"--recompute-message-storage-policyrX   zIf given, Pub/Sub recomputes the regions where messages can be stored at rest, based on your organization's "Resource  Location Restriction" policy.)r7   r   zZ These fields can be set only if the `--recompute-message-storage-policy` flag is not set.rK   z(--message-storage-policy-allowed-regionsREGIONzTA list of one or more Cloud regions where messages are allowed to be stored at rest.)r8   r9   r'   r   z+--message-storage-policy-enforce-in-transitzWhether or not to enforce in-transit guarantees for this topic using the allowed regions. This ensures that publishing, pulling, and push delivery are only handled in allowed Cloud regions.N)r   r]   r   r   r   r>   )r    r   rj   help_messagerecompute_msp_groupexplicit_msp_groups         r   !AddTopicMessageStoragePolicyFlagsr  =  s     - 3Y?	@, '11: 2  $$,-	 %  (M. A 	A 
 %77l7L!!0   " 	 !!3J	 " r   c                 |    U nU(       a  U R                  5       n[        USSSS9  UnUR                  S[        SS9  g)	zAdd flags for the Message Transforms.

Args:
  parser: The argparse parser.
  is_update: Whether the operation is for updating message transforms.
zclear-message-transformsrX   z,If set, clears the message transforms field.rh   --message-transforms-file8Path to YAML or JSON file containing message transforms.rP   N)r;   r$   r   r   )r    r   rj   r   s       r   AddMessageTransformsFlagsr  t  sQ     -557K,@	  M!E  r   c                 0    U R                  S[        SSS9  g)zRAdd flags for message transform validation.

Args:
  parser: The argparse parser.
z--message-transform-filez9Path to YAML or JSON file containing a message transform.Tr  N)r   r   rM   s    r    AddValidateMessageTransformFlagsr    s#     	 F	  r   c                    U R                  SSS9nUR                  SSS9  UR                  S[        R                  " [        S9S	S
R                  [        5      S9  U R                  SS9nUR                  S[        SS9  Sn[        R                  " USSS9n[        R                  " USSS9n[        R                  " X$U/5        g)zPAdd flags for testing message transforms.

Args:
  parser: The argparse parser.
z/Message to test the message transforms against.Tr   r   z4Message body to test the message transforms against.rK   r   r   	ATTRIBUTEzComma-separated list of attributes to attach to the message. Each ATTRIBUTE has the form name="value". You can specify up to {0} attributes.)r9   r8   r   r&   r  r  rP   zIfrom which the message transforms are taken to be applied to the message.F)r   r'   )r'   r   N)r   r   r   r   r   r:   r;   r   r
   r   CreateSubscriptionResourceArgr   )r    message_groupr   r!   topicsubscriptions         r   AddTestMessageTransformFlagsr    s     ++<t , - N   .9/  	 33T3B+!E   
 
.
.EE% <<%E, \-BCr   c                     U R                   (       a(  U R                  (       a  [        R                  " SS5      eU R                   b*  [        R
                  " [        R                  SS5      5        U R                   =(       d    U R                  $ )a  Gets the message body from args.

This is only necessary because we are deprecating the positional `ack_id`.
Putting the positional and a flag in an argument group, will group flag
under positional args. This would be confusing.

DeprecationAction can't be used here because the positional argument is
optional (nargs='?') Since this means zero or more, the DeprecationAction
warn message is always triggered.

This function does not exist in util.py in order to group the explanation for
why this exists with the deprecated flags.

Once the positional is removed, this function can be removed.

Args:
  args (argparse.Namespace): Parsed arguments

Returns:
  Optional[str]: message body.
r   r   )r   messager	   ConflictingArgumentsExceptionr   rC   r=   r:   rG   s    r   ParseMessageBodyr    sa    , 
4<<

2
2>;
OO	"KK&--nkJK				*dll*r   c                 p    U R                   b)  U R                   (       d  [        R                  " SS5      egg)zRaises an exception if filter string is empty.

Args:
  args (argparse.Namespace): Parsed arguments

Raises:
  InvalidArgumentException: if filter string is empty.
Nr   zgFilter string must be non-empty. If you do not want a filter, do not set the --message-filter argument.)message_filterr	   InvalidArgumentExceptionr  s    r   ValidateFilterStringr#    s<     
$T-@-@

-
-	6  .A$r   c                 x    U R                   (       a)  U R                  (       d  [        R                  " SS5      egg)zRaises an exception if args has invalid dead letter arguments.

Args:
  args (argparse.Namespace): Parsed arguments

Raises:
  RequiredArgumentException: if max_delivery_attempts is set without
    dead_letter_topic being present.
DEAD_LETTER_TOPICz--dead-letter-topicN)max_delivery_attemptsr   r	   RequiredArgumentExceptionr  s    r   ValidateDeadLetterPolicyr(    s6     
(>(>

.
.2  )?r   c           
          UR                  5        HK  u  p4[        XS5      (       d  M  [        R                  " US[        R                  USS5      -   S-   U-   5      e   g )NFr   r.   -% is not available in universe_domain )itemsgetattrr	   r"  r   replace)rG   universe_domainfeature_mapr   exception_strs        r   _RaiseExceptionIfContainsr2    se    "-"3"3"5it&&//

KK	3,-34   #6r   c                     [         R                  " 5       (       a  g[         R                  " 5       n[        R                  " [
        R                  U 5      U S-   U-   5      e)zRaises an exception if it's not in default universe.

Args:
  command: Parsed command

Raises:
  InvalidArgumentException: if the command is disabled in current universe.
Nr+  )r   IsDefaultUniverseGetUniverseDomainr	   r"  r   upper)commandr/  s     r   ValidateIsDefaultUniverser8    sQ     !!##
002/++	ii77/I	 r   c                 p    SnU R                  SS[        R                  " 5       [        R                  US9  g)z#Adds the --tags flag to the parser.zList of tags KEY=VALUE pairs to bind. Each item must be expressed as `<tag-key-namespaced-name>=<tag-value-short-name>`.
Example: `123/environment=production,123/costCenter=marketing`z--tagsz	KEY=VALUE)r8   r9   r7   r   N)r   r   r   UpdateAction)r    r!   s     r   AddTagsFlagr;  !  s@    G 
 	 %%  r   c                     [        XS5      nU(       d  gU" [        [        R                  " U5      5       VVs/ s H  u  pEUR	                  XES9PM     snnS9$ s  snnf )zMakes the tags message object.N)keyr   )additionalProperties)r-  sortedsix	iteritemsAdditionalProperty)rG   tags_messagetags_arg_nametagsr=  r   s         r   GetTagsMessagerF  1  sa    	d	+$		 #3==#677jc 
)
)c
)
?7
 s   A
r   )F)FFF)FF)rE  )B__doc__
__future__r   r   r   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.callioper   r   r	   !googlecloudsdk.command_lib.pubsubr
   r   googlecloudsdk.corer   r   r@  r   r=   ry   r   r   r   r   r   r   r   r   r   r   boolr   r   r$   rA   rH   rN   rT   r`   rm   ro   r|   r~   r   r   r   rw   r   r   r   r   r   r  r  r  r  r  r  r  r#  r(  r2  r8  r;  rF  r   r   r   <module>rN     sv    A &  ' 7 + / . ; 2 # * 
  I @  )M %)N &+ ( %E !$M !8 !> 6 % < *
  7><< JO;~ LQL^	'T&_DXv.b< Yx,^;@ eP	,D4n0'DT+<" 	$ r   