
    Z                        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 g Z G d
 dej                         Z G d dej                         Z G d dej                         Z G d dej                         Z G d dej                         Z G d de      ZddZddZd Z G d de      Zy)z'Utilities for Cloud Pub/Sub Topics API.    )absolute_import)division)unicode_literals)
list_pager)utils)apis)iam_util)
exceptionsc                       e Zd ZdZy)PublishOperationExceptionz-Error when something went wrong with publish.N__name__
__module____qualname____doc__     +lib/googlecloudsdk/api_lib/pubsub/topics.pyr   r      s    5r   r   c                       e Zd ZdZy)EmptyMessageExceptionz<Error when no message was specified for a Publish operation.Nr   r   r   r   r   r   !   s    Dr   r   c                       e Zd ZdZy)NoFieldsSpecifiedErrorz:Error when no fields were specified for a Patch operation.Nr   r   r   r   r   r   %   s    Br   r   c                       e Zd ZdZy)InvalidSchemaSettingsExceptionz+Error when the schema settings are invalid.Nr   r   r   r   r   r   )   s    3r   r   c                       e Zd ZdZy)%ConflictingIngestionSettingsExceptionz.Error when the ingestion settings are invalid.Nr   r   r   r   r   r   -   s    6r   r   c                       e Zd ZdZd Zy)_TopicUpdateSettingz*Data container class for updating a topic.c                      || _         || _        y N)
field_namevalue)selfr!   r"   s      r   __init__z_TopicUpdateSetting.__init__4   s     DODJr   N)r   r   r   r   r$   r   r   r   r   r   1   s
    2r   r   c                 2    t        j                  dd|       S )Npubsubv1no_http)r   GetClientInstancer(   s    r   r*   r*   9   s    			$	@@r   Nc                 6    | xs
 t               } | j                  S r    )r*   MESSAGES_MODULE)clients    r   GetMessagesModuler.   =   s    (&(&			r   c                     |j                         }|dk(  r | j                  j                  j                  S |dk(  r | j                  j                  j                  S t        d      )Njsonbinaryz5Unknown message encoding. Options are JSON or BINARY.)lowerSchemaSettingsEncodingValueValuesEnumJSONBINARYr   )messagesmessage_encodingencs      r   ParseMessageEncodingr:   B   s^     #F]""::???
h""::AAA
(? r   c                   V   e Zd ZdZddZd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd Zd Z	d	 Z
dd
ZddZddZ	 ddZd Zd Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)TopicsClientz3Client for topics service in the Cloud Pub/Sub API.Nc                     |xs
 t               | _        |xs t        |      | _        | j                  j                  | _        | j                  j                  | _        y r    )r*   r-   r.   r7   projects_topics_serviceprojects_subscriptions_subscriptions_service)r#   r-   r7   s      r   r$   zTopicsClient.__init__Q   sG    /-/DK9 1& 9DMKK//DM"&++"D"DDr   c                     |r?| j                   j                  | j                   j                  j                  |            S y )N)severity)r7   PlatformLogsSettingsSeverityValueValuesEnum)r#   ingestion_log_severitys     r   #_ParseIngestionPlatformLogsSettingsz0TopicsClient._ParseIngestionPlatformLogsSettingsW   sA    ]]//==55MM$ 0  
 r   c           	         |duxr |duxr
 |duxr |du}|duxr |du}|
duxr" |duxr |duxr |duxr |duxr
 |duxr |du}|duxr |duxr
 |duxr |du}|duxr |duxr |duxr
 |duxr |du}|rK| j                   j                  ||||      } | j                   j                  | | j                  |            S |r| j                   j	                  |||	      }!|dk(  r"| j                   j                  |      |!_        nI|dk(  r | j                   j                         |!_        n$|dk(  r| j                   j                         |!_
        | j                   j                  |!| j                  |      	      S |rN| j                   j                  |
||||||
      }"| j                   j                  |"| j                  |            S |rK| j                   j                  ||||      }#| j                   j                  |#| j                  |            S |rL| j                   j                  |||||      }$| j                   j                  |$| j                  |            S |rt        d      y)zFReturns an IngestionDataSourceSettings message from the provided args.N)	streamArnconsumerArn
