
    ~                         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
rSrSrSrSrSrSrSrSrSr/ r " S S\R4                  5      rSS jrSS jr " S S\5      r " S S\5      r g)z.Utilities for Cloud Pub/Sub Subscriptions API.    )absolute_import)division)unicode_literals)
list_pager)utils)apis)iam_util)
exceptions20zX-Server-Timeoutdefaultneverclearc                       \ rS rSrSrSrg)NoFieldsSpecifiedError)   z:Error when no fields were specified for a Patch operation. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       2lib/googlecloudsdk/api_lib/pubsub/subscriptions.pyr   r   )   s    Br   r   c                 .    [         R                  " SSU S9$ )Npubsubv1no_http)r   GetClientInstancer   s    r   r    r    -   s    			$	@@r   Nc                 @    U =(       d
    [        5       n U R                  $ N)r    MESSAGES_MODULE)clients    r   GetMessagesModuler%   1   s    (&(&			r   c                       \ rS rSrSrS rSrg)_SubscriptionUpdateSetting6   z1Data container class for updating a subscription.c                     Xl         X l        g r"   
field_namevalue)selfr+   r,   s      r   __init__#_SubscriptionUpdateSetting.__init__9   s     OJr   r*   N)r   r   r   r   r   r.   r   r   r   r   r'   r'   6   s
    9r   r'   c                   n   \ rS rSrSrS!S jrS rS r                                   S"S jrS r	S#S	 jr
S
 rS rS$S jrS!S j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 r                                        S%S jrS rS rS rS r S r!g)&SubscriptionsClient>   z:Client for subscriptions service in the Cloud Pub/Sub API.Nc                     U=(       d
    [        5       U l        U=(       d    [        U5      U l        U R                  R                  U l        g r"   )r    r$   r%   messagesprojects_subscriptions_service)r-   r$   r4   s      r   r.   SubscriptionsClient.__init__A   s5    /-/DK9 1& 9DMKK66DMr   c                     U R                   R                  U R                   R                  US9UR                  5       S9nU R                  R                  U5      $ )zAcknowledges one or messages for a Subscription.

Args:
  ack_ids (list[str]): List of ack ids for the messages being ack'd.
  subscription_ref (Resource): Relative name of the subscription for which
    to ack messages for.

Returns:
  None:
)ackIds)acknowledgeRequestsubscription)r4   -PubsubProjectsSubscriptionsAcknowledgeRequestAcknowledgeRequestRelativeNamer6   Acknowledge)r-   ack_idssubscription_refack_reqs       r   AckSubscriptionsClient.AckF   sV     mmII==;;7;K%224 J G
 ==$$W--r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zGets a Subscription from the API.

Args:
  subscription_ref (Resource): Relative name of the subscription to get.

Returns:
  Subscription: the subscription.
