
    O                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  SS
KJr  SSKJr  Sr " S S\R"                  5      r " S S\R"                  5      rS r " S S\R*                  5      rg)z(Utilities for Eventarc MessageBuses API.    )absolute_import)division)unicode_literals)
list_pager)base)common)apis)
exceptions)log)	resourceszSpecifying a network attachment for a pipeline with an HTTP endpoint is not GA
and the pipeline will be limited to pre-GA features.
c                       \ 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       0lib/googlecloudsdk/api_lib/eventarc/pipelines.pyr   r   #   s    Br   r   c                       \ rS rSrSrSrg) InvalidDestinationsArgumentError'   z;Error when the pipeline's destinations argument is invalid.r   Nr   r   r   r   r   r   '   s    Cr   r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nz%eventarc.projects.locations.pipelines)
collection)r   REGISTRYParseRelativeNamenameSelfLink)resource	pipeliness     r   GetPipelineURIr%   +   s8      22mm G 3 ) 
			r   c                      ^  \ rS rSrSrU 4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 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  r"S!r#U =r$$ )#PipelineClientV12   zBPipeline Client for interaction with v1 of Eventarc Pipelines API.c                   > [         [        U ]  [        R                  [        R
                  S5        [        R                  " [        R                  [        R
                  5      nUR                  U l	        UR                  U l        g )Npipeline)superr'   __init__r   API_NAMEAPI_VERSION_1r	   GetClientInstanceMESSAGES_MODULE	_messagesprojects_locations_pipelines_service)selfclient	__class__s     r   r,   PipelineClientV1.__init__5   s\    	
D*--z
 ##FOOV5I5IJF++DN77DMr   c                     U R                   R                  UR                  5       R                  5       UUR	                  5       US9nU R
                  R                  U5      $ )a~  Creates a Pipeline.

Args:
  pipeline_ref: Resource, the Pipeline to create.
  pipeline_message: Pipeline, the pipeline message that holds pipeline's
    name, destinations, mediations, input payload format, logging config,
    retry policy, crypto key name, etc.
  dry_run: If set, the changes will not be committed, only validated

Returns:
  A long-running operation for create.
)parentr*   
pipelineIdvalidateOnly)r1   /EventarcProjectsLocationsPipelinesCreateRequestParentRelativeNameNamer3   Create)r4   pipeline_refpipeline_messagedry_run
create_reqs        r   r@   PipelineClientV1.Create@   s\     OO""$113!$$&	 P J ==
++r   c           	          U R                   R                  UR                  5       US9n[        R                  " U R
                  USUUSS9$ )aM  List available pipelines in location.

Args:
  location_ref: Resource, the location to list Pipelines in.
  limit: int or None, the total number of results to return.
  page_size: int, the number of entries in each batch (affects requests
    made, but not the yielded results).

Returns:
  A generator of Pipelines in the location.
)r9   pageSizer$   rG   )servicerequestfieldlimit
batch_sizebatch_size_attribute)r1   -EventarcProjectsLocationsPipelinesListRequestr>   r   YieldFromListr3   )r4   location_refrK   	page_sizelist_reqs        r   ListPipelineClientV1.ListU   sW     ~~KK((*Y L H ##' r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zuGets the requested Pipeline.

Args:
  pipeline_ref: Resource, the Pipeline to get.

Returns:
  The Pipeline message.
r!   )r1   ,EventarcProjectsLocationsPipelinesGetRequestr>   r3   Get)r4   rA   get_reqs      r   rX   PipelineClientV1.Getm   sA     nnII&&( J G ==W%%r   c                     U R                   R                  UR                  5       UUS9nU R                  R	                  U5      $ )a  Updates the specified Pipeline.

Args:
  pipeline_ref: Resource, the Pipeline to update.
  pipeline_message: Pipeline, the pipeline message that holds pipeline's
    name, destinations, mediations, input payload format, logging config,
    retry policy, crypto key name, etc.
  update_mask: str, a comma-separated list of Pipeline fields to update.

Returns:
  A long-running operation for update.
)r!   r*   
updateMask)r1   .EventarcProjectsLocationsPipelinesPatchRequestr>   r3   Patch)r4   rA   rB   update_mask	patch_reqs        r   r^   PipelineClientV1.Patch{   sG     MM&&(! N I
 ==y))r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes the specified Pipeline.

Args:
  pipeline_ref: Resource, the Pipeline to delete.

Returns:
  A long-running operation for delete.