awsRoleArngcpServiceAccount)
awsKinesisplatformLogsSettings)bucketminimumObjectCreateTime	matchGlobtext)	delimiteravropubsub_avro)cloudStoragerN   )resourceGroup	namespaceeventHubclientIdtenantIdsubscriptionIdrL   )azureEventHubsrN   )
clusterArntopicrK   rL   )awsMskrN   )bootstrapServer	clusterIdr_   identityPoolIdrL   )confluentCloudrN   z.Must set ingestion settings with log severity.)r7   
AwsKinesisIngestionDataSourceSettingsrG   CloudStorage
TextFormat
textFormat
AvroFormat
avroFormatPubSubAvroFormatpubsubAvroFormatAzureEventHubsAwsMskConfluentCloudr   )%r#   kinesis_ingestion_stream_arnkinesis_ingestion_consumer_arnkinesis_ingestion_role_arn!kinesis_ingestion_service_accountcloud_storage_ingestion_bucket$cloud_storage_ingestion_input_format&cloud_storage_ingestion_text_delimiter2cloud_storage_ingestion_minimum_object_create_time"cloud_storage_ingestion_match_glob)azure_event_hubs_ingestion_resource_group$azure_event_hubs_ingestion_namespace$azure_event_hubs_ingestion_event_hub$azure_event_hubs_ingestion_client_id$azure_event_hubs_ingestion_tenant_id*azure_event_hubs_ingestion_subscription_id*azure_event_hubs_ingestion_service_accountaws_msk_ingestion_cluster_arnaws_msk_ingestion_topicaws_msk_ingestion_aws_role_arn!aws_msk_ingestion_service_account*confluent_cloud_ingestion_bootstrap_server$confluent_cloud_ingestion_cluster_idconfluent_cloud_ingestion_topic*confluent_cloud_ingestion_identity_pool_id)confluent_cloud_ingestion_service_accountrF   
is_kinesisis_cloud_storageis_azure_event_hubsis_mskis_confluent_cloudkinesis_sourcecloud_storage_sourceazure_event_hubs_source
msk_sourceconfluent_cloud_sources%                                        r   !_ParseIngestionDataSourceSettingsz.TopicsClient._ParseIngestionDataSourceSettings`   s   J 
&T	1 	<+47	<'t3	< /d:	  7dB ,D8 
 
3$	> 	E1=	E1=	E 2=	E 2=		E
 8tC	E 8tC  
'd	2 	<$D0	<+47	< /d:	  
44	? 	D1=	D,D8	D 8tC	D 7dB  }}//04/=	 0 n ]]66##GG$  7   
!]]77/"T6 8 
 
.	7*.--*B*B< +C +
' 069*.--*B*B*D'/=@040N0N0P-]]66+#GG$  7   
 $ < <A8777CF != ! ]]660#GG$  7   
==''2'3=	 ( j ]]66#GG$  7   
#}};;D8/CE  <   ]]66/#GG$  7   
 1
:  r   c(                    | j                   j                  |j                         ||      }(|r||(_        |r,| j                   j	                  |      })|r||)_        |)|(_        |r<|r:t        | 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)a  Creates a Topic.

    Args:
      topic_ref (Resource): Resource reference to the Topic to create.
      labels (LabelsValue): Labels for the topic to create.
      kms_key (str): Full resource name of kms_key to set on Topic or None.
      message_retention_duration (str): How long to retain messages published to
        the Topic.
      message_storage_policy_allowed_regions (list[str]): List of Cloud regions
        in which messages are allowed to be stored at rest.
      message_storage_policy_enforce_in_transit (bool): Whether or not to
        enforce in-transit guarantees for this topic using the allowed regions.
      schema (Resource): Full resource name of schema used to validate messages
        published on Topic.
      message_encoding (str): If a schema is set, the message encoding of
        incoming messages to be validated against the schema.
      first_revision_id (str): If a schema is set, the revision id of the oldest
        revision allowed for validation.
      last_revision_id (str): If a schema is set, the revision id of the newest
        revision allowed for validation.
      kinesis_ingestion_stream_arn (str): The Kinesis data stream ARN to ingest
        data from.
      kinesis_ingestion_consumer_arn (str): The Kinesis data streams consumer
        ARN to use for ingestion.
      kinesis_ingestion_role_arn (str): AWS role ARN to be used for Federated
        Identity authentication with Kinesis.
      kinesis_ingestion_service_account (str): The GCP service account to be
        used for Federated Identity authentication with Kinesis
      cloud_storage_ingestion_bucket (str): The Cloud Storage bucket to ingest
        data from.
      cloud_storage_ingestion_input_format (str): the format of the data in the
        Cloud Storage bucket ('text', 'avro', or 'pubsub_avro').
      cloud_storage_ingestion_text_delimiter (optional[str]): delimiter to use
        with text format when partioning the object.
      cloud_storage_ingestion_minimum_object_create_time (optional[str]): only
        Cloud Storage objects with a larger or equal creation timestamp will be
        ingested.
      cloud_storage_ingestion_match_glob (optional[str]): glob pattern used to
        match Cloud Storage objects that will be ingested. If unset, all objects
        will be ingested.
      azure_event_hubs_ingestion_resource_group (str): The name of the resource
        group within an Azure subscription.
      azure_event_hubs_ingestion_namespace (str): The name of the Azure Event
        Hubs namespace.
      azure_event_hubs_ingestion_event_hub (str): The name of the Azure event
        hub.
      azure_event_hubs_ingestion_client_id (str): The client id of the Azure
        Event Hubs application used to authenticate Pub/Sub.
      azure_event_hubs_ingestion_tenant_id (str): The tenant id of the Azure
        Event Hubs application used to authenticate Pub/Sub.
      azure_event_hubs_ingestion_subscription_id (str): The id of the Azure
        Event Hubs subscription.
      azure_event_hubs_ingestion_service_account (str): The GCP service account
        to be used for Federated Identity authentication with Azure Event Hubs.
      aws_msk_ingestion_cluster_arn (str): The ARN that uniquely identifies the
        MSK cluster.
      aws_msk_ingestion_topic (str): The name of the MSK topic that Pub/Sub will
        import from.
      aws_msk_ingestion_aws_role_arn (str): AWS role ARN to be used for
        Federated Identity authentication with MSK.
      aws_msk_ingestion_service_account (str): The GCP service account to be
        used for Federated Identity authentication with MSK.
      confluent_cloud_ingestion_bootstrap_server (str): The address of the
        Confluent Cloud bootstrap server. The format is url:port.
      confluent_cloud_ingestion_cluster_id (str): The id of the Confluent Cloud
        cluster.
      confluent_cloud_ingestion_topic (str): The name of the Confluent Cloud
        topic that Pub/Sub will import from.
      confluent_cloud_ingestion_identity_pool_id (str): The id of the identity
        pool to be used for Federated Identity authentication with Confluent
        Cloud.
      confluent_cloud_ingestion_service_account (str): The GCP service account
        to be used for Federated Identity authentication with Confluent Cloud.
      ingestion_log_severity (optional[str]): The log severity to use for
        ingestion.
      message_transforms_file (str): The file path to the JSON or YAML file
        containing the message transforms.
      tags (TagsValue): The tag Keys/Values to be bound to the topic.
      enable_vertex_ai_smt (bool): Whether or not to enable Vertex AI message
        transforms.

    Returns:
      Topic: The created topic.

    Raises:
      InvalidSchemaSettingsException: If an invalid --schema,
          --message-encoding flag comnbination is specified,
          or if the --first_revision_id revision is newer than
          the --last_revision_id specified.
    )namelabelsmessageRetentionDurationallowedPersistenceRegionsschemaencodingfirstRevisionIdlastRevisionIdrq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   rF   N)r7   TopicRelativeName
kmsKeyNameMessageStoragePolicyenforceInTransitmessageStoragePolicyr:   r3   schemaSettingsr   ingestionDataSourceSettingsr   GetMessageTransformsFromFileMessageTransformmessageTransforms#MessageTransformsInvalidFormatErrorMessageTransformsEmptyFileError!MessageTransformsMissingFileErrorGetErrorMessageargstagsr?   Create),r#   	topic_refr   kms_keymessage_retention_duration&message_storage_policy_allowed_regions)message_storage_policy_enforce_in_transitr   r8   first_revision_idlast_revision_idrq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   rF   message_transforms_filer   enable_vertex_ai_smtr_   message_storage_policyencoding_enumes,                                               r   r   zTopicsClient.Create   s   H MM##%!;   E
  e-#}}AA$J  B   
35 	/ $:e "*4==:JKm!]]99 +)	 : e )-(N(N%A'E#=*K'E-Q/U;m+M2[-Q-Q-Q-Q3]3]&C 7'E*K3]-Q(G3]2[55 )O )E%8 "'"D"DMM**# #
 ej==&& 
3
3

/
/

1
1 
 ''*,s   0D) )2E<E77E<c                     | j                   j                  |j                               }| j                  j	                  |      S )zGets a Topic.

    Args:
      topic_ref (Resource): Resource reference to the Topic to get.

    Returns:
      Topic: The topic.
    r_   )r7   PubsubProjectsTopicsGetRequestr   r?   Get)r#   r   get_reqs      r   r   zTopicsClient.Get  s@     mm::$$& ; G ==W%%r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zDeletes a Topic.

    Args:
      topic_ref (Resource): Resource reference to the Topic to delete.

    Returns:
      Empty: An empty response message.
    r   )r7   !PubsubProjectsTopicsDeleteRequestr   r?   Delete)r#   r   
delete_reqs      r   r   zTopicsClient.Delete  sA     @@$$& A J ==
++r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zDetaches the subscription from its topic.

    Args:
      subscription_ref (Resource): Resource reference to the Subscription to
        detach.

    Returns:
      Empty: An empty response message.
    )subscription)r7   (PubsubProjectsSubscriptionsDetachRequestr   rA   Detach)r#   subscription_ref
detach_reqs      r   DetachSubscriptionzTopicsClient.DetachSubscription  sC     GG%224 H J &&--j99r   c                     | j                   j                  |j                         |      }t        j                  | j
                  ||dd      S )a5  Lists Topics for a given project.

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

    Returns:
      A generator of Topics in the Project.
    )projectpageSizetopicsr   
batch_sizefieldbatch_size_attribute)r7   PubsubProjectsTopicsListRequestr   r   YieldFromListr?   )r#   project_ref	page_sizelist_reqs       r   ListzTopicsClient.List  sS     }}<<((*Y = H ##' r   c                     | j                   j                  |j                         |      }| j                  j                  }t        j                  |||dd      S )a7  Lists Snapshots for a given topic.

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

    Returns:
      A generator of Snapshots for the Topic.
    r_   r   	snapshotsr   r   )r7   (PubsubProjectsTopicsSnapshotsListRequestr   r-   projects_topics_snapshotsr   r   )r#   r   r   r   list_snaps_services        r   ListSnapshotszTopicsClient.ListSnapshots  s`     }}EE$$& F H >>##' r   c                     | j                   j                  |j                         |      }| j                  j                  }t        j                  |||dd      S )aL  Lists Subscriptions for a given topic.

    Args:
      topic_ref (Resource): Resource reference to Topic 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 for the Topic..
    r   subscriptionsr   r   )r7   ,PubsubProjectsTopicsSubscriptionsListRequestr   r-   projects_topics_subscriptionsr   r   )r#   r   r   r   list_subs_services        r   ListSubscriptionszTopicsClient.ListSubscriptions#  s`     }}II$$& J H AA##' r   c                    |s|st        d      | j                  j                  || j                  j                  j                  |      |      }| j                  j	                  | j                  j                  |g      |j                               }| j                  j                  |      }|j                  st        d      |S )ap  Publishes a message to the given topic.

    Args:
      topic_ref (Resource): Resource reference to Topic to publish to.
      message_body (bytes): Message to send.
      attributes (list[AdditionalProperty]): List of attributes to attach to the
        message.
      ordering_key (string): The ordering key to associate with this message.

    Returns:
      PublishResponse: Response message with message ids from the API.
    Raises:
      EmptyMessageException: If neither message nor attributes is
        specified.
      PublishOperationException: When something went wrong with the publish
        operation.
    zdYou cannot send an empty message. You must specify either a MESSAGE, one or more ATTRIBUTE, or both.)additionalProperties)data