r;   )r4   %PubsubProjectsSubscriptionsGetRequestr>   r6   Get)r-   rA   get_reqs      r   rH   SubscriptionsClient.GetX   sA     mmAA%224 B G ==W%%r   c'                    U R                   R                  UR                  5       UR                  5       UUUUUU R                  X5      U
UU R	                  X5      U R                  X5      UU R                  UUUUUU5      U R                  UUUUUUUUUU U!5      U R                  U"U#5      S9n'U$(       a2   [        R                  " U R                   R                  U$U&5      U'l        U%(       a  U%U'l        U R&                  R)                  U'5      $ ! [        R                  [        R                  [        R                  4 a"  n([        R                   " U(5      4U(l        e Sn(A(ff = f)a$  Creates a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    created.
  topic_ref (Resource): Resource reference for the associated topic for the
    subscriptions.
  ack_deadline (int): Number of seconds the system will wait for a
    subscriber to ack a message.
  push_config (Message): Message containing the push endpoint for the
    subscription.
  retain_acked_messages (bool): Whether or not to retain acked messages.
  message_retention_duration (int): How long to retained unacked messages.
  labels (Subscriptions.LabelsValue): The labels for the request.
  no_expiration (bool): Whether or not to set no expiration on subscription.
  expiration_period (str): TTL on expiration_policy.
  enable_message_ordering (bool): Whether or not to deliver messages with
    the same ordering key in order.
  filter_string (str): filter string in the Cloud Pub/Sub filter language.
  dead_letter_topic (str): Topic for publishing dead messages.
  max_delivery_attempts (int): Threshold of failed deliveries before sending
    message to the dead letter topic.
  min_retry_delay (str): The minimum delay between consecutive deliveries of
    a given message.
  max_retry_delay (str): The maximum delay between consecutive deliveries of
    a given message.
  enable_exactly_once_delivery (bool): Whether or not to set exactly once
    delivery on the subscription.
  bigquery_table (str): BigQuery table to which to write
  use_topic_schema (bool): Whether or not to use the topic schema when
    writing to BigQuery
  use_table_schema (bool): Whether or not to use the table schema when
    writing to BigQuery
  write_metadata (bool): Whether or not to write metadata fields when
    writing to BigQuery
  drop_unknown_fields (bool): Whether or not to drop fields that are only in
    the topic schema when writing to BigQuery
  bigquery_service_account_email (str): The service account to use when
    writing to BigQuery
  cloud_storage_bucket (str): The name for the Cloud Storage bucket.
  cloud_storage_file_prefix (str): The prefix for Cloud Storage filename.
  cloud_storage_file_suffix (str): The suffix for Cloud Storage filename.
  cloud_storage_file_datetime_format (str): The custom datetime format
    string for Cloud Storage filename.
  cloud_storage_max_bytes (int): The maximum bytes that can be written to a
    Cloud Storage file before a new file is created.
  cloud_storage_max_duration (str): The maximum duration that can elapse
    before a new Cloud Storage file is created.
  cloud_storage_max_messages (int): The maximum number of messages that can
    be written to a Cloud Storage file before a new file is created.
  cloud_storage_output_format (str): The output format for data written to
    Cloud Storage.
  cloud_storage_use_topic_schema (bool): Whether or not to use the topic
    schema when writing to Cloud Storage.
  cloud_storage_write_metadata (bool): Whether or not to write the
    subscription name and other metadata in the output.
  cloud_storage_service_account_email (str): The service account to use when
    writing to Cloud Storage
  pubsub_export_topic (str): The Pubsub topic to which to publish messages.
  pubsub_export_topic_region (str): The Cloud region to which to publish
    messages.
  message_transforms_file (str): The file path to the JSON or YAML file
    containing the message transforms.
  tags (TagsValue): The tags Keys/Values to be bound to the subscription.
  enable_vertex_ai_smt (bool): Whether or not to enable Vertex AI message
    transforms.

Returns:
  Subscription: the created subscription
)nametopicackDeadlineSeconds
pushConfigretainAckedMessageslabelsmessageRetentionDurationexpirationPolicyenableMessageOrderingfilterdeadLetterPolicyretryPolicyenableExactlyOnceDeliverybigqueryConfigcloudStorageConfigpubsubExportConfigN)r4   Subscriptionr>   _ExpirationPolicy_DeadLetterPolicy_RetryPolicy_BigQueryConfig_CloudStorageConfig_PubsubExportConfigr   GetMessageTransformsFromFileMessageTransformmessageTransforms#MessageTransformsInvalidFormatErrorMessageTransformsEmptyFileError!MessageTransformsMissingFileErrorGetErrorMessageargstagsr6   Create))r-   rA   	topic_refack_deadlinepush_configretain_acked_messagesmessage_retention_durationrQ   no_expirationexpiration_periodenable_message_orderingfilter_stringdead_letter_topicmax_delivery_attemptsmin_retry_delaymax_retry_delayenable_exactly_once_deliverybigquery_tableuse_topic_schemause_table_schemawrite_metadatadrop_unknown_fieldsbigquery_service_account_emailcloud_storage_bucketcloud_storage_file_prefixcloud_storage_file_suffix"cloud_storage_file_datetime_formatcloud_storage_max_bytescloud_storage_max_durationcloud_storage_max_messagescloud_storage_output_formatcloud_storage_use_topic_schemacloud_storage_write_metadata#cloud_storage_service_account_emailpubsub_export_topicpubsub_export_topic_regionmessage_transforms_filerk   enable_vertex_ai_smtr;   es)                                            r   rl   SubscriptionsClient.Createg   s   ^ ==--**,$$&'1!;//
 6//
 %%oG">++*
  33 %%.#&&'*(/
  33!;
