
    ~                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ d
ZdZdZdZdZdZdZdZdZdZg Z G d dej4                        ZddZddZ G d de      Z G d de      Z y)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                       e Zd ZdZy)NoFieldsSpecifiedErrorz:Error when no fields were specified for a Patch operation.N)__name__
__module____qualname____doc__     2lib/googlecloudsdk/api_lib/pubsub/subscriptions.pyr   r   )   s    Br   r   c                 2    t        j                  dd|       S )Npubsubv1no_http)r   GetClientInstancer   s    r   r   r   -   s    			$	@@r   Nc                 6    | xs
 t               } | j                  S N)r   MESSAGES_MODULE)clients    r   GetMessagesModuler"   1   s    (&(&			r   c                       e Zd ZdZd Zy)_SubscriptionUpdateSettingz1Data container class for updating a subscription.c                      || _         || _        y r   )
field_namevalue)selfr&   r'   s      r   __init__z#_SubscriptionUpdateSetting.__init__9   s     DODJr   N)r   r   r   r   r)   r   r   r   r$   r$   6   s
    9r   r$   c                   Z   e Zd ZdZddZd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZd Zd!dZ	d	 Z
d
 Zd"dZddZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZd Zd Zd Zd Zy)$SubscriptionsClientz:Client for subscriptions service in the Cloud Pub/Sub API.Nc                     |xs
 t               | _        |xs t        |      | _        | j                  j                  | _        y r   )r   r!   r"   messagesprojects_subscriptions_service)r(   r!   r-   s      r   r)   zSubscriptionsClient.__init__A   s5    /-/DK9 1& 9DMKK66DMr   c                     | j                   j                  | j                   j                  |      |j                               }| j                  j                  |      S )a  Acknowledges 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)r-   -PubsubProjectsSubscriptionsAcknowledgeRequestAcknowledgeRequestRelativeNamer/   Acknowledge)r(   ack_idssubscription_refack_reqs       r   AckzSubscriptionsClient.AckF   sV     mmII==;;7;K%224 J G
 ==$$W--r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zGets a Subscription from the API.

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

    Returns:
      Subscription: the subscription.
    r3   )r-   %PubsubProjectsSubscriptionsGetRequestr6   r/   Get)r(   r9   get_reqs      r   r?   zSubscriptionsClient.GetX   sA     mmAA%224 B G ==W%%r   c'                    | j                   j                  |j                         |j                         |||||| j                  ||	      |
|| j	                  ||      | j                  ||      || j                  ||||||      | j                  |||||||||| |!      | j                  |"|#            }'|$r1	 t        j                  | j                   j                  |$|&      |'_        |%r|%|'_        | j&                  j)                  |'      S # t        j                  t        j                  t        j                  f$ r!}(t        j                   |(      f|(_         d}(~(ww xY w)a0  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)r-   Subscriptionr6   _ExpirationPolicy_DeadLetterPolicy_RetryPolicy_BigQueryConfig_CloudStorageConfig_PubsubExportConfigr   GetMessageTransformsFromFileMessageTransformmessageTransforms#MessageTransformsInvalidFormatErrorMessageTransformsEmptyFileError!MessageTransformsMissingFileErrorGetErrorMessageargstagsr/   Create))r(   r9   	topic_refack_deadlinepush_configretain_acked_messagesmessage_retention_durationrG   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_filera   enable_vertex_ai_smtr3   es)                                            r   rb   zSubscriptionsClient.Createg   s   ^ ==--**,$$&'1!;//,
 6//4
 %%oG">++*
  33 %%.#&&'*(/
  33!;
O . *LV ).)K)KMM**# *
& l==-- 
3
3

/
/