attributesorderingKey)r7   )publishRequestr_   z,Publish operation failed with Unknown error.)r   r7   PubsubMessageAttributesValue"PubsubProjectsTopicsPublishRequestPublishRequestr   r?   Publish
messageIdsr   )r#   r   message_bodyr   ordering_keymessagepublish_reqresults           r   r   zTopicsClient.Publish;  s    ( 
!5  mm))==..>>!+ ? 
 ! * G --BB}}33gY3G$$& C K ]]"";/F%
8  Mr   c                     | j                   j                  |j                         | j                   j                  |            }| j                  j                  |      S )zSets an IAM policy on a Topic.

    Args:
      topic_ref (Resource): Resource reference for topic to set IAM policy on.
      policy (Policy): The policy to be added to the Topic.

    Returns:
      Policy: the policy which was set.
    )policy)resourcesetIamPolicyRequest)r7   'PubsubProjectsTopicsSetIamPolicyRequestr   SetIamPolicyRequestr?   SetIamPolicy)r#   r   r   requests       r   r  zTopicsClient.SetIamPolicyg  sV     mmCC'') MM==V=L D G ==%%g..r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zGets the IAM policy for a Topic.

    Args:
      topic_ref (Resource): Resource reference for topic to get the IAM policy
        of.

    Returns:
      Policy: the policy for the Topic.
    )r   )r7   'PubsubProjectsTopicsGetIamPolicyRequestr   r?   GetIamPolicy)r#   r   r  s      r   r  zTopicsClient.GetIamPolicyw  sA     mmCC'') D G ==%%g..r   c                     | j                  |      }t        j                  | j                  j                  |||       | j                  ||      S )ax  Adds an IAM Policy binding to a Topic.

    Args:
      topic_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	   AddBindingToIamPolicyr7   Bindingr  r#   r   memberroler   s        r   AddIamPolicyBindingz TopicsClient.AddIamPolicyBinding  sE     y)F""4==#8#8&&$OY//r   c                 v    | j                  |      }t        j                  |||       | j                  ||      S )a  Removes an IAM Policy binding from a Topic.

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

    Returns:
      Policy: the updated policy.
    Raises:
      api_exception.HttpException: If either of the requests failed.
    )r  r	   RemoveBindingFromIamPolicyr  r	  s        r   RemoveIamPolicyBindingz#TopicsClient.RemoveIamPolicyBinding  s9     y)F''=Y//r   c,                    g },|r|,j                  t        d|             |r|,j                  t        d|             |r|,j                  t        d|             |r|,j                  t        dd             |r|,j                  t        dd             nB|r@| j                  j                  |      }-|r||-_        |,j                  t        d|-             |r|,j                  t        dd             nR|	rP|