O . *LV ).)K)KMM**# *
& l==-- 
3
3

/
/

1
1 
 ''*,s   71D 3E&E!!E&c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    deleted.

Returns:
  None:
rF   )r4   (PubsubProjectsSubscriptionsDeleteRequestr>   r6   Delete)r-   rA   
delete_reqs      r   r   SubscriptionsClient.Delete  sA     GG%224 H J ==
++r   c                     U R                   R                  UR                  5       US9n[        R                  " U R
                  UUSSS9$ )a2  Lists Subscriptions for a given project.

Args:
  project_ref (Resource): Resource reference to Project to list
    subscriptions from.
  page_size (int): the number of entries in each batch (affects requests
    made, but not the yielded results).

Returns:
  A generator of subscriptions in the project.
)projectpageSizesubscriptionsr   )
batch_sizefieldbatch_size_attribute)r4   &PubsubProjectsSubscriptionsListRequestr>   r   YieldFromListr6   )r-   project_ref	page_sizelist_reqs       r   ListSubscriptionsClient.List$  sT     }}CC((*Y D H ##' r   c                     U R                   R                  U R                   R                  X2S9UR                  5       S9nU R                  R                  U5      $ )a  Modifies the ack deadline for messages for a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    modified.
  ack_ids (list[str]): List of ack ids to modify.
  ack_deadline (int): The new ack deadline for the messages.

Returns:
  None:
)rN   r9   )modifyAckDeadlineRequestr;   )r4   3PubsubProjectsSubscriptionsModifyAckDeadlineRequestModifyAckDeadlineRequestr>   r6   ModifyAckDeadline)r-   rA   r@   rn   mod_reqs        r   r   %SubscriptionsClient.ModifyAckDeadline;  s^     mmOO!%!G!G+ "H "
 &224	 P G ==**733r   c                     U R                   R                  U R                   R                  US9UR                  5       S9nU R                  R                  U5      $ )zModifies the push endpoint for a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    modified.
  push_config (Message): The new push endpoint for the Subscription.

Returns:
  None:
)rO   )modifyPushConfigRequestr;   )r4   2PubsubProjectsSubscriptionsModifyPushConfigRequestModifyPushConfigRequestr>   r6   ModifyPushConfig)r-   rA   ro   r   s       r   r   $SubscriptionsClient.ModifyPushConfigP  s^     mmNN $ E E" !F !
 &224	 O G ==))'22r   c                 2   U R                   R                  U R                   R                  X#S9UR                  5       S9n[        U R
                  R                  [        '   U R                  R                  U5      nU R
                  R                  [        	 U$ )a  Pulls one or more messages from a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    pulled from.
  max_messages (int): The maximum number of messages to retrieve.
  return_immediately (bool): Whether or not to return immediately without
    waiting for a new message for a bounded amount of time if there is
    nothing to pull right now.

Returns:
  PullResponse: proto containing the received messages.
)maxMessagesreturnImmediately)pullRequestr;   )
r4   &PubsubProjectsSubscriptionsPullRequestPullRequestr>   PULL_RPC_DEADLINE_SECONDSr$   additional_http_headersSERVER_TIMEOUT_HEADERr6   Pull)r-   rA   max_messagesreturn_immediatelypull_req	pull_resps         r   r   SubscriptionsClient.Pullc  s     }}CCMM--$ . 
 &224	 D H 	" 	KK''(=> ""8,I++,ABr   c                     U=(       a    UR                  5       nU R                  R                  U R                  R                  XBS9UR                  5       S9nU R                  R                  U5      $ )a  Reset a Subscription's backlog to point to a given time or snapshot.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    seeked on.
  time (str): The time to reset to.
  snapshot_ref (Resource): Resource reference to a snapshot..

Returns:
  None:
)snapshottime)seekRequestr;   )r>   r4   &PubsubProjectsSubscriptionsSeekRequestSeekRequestr6   Seek)r-   rA   r   snapshot_refr   seek_reqs         r   r   SubscriptionsClient.Seek~  si     ; 9 9 ;H}}CCMM--x-K%224 D H ==h''r   c                     U(       a  U R                   R                  SS9$ U(       a  U R                   R                  US9$ g)zBuild ExpirationPolicy message from argument values.

Args:
  no_expiration (bool): Whether or not to set no expiration on subscription.
  expiration_period (str): TTL on expiration_policy.

Returns:
  ExpirationPolicy message or None.
N)ttl)r4   ExpirationPolicy)r-   rr   rs   s      r   r]   %SubscriptionsClient._ExpirationPolicy  s>     ]]+++55]]++0A+BBr   c                 F    U(       a  U R                   R                  UUS9$ g)a  Builds DeadLetterPolicy message from argument values.