1
1 
 ''*,s   80D 2E>EEc                     | j                   j                  |j                               }| j                  j	                  |      S )zDeletes a Subscription.

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

    Returns:
      None:
    r=   )r-   (PubsubProjectsSubscriptionsDeleteRequestr6   r/   Delete)r(   r9   
delete_reqs      r   r   zSubscriptionsClient.Delete  sA     GG%224 H J ==
++r   c                     | j                   j                  |j                         |      }t        j                  | j
                  ||dd      S )aR  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)r-   &PubsubProjectsSubscriptionsListRequestr6   r   YieldFromListr/   )r(   project_ref	page_sizelist_reqs       r   ListzSubscriptionsClient.List$  sT     }}CC((*Y D H ##' r   c                     | j                   j                  | j                   j                  ||      |j                               }| j                  j                  |      S )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:
    )rD   r1   )modifyAckDeadlineRequestr3   )r-   3PubsubProjectsSubscriptionsModifyAckDeadlineRequestModifyAckDeadlineRequestr6   r/   ModifyAckDeadline)r(   r9   r8   rd   mod_reqs        r   r   z%SubscriptionsClient.ModifyAckDeadline;  s`     mmOO!%!G!G+G "H "
 &224	 P G ==**733r   c                     | j                   j                  | j                   j                  |      |j                               }| j                  j                  |      S )a   Modifies 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:
    )rE   )modifyPushConfigRequestr3   )r-   2PubsubProjectsSubscriptionsModifyPushConfigRequestModifyPushConfigRequestr6   r/   ModifyPushConfig)r(   r9   re   r   s       r   r   z$SubscriptionsClient.ModifyPushConfigP  s^     mmNN $ E E" !F !
 &224	 O G ==))'22r   c                 @   | j                   j                  | j                   j                  ||      |j                               }t        | j
                  j                  t        <   | j                  j                  |      }| j
                  j                  t        = |S )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)pullRequestr3   )
r-   &PubsubProjectsSubscriptionsPullRequestPullRequestr6   PULL_RPC_DEADLINE_SECONDSr!   additional_http_headersSERVER_TIMEOUT_HEADERr/   Pull)r(   r9   max_messagesreturn_immediatelypull_req	pull_resps         r   r   zSubscriptionsClient.Pullc  s     }}CCMM--$8J . 
 &224	 D H 	" 	KK''(=> ""8,I++,ABr   c                     |xr |j                         }| j                  j                  | j                  j                  ||      |j                               }| j                  j                  |      S )a8  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)seekRequestr3   )r6   r-   &PubsubProjectsSubscriptionsSeekRequestSeekRequestr/   Seek)r(   r9   r   snapshot_refr   seek_reqs         r   r   zSubscriptionsClient.Seek~  sk     ; 9 9 ;H}}CCMM--xd-K%224 D H ==h''r   c                 |    |r| j                   j                  d      S |r| j                   j                  |      S y)a  Build 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)r-   ExpirationPolicy)r(   rh   ri   s      r   rS   z%SubscriptionsClient._ExpirationPolicy  s>     ]]+++55]]++0A+BBr   c                 B    |r| j                   j                  ||      S y)a9  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)r-   DeadLetterPolicy)r(   rl   rm   s      r   rT   z%SubscriptionsClient._DeadLetterPolicy  s.     ]]+++3 ,   r   c                 F    |s|r| j                   j                  ||      S y)aJ  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)r-   RetryPolicy)r(   rn   ro   s      r   rU   z SubscriptionsClient._RetryPolicy  s/     /]]&&( '   r   c                 J    |r!| j                   j                  ||||||      S y)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)r-   BigQueryConfig)r(   r   rr   rs   rt   ru   service_account_emails          r   rV   z#SubscriptionsClient._BigQueryConfig  s:    . ]]))))&/3 *   r   c           
          |rz| j                   j                  ||||||||      }|dk(  r!| j                   j                         |_        |S |dk(  r*| j                   j	                  |
r|
nd|	r|	nd      |_        |S y)a  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   )r-   CloudStorageConfig
TextConfig
textConfig
AvroConfig
avroConfig)r(   r   file_prefixfile_suffixfile_datetime_format	max_bytesmax_durationr   output_formatrr   rt   r   cloud_storage_configs                r   rW   z'SubscriptionsClient._CloudStorageConfig  s    L !]]==$$!5""3 > 	 
&	 *.--*B*B*D' "! F"*.--*B*B,:. 0@+T	 +C +
' "!r   c                 B    |r| j                   j                  ||      S y)a  Builds 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
    )rC   regionN)r-   PubSubExportConfig)r(   rC   r   s      r   rX   z'SubscriptionsClient._PubsubExportConfig%  s$     ]]--E&-IIr   c                 :    |j                   t        k(  rd |_         y y r   )r'   DEFAULT_MESSAGE_RETENTION_VALUEr(   update_settings     r   _HandleMessageRetentionUpdatez1SubscriptionsClient._HandleMessageRetentionUpdate3  s    >>!n ?r   c                 :    |j                   t        k(  rd |_         y y r   )r'   CLEAR_DEAD_LETTER_VALUEr   s     r   _HandleDeadLetterPolicyUpdatez1SubscriptionsClient._HandleDeadLetterPolicyUpdate7  s    66!n 7r   c                 :    |j                   t        k(  rd |_         y y r   )r'   CLEAR_RETRY_VALUEr   s     r   _HandleRetryPolicyUpdatez,SubscriptionsClient._HandleRetryPolicyUpdate;  s    00!n 1r   c                 :    |j                   t        k(  rd |_         y y r   )r'   CLEAR_BIGQUERY_CONFIG_VALUEr   s     r   _HandleBigQueryConfigUpdatez/SubscriptionsClient._HandleBigQueryConfigUpdate?  s    ::!n ;r   c                 :    |j                   t        k(  rd |_         y y r   )r'    CLEAR_CLOUD_STORAGE_CONFIG_VALUEr   s     r   _HandleCloudStorageConfigUpdatez3SubscriptionsClient._HandleCloudStorageConfigUpdateC      ??!n @r   c                 :    |j                   t        k(  rd |_         y y r   )r'   "CLEAR_PUSH_NO_WRAPPER_CONFIG_VALUEr   s     r   _HandlePushNoWrapperUpdatez.SubscriptionsClient._HandlePushNoWrapperUpdateG  s    AA!n Br   c                 :    |j                   t        k(  rd |_         y y r   )r'    CLEAR_PUBSUB_EXPORT_CONFIG_VALUEr   s     r   _HandlePubsubExportConfigUpdatez3SubscriptionsClient._HandlePubsubExportConfigUpdateK  r   r   c*                    |"rt         }*n| j                  |||||||||| |!      }*|rt        }+n| j                  |	|
      }+|rt        },n| j                  ||      },|rt        }-n| j                  ||||||      }-|&rt        }.n| j                  |$|%      }.|#rt        }/nd}/|'r-	 t        j                  | j                  j                  |'|)      }0nd}0|(rt(        }2nd}2t+        d|      t+        d|      t+        d|      t+        d|      t+        d|      t+        d|      t+        d| j-                  ||            t+        d	|+      t+        d
|,      t+        d|-      t+        d|*      t+        d|/      t+        d|.      t+        d|0      t+        d|2      g}3| j                  j/                  |j1                               }4g }5|3D ]K  }6|6j2                  |6j4                  dk(  r| j7                  |6       |6j4                  d	k(  r| j9                  |6       |6j4                  d
k(  r| j;                  |6       |6j4                  dk(  r| j=                  |6       |6j4                  dk(  r| j?                  |6       |6j4                  dk(  r| jA                  |6       |6j4                  dk(  r0| jC                  |6       ||5jE                  |6j4                         tG        |4|6j4                  |6j2                         |5jE                  |6j4                         N |5stI        d      | j                  jK                  | j                  jM                  |4djO                  |5            |j1                               }7| jP                  jS                  |7      S # t        j                  t        j                   t        j"                  f$ r!}1t        j$                  |1      f|1_         d}1~1ww xY w)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.
    NrD   rE   rF   rN   rH   rG   rI   rL   rM   rO   rP   zpushConfig.noWrapperrQ   r[   )rB   z*Must specify at least one field to update.,)r3   
updateMask)updateSubscriptionRequestrB   )*r   rW   r   rT   r   rU   r   rV   r   rX   r   r   rY   r-   rZ   r\   r]   r^   r_   r`   #CLEAR_MESSAGE_TRANSFORMATIONS_VALUEr$   rS   rR   r6   r'   r&   r   r   r   r   r   r   r   appendsetattrr   'PubsubProjectsSubscriptionsPatchRequestUpdateSubscriptionRequestjoinr/   Patch)8r(   r9   rd   re   rf   rg   rG   rh   ri   rl   rm   clear_dead_letter_policyrn   ro   clear_retry_policyrp   rq   rr   rs   rt   ru   rv   clear_bigquery_configrw   rx   ry   rz   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_settingsr3   update_maskr   	patch_reqs8                                                           r   r  zSubscriptionsClient.PatchO  s   x "&F#&*&>&>

#
#
,
!
$
$
%
(
&
-'#  211
2 &l&&Hl3o,,





(o "=!55
9 $A#"??MM**# 
  :nn 	##7F"<="!#8	
 	#')E	
 	#&(B	
 	#8V4"""=2C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 2O ?OO c                     | j                   j                  |j                         | j                   j                  |            }| j                  j                  |      S )a  Sets 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)r-   .PubsubProjectsSubscriptionsSetIamPolicyRequestr6   SetIamPolicyRequestr/   SetIamPolicy)r(   r9   r  requests       r   r!  z SubscriptionsClient.SetIamPolicyX  sV     mmJJ!..0 MM==V=L K G ==%%g..r   c                     | j                   j                  |j                               }| j                  j	                  |      S )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  )r-   .PubsubProjectsSubscriptionsGetIamPolicyRequestr6   r/   GetIamPolicy)r(   r9   r"  s      r   r%  z SubscriptionsClient.GetIamPolicyi  sA     mmJJ!..0 K G ==%%g..r   c                     | j                  |      }t        j                  | j                  j                  |||       | j                  ||      S )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.
    )r%  r	   AddBindingToIamPolicyr-   Bindingr!  r(   r9   memberroler  s        r   AddIamPolicyBindingz'SubscriptionsClient.AddIamPolicyBindingx  sG     /0F""4==#8#8&&$O-v66r   c                 v    | j                  |      }t        j                  |||       | j                  ||      S )a  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.
    )r%  r	   RemoveBindingFromIamPolicyr!  r)  s        r   RemoveIamPolicyBindingz*SubscriptionsClient.RemoveIamPolicyBinding  s;     /0F''=-v66r   )NN)#NNNNFNNNNNNNNNNNNNNNNNNNNNNNNNNNNNF)d   )T)(NNNNNFNNNFNNFNNNNNNNFNNNNNNNNNNNFFNNFNFF) r   r   r   r   r)   r;   r?   rb   r   r   r   r   r   r   rS   rT   rU   rV   rW   rX   r   r   r   r   r   r   r   r  r!  r%  r,  r/  r   r   r   r+   r+   >   s~   B7
.$&(  !%" #'%) $ $)-"!%!%"&%)#'*.!%" Ol.\,.4*3&6(& $$ D<|"""""""  !% $#'%)! $ $)-"!%!%"&%)#'*.!&#(!%!&"$ UG*R/"/7$7r   r+   )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$   r+   r   r   r   <module>r:     s     5 &  ' ' / , 3 * ! * "+  ' !  % #*  %, "#*  &( #CZ-- CA 
 \7& \7r   