rV   )r1   /EventarcProjectsLocationsPipelinesDeleteRequestr>   r3   Delete)r4   rA   
delete_reqs      r   rd   PipelineClientV1.Delete   sA     OO&&( P J ==
++r   c                 .   U R                   R                  UR                  5       U R                  X5      U R	                  UUU5      U R                  U5      U R                  U5      U R                  XU
5      UUU(       a  UR                  5       S9	$ S S9	$ )N)	r!   destinationsinputPayloadFormat
mediationsloggingConfigretryPolicycryptoKeyNamelabelserrorMessageBus)r1   Pipeliner>   _BuildDestinations_BuildInputPayloadFormat_BuildMediations_BuildLoggingConfig_BuildRetryPolicy)r4   rA   rh   input_payload_format_json+input_payload_format_avro_schema_definition/input_payload_format_protobuf_schema_definitionrj   logging_configmax_retry_attemptsmin_retry_delaymax_retry_delaycrypto_key_namern   error_message_bus_refs                 r   BuildPipelinePipelineClientV1.BuildPipeline   s      >>""&&(,,\H88%7;

 ((4..~>**
 & % "..0! #  $ % #  r   c                 .   / nU(       a  UR                  S5        U(       d  U(       d  U(       a  UR                  S5        U(       a  UR                  S5        U(       a  UR                  S5        U(       d  U(       d  U(       d  U	(       a  UR                  S5        U
(       d  U(       a  UR                  S5        U(       a  UR                  S5        U(       d  U(       a  UR                  S5        U(       d  [        S	5      eS
R                  U5      $ )a  Builds an update mask for updating a pipeline.

Args:
  destinations: bool, whether to update the destinations.
  input_payload_format_json: bool, whether to update the
    input_payload_format_json.
  input_payload_format_avro_schema_definition: bool, whether to update the
    input_payload_format_avro_schema_definition.
  input_payload_format_protobuf_schema_definition: bool, whether to update
    the input_payload_format_protobuf_schema_definition.
  mediations: bool, whether to update the mediations.
  logging_config: bool, whether to update the logging_config.
  max_retry_attempts: bool, whether to update the max_retry_attempts.
  min_retry_delay: bool, whether to update the min_retry_delay.
  max_retry_delay: bool, whether to update the max_retry_delay.
  crypto_key: bool, whether to update the crypto_key.
  clear_crypto_key: bool, whether to clear the crypto_key.
  labels: bool, whether to update the labels.
  error_message_bus: bool, whether to update the error_message_bus.
  clear_error_message_bus: bool, whether to clear the error_message_bus.

Returns:
  The update mask as a string.


Raises:
  NoFieldsSpecifiedError: No fields are being updated.
rh   ri   rj   rk   rl   rm   rn   ro   z*Must specify at least one field to update.,)appendr   join)r4   rh   rv   rw   rx   rj   ry   rz   r{   r|   
crypto_keyclear_crypto_keyrn   error_message_busclear_error_message_busr_   s                   r   BuildUpdateMask PipelineClientV1.BuildUpdateMask   s    Z K(!6:-.&)'%)"3*+"#OPP88K  r   c                 B    U R                   R                  R                  $ N)r1   rp   LabelsValue)r4   s    r   LabelsValueClass!PipelineClientV1.LabelsValueClass  s    >>""...r   c                 X    Uc  / $ U Vs/ s H  o0R                  X5      PM     sn$ s  snf r   )_BuildDestination)r4   rA   rh   ds       r   rq   #PipelineClientV1._BuildDestinations  s.    i=IJ\""<3\JJJs   'c                    U R                  U5      nU R                  X5      nU R                  X5      nU R                  X5      nUS LUS L-   US L-   US L-   S:w  a  [	        S5      eUR                  S5       b   U(       d  U(       d  U(       a  [	        S5      eUR                  S5      (       a!  UR                  S5      (       a  [	        S5      eUR                  S5      (       a!  UR                  S5      (       a  [	        S	5      eU R                  R                  UUUUU R                  X5      U R                  U5      U R                  U5      S
9$ )N   zTExactly one of http_endpoint_uri, workflow, message_bus, or pubsub_topic must be set&http_endpoint_message_binding_templatezghttp_endpoint_message_binding_template cannot be set when workflow, message_bus, or pubsub_topic is sethttp_endpoint_uriprojectz3project cannot be set when http_endpoint_uri is setlocationz4location cannot be set when http_endpoint_uri is set)httpEndpointworkflow
messageBustopicnetworkConfigauthenticationConfigoutputPayloadFormat)_BuildDestinationHttpEndpoint_BuildDestinationWorkflow_BuildDestinationMessageBus_BuildDestinationPubsubTopicr   getr1   (GoogleCloudEventarcV1PipelineDestination_BuildDestinationNetworkConfig%_BuildDestinationAuthenticationConfig$_BuildDestinationOutputPayloadFormat)r4   rA   destinationhttp_endpointr   message_buspubsub_topics          r   r   "PipelineClientV1._BuildDestination  s~   66{CM--lHH22<MK44\OLT!hd&:;4	T	!#&'( -&  0;,,1  *++	0J0J,
?  *++
0K0K,
@  >>BB"99
 "GG
 !EE
 C  r   c                     UR                  S5      c  g U R                  R                  UR                  S5      UR                  S5      S9$ )Nr   r   )urimessageBindingTemplate)r   r1   4GoogleCloudEventarcV1PipelineDestinationHttpEndpointr4   r   s     r   r   .PipelineClientV1._BuildDestinationHttpEndpointB  sN    *+3>>NNOO/0*4 
 O  r   c                     UR                  S5      c  g UR                  S5      =(       d    UR                  nUR                  S5      =(       d    UR                  nSU SU SUR                  S5       3$ )Nr   r   r   	projects//locations/z/workflows/r   
projectsIdlocationsIdr4   rA   r   r   r   s        r   r   *PipelineClientV1._BuildDestinationWorkflowL  sj    z"*ooi(CL,C,CGz*Fl.F.FHwi{8*KPZ@[?\]]r   c                     UR                  S5      c  g UR                  S5      =(       d    UR                  nUR                  S5      =(       d    UR                  nSU SU SUR                  S5       3$ )Nr   r   r   r   r   z/messageBuses/r   r   s        r   r   ,PipelineClientV1._BuildDestinationMessageBusS  sj    }%-ooi(CL,C,CGz*Fl.F.FHwi{8*N;??S`CaBbccr   c                     UR                  S5      c  g UR                  S5      =(       d    UR                  nSU SUR                  S5       3$ )Nr   r   r   z/topics/)r   r   )r4   rA   r   r   s       r   r   -PipelineClientV1._BuildDestinationPubsubTopicZ  sJ    ~&.ooi(CL,C,CGwix(G'HIIr   c           
      F   UR                  S5      br  UR                  S5      b_  [        R                  " [        5        U R                  R                  SUR                   SUR                   SUR                  S5       3S9$ g UR                  S5      b  [        S5      eg )Nr   network_attachmentr   z	/regions/z/networkAttachments/)networkAttachmentz"network_attachment must not be set)	r   r   warning NO_NA_FOR_HTTP_ENDPOINTS_WARNINGr1   5GoogleCloudEventarcV1PipelineDestinationNetworkConfigr   r   r   )r4   rA   r   s      r   r   /PipelineClientV1._BuildDestinationNetworkConfig`  s    *+7	-	.	:45~~SS ),*A*A)B)LLdLdKeey  {F  {J  {J  K_  {`  za  b T 
 	
  +,8,
.  r   c                    U R                  U5      nU R                  U5      nUS LUS L-   S:  a  [        S5      eUR                  S5      (       a   U(       a  [        S5      eUc  [        S5      eUR                  S5      (       a   U(       a  [        S5      eUc  [        S5      eUc  Uc  g U R                  R                  UUS	9$ )
Nr   zrAt most one of google_oidc_authentication_service_account or oauth_token_authentication_service_account can be set oauth_token_authentication_scopezeoauth_token_authentication_scope cannot be set when google_oidc_authentication_service_account is setzioauth_token_authentication_scope cannot be set when oauth_token_authentication_service_account is not set#google_oidc_authentication_audiencezhgoogle_oidc_authentication_audience cannot be set when oauth_token_authentication_service_account is setzlgoogle_oidc_authentication_audience cannot be set when google_oidc_authentication_service_account is not set)
googleOidc
oauthToken))_BuildDestinationAuthenticationGoogleOidc)_BuildDestinationAuthenticationOauthTokenr   r   r1   <GoogleCloudEventarcV1PipelineDestinationAuthenticationConfig)r4   r   google_oidcoauth_tokens       r   r   6PipelineClientV1._BuildDestinationAuthenticationConfigr  s   @@MK@@MK4Kt$;<q@,C  9::	.A
 	
 
	.E
 	
 <==	.A
 	
 
	.E
 	
 {2>>VV W  r   c                     UR                  S5      c  g U R                  R                  UR                  S5      UR                  S5      S9$ )N*google_oidc_authentication_service_accountr   )serviceAccountaudience)r   r1   EGoogleCloudEventarcV1PipelineDestinationAuthenticationConfigOidcTokenr   s     r   r   :PipelineClientV1._BuildDestinationAuthenticationGoogleOidc  sP    CDL>>__"8
 !FG	 `  r   c                     UR                  S5      c  g U R                  R                  UR                  S5      UR                  S5      S9$ )N*oauth_token_authentication_service_accountr   )r   scope)r   r1   FGoogleCloudEventarcV1PipelineDestinationAuthenticationConfigOAuthTokenr   s     r   r   :PipelineClientV1._BuildDestinationAuthenticationOauthToken  sP    CDL>>``"8
 oo@A	 a  r   c                     U R                  U5      nU R                  U5      nU R                  U5      nUS LUS L-   US L-   S:  a  [        S5      eUc  Uc  Uc  g U R                  R                  UUUS9$ )Nr   zAt most one of output_payload_format_json, output_payload_format_avro_schema_definition, or output_payload_format_protobuf_schema_definition can be setjsonavroprotobuf)._BuildDestinationOutputPayloadFormatJsonFormat._BuildDestinationOutputPayloadFormatAvroFormat2_BuildDestinationOutputPayloadFormatProtobufFormatr   r1   1GoogleCloudEventarcV1PipelineMessagePayloadFormat)r4   r   r   r   r   s        r   r   5PipelineClientV1._BuildDestinationOutputPayloadFormat  s    >>{KD>>{KDFFH 	DT-.($2FG!K,I 
 |)9>>KK L  r   c                 x    UR                  S5      c  g U R                  R                  UR                  S5      S9$ )N,output_payload_format_avro_schema_definitionschemaDefinition)r   r1   ;GoogleCloudEventarcV1PipelineMessagePayloadFormatAvroFormatr   s     r   r   ?PipelineClientV1._BuildDestinationOutputPayloadFormatAvroFormat  sA    EFN>>UU$:
 V  r   c                 z    UR                  S5       c  g U R                  R                  UR                  S5      S9$ )N0output_payload_format_protobuf_schema_definitionr   )r   r1   ?GoogleCloudEventarcV1PipelineMessagePayloadFormatProtobufFormatr   s     r   r   CPipelineClientV1._BuildDestinationOutputPayloadFormatProtobufFormat  sH    JK	 >>YY$>
 Z  r   c                 D    SU;  a  g U R                   R                  5       $ )Noutput_payload_format_jsonr1   ;GoogleCloudEventarcV1PipelineMessagePayloadFormatJsonFormatr   s     r   r   ?PipelineClientV1._BuildDestinationOutputPayloadFormatJsonFormat  s"    #;6RRTr   c                     Uc  Uc  Uc  g U R                   R                  U R                  U5      U R                  U5      U R	                  U5      S9$ )Nr   )r1   r   "_BuildInputPayloadFormatJsonFormat"_BuildInputPayloadFormatAvroFormat&_BuildInputPayloadFormatProtobufFormat)r4   r   avro_schema_definitionprotobuf_schema_definitions       r   rr   )PipelineClientV1._BuildInputPayloadFormat  sc     	"*&.>>KK44T:445KL<<&
 L  r   c                 <    Uc  g U R                   R                  US9$ Nr   )r1   r   r4   schema_definitions     r   r   3PipelineClientV1._BuildInputPayloadFormatAvroFormat  s+     >>UU* V  r   c                 <    Uc  g U R                   R                  US9$ r   )r1   r   r   s     r   r   7PipelineClientV1._BuildInputPayloadFormatProtobufFormat  s+     >>YY* Z  r   c                 >    Uc  g U R                   R                  5       $ r   r   )r4   r   s     r   r   3PipelineClientV1._BuildInputPayloadFormatJsonFormat  s    |RRTr   c           
          Uc  / $ U Vs/ s HB  nU R                   R                  U R                   R                  UR                  S5      S9S9PMD     sn$ s  snf )Ntransformation_template)transformationTemplate)transformation)r1   &GoogleCloudEventarcV1PipelineMediation4GoogleCloudEventarcV1PipelineMediationTransformationr   )r4   rj   ms      r   rs   !PipelineClientV1._BuildMediations  sq    i  A 	==>>^^'(uu-F'G _  	> 	

   s   A	Ac                     Uc  g U R                   R                  U R                   R                  R                  U5      S9$ )N)logSeverity)r1   LoggingConfigLogSeverityValueValuesEnum)r4   ry   s     r   rt   $PipelineClientV1._BuildLoggingConfig  sB    >>''NN00KK
 (  r   c                 L    Uc  Uc  Uc  g U R                   R                  UUUS9$ )N)maxAttemptsminRetryDelaymaxRetryDelay)r1   (GoogleCloudEventarcV1PipelineRetryPolicy)r4   rz   r{   r|   s       r   ru   "PipelineClientV1._BuildRetryPolicy  s?     	"##>>BB&%% C  r   )r1   r3   )F)%r   r   r   r   r   r,   r@   rS   rX   r^   rd   r   r   r   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   rr   r   r   r   rs   rt   ru   r   __classcell__)r6   s   @r   r'   r'   2   s    J	8,*0&*(,$LJ!X/K
)V^dJ$#J(
"
 r   r'   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.eventarcr   r   googlecloudsdk.api_lib.utilr	   googlecloudsdk.corer
   r   r   r   Errorr   r   r%   EventarcClientBaser'   r   r   r   <module>r"     sq    / &  ' ' 0 2 , * # )$  CZ-- CDz'7'7 Dqt.. qr   