Args:
  dead_letter_topic (str): Topic for publishing dead messages.
  max_delivery_attempts (int): Threshold of failed deliveries before sending
    message to the dead letter topic.

Returns:
  DeadLetterPolicy message or None.
)deadLetterTopicmaxDeliveryAttemptsN)r4   DeadLetterPolicy)r-   rv   rw   s      r   r^   %SubscriptionsClient._DeadLetterPolicy  s.     ]]+++3 ,   r   c                 R    U(       d  U(       a  U R                   R                  XS9$ g)a*  Builds RetryPolicy message from argument values.

Args:
  min_retry_delay (str): The minimum delay between consecutive deliveries of
    a given message.
  max_retry_delay (str): The maximum delay between consecutive deliveries of
    a given message.

Returns:
  DeadLetterPolicy message or None.
)minimumBackoffmaximumBackoffN)r4   RetryPolicy)r-   rx   ry   s      r   r_    SubscriptionsClient._RetryPolicy  s-     /]]&&( '   r   c           	      N    U(       a  U R                   R                  UUUUUUS9$ g)a  Builds BigQueryConfig message from argument values.

Args:
  table (str): The name of the table
  use_topic_schema (bool): Whether or not to use the topic schema
  use_table_schema (bool): Whether or not to use the table schema
  write_metadata (bool): Whether or not to write metadata fields
  drop_unknown_fields (bool): Whether or not to drop fields that are only in
    the topic schema
  service_account_email(str): The service account to use

Returns:
  BigQueryConfig message or None
)tableuseTopicSchemauseTableSchemawriteMetadatadropUnknownFieldsserviceAccountEmailN)r4   BigQueryConfig)r-   r   r|   r}   r~   r   service_account_emails          r   r`   #SubscriptionsClient._BigQueryConfig  s:    . ]]))))&/3 *   r   c                    U(       a  U R                   R                  UUUUUUUUS9nUS:X  a!  U R                   R                  5       Ul        U$ US:X  a1  U R                   R	                  U
(       a  U
OSU	(       a  U	OSS9Ul        U$ g)a5  Builds CloudStorageConfig message from argument values.

Args:
  bucket (str): The name for the Cloud Storage bucket.
  file_prefix (str): The prefix for Cloud Storage filename.
  file_suffix (str): The suffix for Cloud Storage filename.
  file_datetime_format (str): The custom datetime format string for Cloud
    Storage filename.
  max_bytes (int): The maximum bytes that can be written to a Cloud Storage
    file before a new file is created.
  max_duration (str): The maximum duration that can elapse before a new
    Cloud Storage file is created.
  max_messages (int): The maximum number of messages that can be written to
    a Cloud Storage file before a new file is created.
  output_format (str): The output format for data written to Cloud Storage.
  use_topic_schema (bool): Whether or not to use the topic schema when
    writing to Cloud Storage.
  write_metadata (bool): Whether or not to write the subscription name and
    other metadata in the output.
  service_account_email(str): The service account to use

Returns:
  CloudStorageConfig message or None
)bucketfilenamePrefixfilenameSuffixfilenameDatetimeFormatmaxBytesmaxDurationr   r   textavroFN)r   r   )r4   CloudStorageConfig
TextConfig
textConfig
AvroConfig
avroConfig)r-   r   file_prefixfile_suffixfile_datetime_format	max_bytesmax_durationr   output_formatr|   r~   r   cloud_storage_configs                r   ra   'SubscriptionsClient._CloudStorageConfig  s    L !]]==$$!5""3 > 	 
&	 *.--*B*B*D' "! F"*.--*B*B,:. 0@+T	 +C +
' "!r   c                 D    U(       a  U R                   R                  XS9$ g)zBuilds PubsubExportConfig message from argument values.

Args:
  topic (str): The Pubsub topic to which to publish messages.
  region (str): The Cloud region to which to publish messages.

Returns:
  PubsubExportConfig message or None
)rM   regionN)r4   PubSubExportConfig)r-   rM   r   s      r   rb   'SubscriptionsClient._PubsubExportConfig%  s"     ]]--E-IIr   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,   DEFAULT_MESSAGE_RETENTION_VALUEr-   update_settings     r   _HandleMessageRetentionUpdate1SubscriptionsClient._HandleMessageRetentionUpdate3  s    >>!n ?r   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,   CLEAR_DEAD_LETTER_VALUEr   s     r   _HandleDeadLetterPolicyUpdate1SubscriptionsClient._HandleDeadLetterPolicyUpdate7  s    66!n 7r   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,   CLEAR_RETRY_VALUEr   s     r   _HandleRetryPolicyUpdate,SubscriptionsClient._HandleRetryPolicyUpdate;  s    00!n 1r   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,   CLEAR_BIGQUERY_CONFIG_VALUEr   s     r   _HandleBigQueryConfigUpdate/SubscriptionsClient._HandleBigQueryConfigUpdate?  s    ::!n ;r   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,    CLEAR_CLOUD_STORAGE_CONFIG_VALUEr   s     r   _HandleCloudStorageConfigUpdate3SubscriptionsClient._HandleCloudStorageConfigUpdateC      ??!n @r   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,   "CLEAR_PUSH_NO_WRAPPER_CONFIG_VALUEr   s     r   _HandlePushNoWrapperUpdate.SubscriptionsClient._HandlePushNoWrapperUpdateG  s    AA!n Br   c                 <    UR                   [        :X  a  S Ul         g g r"   )r,    CLEAR_PUBSUB_EXPORT_CONFIG_VALUEr   s     r   _HandlePubsubExportConfigUpdate3SubscriptionsClient._HandlePubsubExportConfigUpdateK  r  r   c*                 (   U"(       a  [         n*OU R                  UUUUUUUUUU U!5      n*U(       a  [        n+OU R                  X5      n+U(       a  [        n,OU R                  X5      n,U(       a  [        n-OU R                  UUUUUU5      n-U&(       a  [        n.OU R                  U$U%5      n.U#(       a  [        n/OSn/U'(       a.   [        R                  " U R                  R                  U'U)5      n0OSn0U((       a  [(        n2OSn2[+        SU5      [+        SU5      [+        SU5      [+        SU5      [+        SU5      [+        SU5      [+        SU R-                  Xx5      5      [+        S	U+5      [+        S
U,5      [+        SU-5      [+        SU*5      [+        SU/5      [+        SU.5      [+        SU05      [+        SU25      /n3U R                  R/                  UR1                  5       S9n4/ n5U3 GHW  n6U6R2                  c  M  U6R4                  S:X  a  U R7                  U65        U6R4                  S	:X  a  U R9                  U65        U6R4                  S
:X  a  U R;                  U65        U6R4                  S:X  a  U R=                  U65        U6R4                  S:X  a  U R?                  U65        U6R4                  S:X  a  U RA                  U65        U6R4                  S:X  a2  U RC                  U65        Uc  U5RE                  U6R4                  5        GM  [G        U4U6R4                  U6R2                  5        U5RE                  U6R4                  5        GMZ     U5(       d  [I        S5      eU R                  RK                  U R                  RM                  U4SRO                  U55      S9UR1                  5       S9n7U RP                  RS                  U75      $ ! [        R                  [        R                   [        R"                  4 a"  n1[        R$                  " U15      4U1l        e Sn1A1ff = f)a  Updates a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to be
    updated.
  ack_deadline (int): Number of seconds the system will wait for a
    subscriber to ack a message.
  push_config (Message): Message containing the push endpoint for the
    subscription.
  retain_acked_messages (bool): Whether or not to retain acked messages.
  message_retention_duration (str): How long to retained unacked messages.
  labels (LabelsValue): The Cloud labels for the subscription.
  no_expiration (bool): Whether or not to set no expiration on subscription.
  expiration_period (str): TTL on expiration_policy.
  dead_letter_topic (str): Topic for publishing dead messages.
  max_delivery_attempts (int): Threshold of failed deliveries before sending
    message to the dead letter topic.
  clear_dead_letter_policy (bool): If set, clear the dead letter policy from
    the subscription.
  min_retry_delay (str): The minimum delay between consecutive deliveries of
    a given message.
  max_retry_delay (str): The maximum delay between consecutive deliveries of
    a given message.
  clear_retry_policy (bool): If set, clear the retry policy from the
    subscription.
  enable_exactly_once_delivery (bool): Whether or not to set exactly once
    delivery on the subscription.
  bigquery_table (str): BigQuery table to which to write
  use_topic_schema (bool): Whether or not to use the topic schema when
    writing to BigQuery
  use_table_schema (bool): Whether or not to use the table schema when
    writing to BigQuery
  write_metadata (bool): Whether or not to write metadata fields when
    writing to BigQuery
  drop_unknown_fields (bool): Whether or not to drop fields that are only in
    the topic schema when writing to BigQuery
  bigquery_service_account_email (str): The service account to use when
    writing to BigQuery
  clear_bigquery_config (bool): If set, clear the BigQuery config from the
    subscription
  cloud_storage_bucket (bool): The name for the Cloud Storage bucket.
  cloud_storage_file_prefix (str): The prefix for Cloud Storage filename.
  cloud_storage_file_suffix (str): The suffix for Cloud Storage filename.
  cloud_storage_file_datetime_format (str): The custom datetime format
    string for Cloud Storage filename.
  cloud_storage_max_bytes (int): The maximum bytes that can be written to a
    Cloud Storage file before a new file is created.
  cloud_storage_max_duration (str): The maximum duration that can elapse
    before a new Cloud Storage file is created.
  cloud_storage_max_messages (int): The maximum number of messages that can
    be written to a Cloud Storage file before a new file is created.
  cloud_storage_output_format (str): The output format for data written to
    Cloud Storage.
  cloud_storage_use_topic_schema (bool): Whether or not to use the topic
    schema when writing to Cloud Storage.
  cloud_storage_write_metadata (bool): Whether or not to write the
    subscription name and other metadata in the output.
  cloud_storage_service_account_email (str): The service account to use when
    writing to Cloud Storage
  clear_cloud_storage_config (bool): If set, clear the Cloud Storage config
    from the subscription.
  clear_push_no_wrapper_config (bool): If set, clear the Push No Wrapper
    config from the subscription.
  pubsub_export_topic (str): The Pubsub topic to which to publish messages.
  pubsub_export_topic_region (str): The Cloud region to which to publish
    messages.
  clear_pubsub_export_config (bool): If set, clear the Pubsub export config
    from the subscription.
  message_transforms_file (str): The file path to the JSON or YAML file
    containing the message transforms.
  clear_message_transforms (bool): If set, clears all message transforms
    from the subscription.
  enable_vertex_ai_smt (bool): If set, enables Vertex AI message
    transforms.

Returns:
  Subscription: The updated subscription.
Raises:
  NoFieldsSpecifiedError: if no fields were specified.
NrN   rO   rP   rX   rR   rQ   rS   rV   rW   rY   rZ   zpushConfig.noWrapperr[   re   )rL   z*Must specify at least one field to update.,)r;   
updateMask)updateSubscriptionRequestrL   )*r  ra   r  r^   r  r_   r  r`   r  rb   r  r   rc   r4   rd   rf   rg   rh   ri   rj   #CLEAR_MESSAGE_TRANSFORMATIONS_VALUEr'   r]   r\   r>   r,   r+   r  r  r	  r  r  r  r  appendsetattrr   'PubsubProjectsSubscriptionsPatchRequestUpdateSubscriptionRequestjoinr6   Patch)8r-   rA   rn   ro   rp   rq   rQ   rr   rs   rv   rw   clear_dead_letter_policyrx   ry   clear_retry_policyrz   r{   r|   r}   r~   r   r   clear_bigquery_configr   r   r   r   r   r   r   r   r   r   r   clear_cloud_storage_configclear_push_no_wrapper_configr   r   clear_pubsub_export_configr   clear_message_transformsr   cloud_storage_config_settingsdead_letter_policyretry_policybigquery_configpubsub_export_configpush_config_no_wrappermessage_transformsr   clear_messagesupdate_settingsr;   update_maskr   	patch_reqs8                                                           r   r&  SubscriptionsClient.PatchO  s   x "&F#&*&>&>