rNt        | j                  |
      }.|,j                  t        d| j                  j                  |	|.||                   |r|,j                  t        d	d             nH| j                  |||||||||||||||||| |!|"|#|$|%|&|'|(
      }/|/|,j                  t        d	|/             |)rF	 |,j                  t        dt        j                  | j                  j                  |)|+                   |*r|,j                  t        dt                      | j                  j#                  |j%                               }1g }2|,D ]>  }3t'        |1|3j(                  |3j*                         |2j                  |3j(                         @ |2st-        d      | j                  j/                  | j                  j1                  |1dj3                  |2            |j%                               }4| j4                  j7                  |4      S # t        j                  t        j                  t        j                  f$ r!}0t        j                  |0      f|0_         d}0~0ww xY w)a  Updates a Topic.

    Args:
      topic_ref (Resource): Resource reference for the topic to be updated.
      labels (LabelsValue): The Cloud labels for the topic.
      kms_key_name (str): The full resource name of the Cloud KMS key to
        associate with the topic, or None.
      message_retention_duration (str): How long to retain messages.
      clear_message_retention_duration (bool): If set, remove retention from the
        topic.
      recompute_message_storage_policy (bool): True to have the API recalculate
        the message storage policy.
      message_storage_policy_allowed_regions (list[str]): List of Cloud regions
        in which messages are allowed to be stored at rest.
      message_storage_policy_enforce_in_transit (bool): Whether or not to
        enforce in-transit guarantees for this topic using the allowed regions.
      schema (Resource): Full resource name of schema used to validate messages
        published on Topic.
      message_encoding (str): If a schema is set, the message encoding of
        incoming messages to be validated against the schema.
      first_revision_id (str): If a schema is set, the revision id of the oldest
        revision allowed for validation.
      last_revision_id (str): If a schema is set, the revision id of the newest
        revision allowed for validation.
      clear_schema_settings (bool): If set, clear schema settings from the
        topic.
      clear_ingestion_data_source_settings (bool): If set, clear
        IngestionDataSourceSettings from the topic.
      kinesis_ingestion_stream_arn (str): The Kinesis data stream ARN to ingest
        data from.
      kinesis_ingestion_consumer_arn (str): The Kinesis data streams consumer
        ARN to use for ingestion.
      kinesis_ingestion_role_arn (str): AWS role ARN to be used for Federated
        Identity authentication with Kinesis.
      kinesis_ingestion_service_account (str): The GCP service account to be
        used for Federated Identity authentication with Kinesis
      cloud_storage_ingestion_bucket (str): The Cloud Storage bucket to ingest
        data from.
      cloud_storage_ingestion_input_format (str): the format of the data in the
        Cloud Storage bucket ('text', 'avro', or 'pubsub_avro').
      cloud_storage_ingestion_text_delimiter (optional[str]): delimiter to use
        with text format when partioning the object.
      cloud_storage_ingestion_minimum_object_create_time (optional[str]): only
        Cloud Storage objects with a larger or equal creation timestamp will be
        ingested.
      cloud_storage_ingestion_match_glob (optional[str]): glob pattern used to
        match Cloud Storage objects that will be ingested. If unset, all objects
        will be ingested.
      azure_event_hubs_ingestion_resource_group (str): The name of the resource
        group within an Azure subscription.
      azure_event_hubs_ingestion_namespace (str): The name of the Azure Event
        Hubs namespace.
      azure_event_hubs_ingestion_event_hub (str): The name of the Azure event
        hub.
      azure_event_hubs_ingestion_client_id (str): The client id of the Azure
        Event Hubs application used to authenticate Pub/Sub.
      azure_event_hubs_ingestion_tenant_id (str): The tenant id of the Azure
        Event Hubs application used to authenticate Pub/Sub.
      azure_event_hubs_ingestion_subscription_id (str): The id of the Azure
        Event Hubs subscription.
      azure_event_hubs_ingestion_service_account (str): The GCP service account
        to be used for Federated Identity authentication with Azure Event Hubs.
      aws_msk_ingestion_cluster_arn (str): The ARN that uniquely identifies the
        MSK cluster.
      aws_msk_ingestion_topic (str): The name of the MSK topic that Pub/Sub will
        import from.
      aws_msk_ingestion_aws_role_arn (str): AWS role ARN to be used for
        Federated Identity authentication with MSK.
      aws_msk_ingestion_service_account (str): The GCP service account to be
        used for Federated Identity authentication with MSK.
      confluent_cloud_ingestion_bootstrap_server (str): The address of the
        Confluent Cloud bootstrap server. The format is url:port.
      confluent_cloud_ingestion_cluster_id (str): The id of the Confluent Cloud
        cluster.
      confluent_cloud_ingestion_topic (str): The name of the Confluent Cloud
        topic that Pub/Sub will import from.
      confluent_cloud_ingestion_identity_pool_id (str): The id of the identity
        pool to be used for Federated Identity authentication with Confluent
        Cloud.
      confluent_cloud_ingestion_service_account (str): The GCP service account
        to be used for Federated Identity authentication with Confluent Cloud.
      ingestion_log_severity (optional[str]): The log severity to use for
        ingestion.
      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 topic.
      enable_vertex_ai_smt (bool): If set, enables Vertex AI message
        transforms.

    Returns:
      Topic: The updated topic.
    Raises:
      NoFieldsSpecifiedError: if no fields were specified.
      PatchConflictingArgumentsError: if conflicting arguments were provided
      InvalidSchemaSettingsException: If an invalid --schema,
          --message-encoding flag comnbination is specified,
          or if the --first_revision_id revision is newer than
          the --last_revision_id specified.
    r   r   r   Nr   r   r   r   r   r   r   )r   )r   z*Must specify at least one field to update.,)r_   