#
#
,
!
$
$
%
(
&
-'#  211
 &l&&Hl3o,,





(o "=!55
9 $A#"??MM**# 
  :nn 	##7F"<="!#8	
 	#')E	
 	#&(B	
 	#8V4"""=D	
 	##57IJ"=,?"#3_E" "?	
 	#"$:	
 	##79MN"#68JK"#6G9O< ==--**, . L K)				)$$(BB

,
,^
<$$(::

,
,^
<$$5

'
'
7$$(88

*
*>
:$$(<<

.
.~
>$$(<<

.
.~
>$$(>>

)
).
9 ~889
n779M9MN>445) ** "#OPPEE"&--"I"I%#((;2G #J #
 **,	 F I ==y))] 
3
3

/
/

1
1 
 ''*,s   ,N< <3P/PPc                     U R                   R                  UR                  5       U R                   R                  US9S9nU R                  R                  U5      $ )zSets an IAM policy on a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to set
    IAM policy on.
  policy (Policy): The policy to be added to the Subscription.

Returns:
  Policy: the policy which was set.
)policy)resourcesetIamPolicyRequest)r4   .PubsubProjectsSubscriptionsSetIamPolicyRequestr>   SetIamPolicyRequestr6   SetIamPolicy)r-   rA   r;  requests       r   r@   SubscriptionsClient.SetIamPolicyX  sV     mmJJ!..0 MM==V=L K G ==%%g..r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zGets the IAM policy for a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to get
    the IAM policy of.

Returns:
  Policy: the policy for the Subscription.
)r<  )r4   .PubsubProjectsSubscriptionsGetIamPolicyRequestr>   r6   GetIamPolicy)r-   rA   rA  s      r   rE   SubscriptionsClient.GetIamPolicyi  sA     mmJJ!..0 K G ==%%g..r   c                     U R                  U5      n[        R                  " U R                  R                  XBU5        U R                  X5      $ )a^  Adds an IAM Policy binding to a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to add
    IAM policy binding to.
  member (str): The member to add.
  role (str): The role to assign to the member.

Returns:
  Policy: the updated policy.
Raises:
  api_exception.HttpException: If either of the requests failed.
)rE  r	   AddBindingToIamPolicyr4   Bindingr@  r-   rA   memberroler;  s        r   AddIamPolicyBinding'SubscriptionsClient.AddIamPolicyBindingx  sC     /0F""4==#8#8&$O-66r   c                 t    U R                  U5      n[        R                  " XBU5        U R                  X5      $ )ah  Removes an IAM Policy binding from a Subscription.

Args:
  subscription_ref (Resource): Resource reference for subscription to remove
    IAM policy binding from.
  member (str): The member to add.
  role (str): The role to assign to the member.

Returns:
  Policy: the updated policy.
Raises:
  api_exception.HttpException: If either of the requests failed.
)rE  r	   RemoveBindingFromIamPolicyr@  rJ  s        r   RemoveIamPolicyBinding*SubscriptionsClient.RemoveIamPolicyBinding  s7     /0F''=-66r   )r6   r$   r4   )NN)#NNNNFNNNNNNNNNNNNNNNNNNNNNNNNNNNNNF)d   )T)(NNNNNFNNNFNNFNNNNNNNFNNNNNNNNNNNFFNNFNFF)"r   r   r   r   r   r.   rC   rH   rl   r   r   r   r   r   r   r]   r^   r_   r`   ra   rb   r  r  r	  r  r  r  r  r&  r@  rE  rM  rQ  r   r   r   r   r1   r1   >   s~   B7
.$&(  !%" #'%) $ $)-"!%!%"&%)#'*.!%" Ol.\,.4*3&6(& $$ D<|"""""""  !% $#'%)! $ $)-"!%!%"&%)#'*.!&#(!%!&"$ UG*R/"/7$7r   r1   )Fr"   )!r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.api_lib.utilr   googlecloudsdk.command_lib.iamr	   googlecloudsdk.corer
   r   r   r   NEVER_EXPIRATION_PERIOD_VALUEr  r  r  r  r  r  r   Errorr   r    r%   objectr'   r1   r   r   r   <module>r]     s     5 &  ' ' / , 3 * ! * "+  ' !  % #*  %, "#*  &( #CZ-- CA 
 \7& \7r   