updateMask)updateTopicRequestr   )appendr   r7   r   r   r:   r3   r   r   r   r   r   r   r   r   r   CLEAR_MESSAGE_TRANSFORMS_VALUEr   r   setattrr!   r"   r    PubsubProjectsTopicsPatchRequestUpdateTopicRequestjoinr?   Patch)5r#   r   r   kms_key_namer    clear_message_retention_duration recompute_message_storage_policyr   r   r   r8   r   r   clear_schema_settings$clear_ingestion_data_source_settingsrq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   rF   r   clear_message_transformsr   update_settingsr   r   new_settingsr   r_   update_maskupdate_setting	patch_reqs5                                                        r   r  zTopicsClient.Patch  st   d O06BC0|LM!
(*D
 (
8$
? (01GNO	/#}}AA$J  B   
35 	/ 
46L
M 01A4HI	$*4==:JKm
mm**("3!1	 + 
 ,
;T
B ;;'C)G%?,M)G/S1W=o-O4]/S/S/S/S5_5_(E"9)G,M5_/S*I5_4]!75 < l8 
	! =|L	
 #22MM22+)=		
$  
!#A MMY%;%;%=>EK)e^..0D0DE223 * "#OPP>>==;;CHH[$9 < 
 ##%	 ? I ==y))= 
3
3

/
/

1
1 
 ''*,s   0AL 2M4MM)NN)NNNNNNNNNNNNNNNNNNNNNNNNNN)&NNNNFNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNF)d   )NNN)*NNNFFNFNNNNNFNNNNNNNNNNNNNNNNNNNNNNNNNNNFF)r   r   r   r   r$   rG   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r   r   r   r<   r<   N   s   ;E $(%)!%(,%)+/-19=)-04+/+/+/+/1515$("%)(,15+/&*1504!7]D !%-105#'%)!%(,%)+/-19=)-04+/+/+/+/1515$("%)(,15+/&*1504!" QJ'X&,:,.2 IM*X/ /0$0* !%',',-105 +0#'%)!%(,%)+/-19=)-04+/+/+/+/1515$("%)(,15+/&*1504!"$ YS*r   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  Errorr   r   r   r   r   objectr   r*   r.   r:   r<   r   r   r   <module>r/     s    . &  ' ' / , 3 *!# 6
 0 0 6EJ,, ECZ-- C4Z%5%5 47J,<,< 7& A 
	o*6 o*r   