
    2(                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr   " S S\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)common_publishing)apis)
exceptions)	resourcesc                       \ 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       4lib/googlecloudsdk/api_lib/eventarc/message_buses.pyr   r      s    Br   r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nz(eventarc.projects.locations.messageBuses)
collection)r   REGISTRYParseRelativeNamenameSelfLink)resourcemessage_busess     r   GetMessageBusURIr!   "   s8    $$66mm J 7 - 
			!!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 5       rSrU =r$ )MessageBusClientV1)   zGMessageBus Client for interaction with v1 of Eventarc MessageBuses API.c                   > [         [        U ]  [        R                  [        R
                  S5        [        R                  " [        R                  [        R
                  5      nUR                  U l	        UR                  U l        [        R                  " [        R                  [        R
                  5      nUR                  U l        UR                  U l        g )Nzmessage bus)superr#   __init__r   API_NAMEAPI_VERSION_1r
   GetClientInstanceMESSAGES_MODULE	_messagesprojects_locations_messageBuses_servicer	   _publishing_messages_publishing_service)selfclientpublishing_client	__class__s      r   r'   MessageBusClientV1.__init__,   s    	
d,--}
 ##FOOV5I5IJF++DN::DM ..""$5$C$C !2 A AD0PPDr   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 new MessageBus.

Args:
  message_bus_ref: Resource, the MessageBus to create.
  message_bus_message: MessageBus, the messageBus message that holds
    messageBus' name, crypto key name, etc.
  dry_run: If set, the changes will not be committed, only validated

Returns:
  A long-running operation for create.
)parent
messageBusmessageBusIdvalidateOnly)r,   2EventarcProjectsLocationsMessageBusesCreateRequestParentRelativeNameNamer.   Create)r1   message_bus_refmessage_bus_messagedry_run
create_reqs        r   r?   MessageBusClientV1.Create?   s_     	II"))+88:*(--/ 	 	J 	
  ==
++r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )z~Gets the requested MessageBus.

Args:
  message_bus_ref: Resource, the MessageBus to get.

Returns:
  The MessageBus message.
r   )r,   /EventarcProjectsLocationsMessageBusesGetRequestr=   r.   Get)r1   r@   get_reqs      r   rH   MessageBusClientV1.GetU   sA     nnLL))+ M G ==W%%r   c           	          U R                   R                  UR                  5       US9n[        R                  " U R
                  USUUSS9$ )aV  List available messageBuses in location.

Args:
  location_ref: Resource, the location to list MessageBuses 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 MessageBuses in the location.
r7   pageSizemessageBusesrM   )servicerequestfieldlimit
batch_sizebatch_size_attribute)r,   0EventarcProjectsLocationsMessageBusesListRequestr=   r   YieldFromListr.   )r1   location_refrR   	page_sizelist_reqs        r   ListMessageBusClientV1.Listc   sW     ~~NN((*Y O H ##' r   c                     U R                   R                  UR                  5       UUS9nU R                  R	                  U5      $ )aM  Updates the specified MessageBus.

Args:
  message_bus_ref: Resource, the MessageBus to update.
  message_bus_message: MessageBus, the messageBus message that holds
    messageBus' name, crypto key name, etc.
  update_mask: str, a comma-separated list of MessageBus fields to update.

Returns:
  A long-running operation for update.
)r   r8   
updateMask)r,   1EventarcProjectsLocationsMessageBusesPatchRequestr=   r.   Patch)r1   r@   rA   update_mask	patch_reqs        r   r_   MessageBusClientV1.Patch{   sJ     	HH --/*" 	I 	
  ==y))r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes the specified MessageBus.

Args:
  message_bus_ref: Resource, the MessageBus to delete.

Returns:
  A long-running operation for delete.
rF   )r,   2EventarcProjectsLocationsMessageBusesDeleteRequestr=   r.   Delete)r1   r@   
delete_reqs      r   re   MessageBusClientV1.Delete   sD     	II --/ 	J 	
 
 ==
++r   c
                    U R                   R                  UR                  5       U R                   R                  U R	                  XEXgU5      UUU	(       a  U	R                  5       OSS9S9n
U R
                  R                  U
5        g)a  Publish a Cloud Event to a MessageBus.

Args:
  message_bus_ref: Resource, the message bus to publish to.
  json_message: str, the json string to publish.
  avro_message: byte, the avro payload to publish.
  event_id: str, the id of the event.
  event_type: str, the type of the event.
  event_source: str, the source of the event.
  event_data: str, the data of the event.
  event_attributes: dict, the attributes of the event.
  destination_enrollment_ref: Resource, the enrollment to deliver the event
    to.
N)protoMessageavroMessagejsonMessagedestinationEnrollment)r8   -googleCloudEventarcPublishingV1PublishRequest)r/   =EventarcpublishingProjectsLocationsMessageBusesPublishRequestr=   -GoogleCloudEventarcPublishingV1PublishRequest_BuildCloudEventProtoMessager0   Publish)r1   r@   json_messageavro_messageevent_id
event_typeevent_source
event_dataevent_attributesdestination_enrollment_refpublish_reqs              r   rq   MessageBusClientV1.Publish   s    6 ++ii"//16:6O6O6}6}::l@P %$ . +779 7~ 7
 j K" 	$$[1r   c           
          U R                   R                  UR                  5       US9n[        R                  " U R
                  SUSUUSS9$ )z@List available enrollments attached to the specified messageBus.rL   ListEnrollmentsenrollmentsrM   )rO   methodrP   rQ   rR   rS   rT   )r,   ;EventarcProjectsLocationsMessageBusesListEnrollmentsRequestr=   r   rV   r.   )r1   r@   rR   rX   rY   s        r   r}   "MessageBusClientV1.ListEnrollments   sX    ~~YY++-	 Z H ## ' r   c                     S nUb<  U R                   R                  U R                   R                  R                  U5      S9nU R                   R                  UR	                  5       UUUS9$ )N)logSeverity)r   loggingConfigcryptoKeyNamelabels)r,   LoggingConfigLogSeverityValueValuesEnum
MessageBusr=   )r1   r@   logging_configcrypto_key_namer   logging_config_enums         r   BuildMessageBus"MessageBusClientV1.BuildMessageBus   sx     ! NN88nn22MM 9 
 >>$$))+)%	 %  r   c                     / nU(       a  UR                  S5        U(       d  U(       a  UR                  S5        U(       a  UR                  S5        U(       d  [        S5      eSR                  U5      $ )a  Builds an update mask for updating a MessageBus.

Args:
  logging_config: bool, whether to update the logging config.
  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.

Returns:
  The update mask as a string.


Raises:
  NoFieldsSpecifiedError: No fields are being updated.
r   r   r   z*Must specify at least one field to update.,)appendr   join)r1   r   
crypto_keyclear_crypto_keyr   r`   s         r   BuildUpdateMask"MessageBusClientV1.BuildUpdateMask   s]    $ K)%)""#OPP88K  r   c                 B    U R                   R                  R                  $ )zReturns the labels value class.)r,   r   LabelsValuer1   s    r   LabelsValueClass#MessageBusClientV1.LabelsValueClass  s    >>$$000r   c           
      v    Ub	  Ub  Ub  Uc  g U R                   R                  UUUSUU R                  U5      S9$ )Nz1.0)idtypesourcespecVersiontextData
attributes)r/   )GoogleCloudEventarcPublishingV1CloudEvent_BuildCloudEventAttributes)r1   rt   ru   rv   rw   rx   s         r   rp   /MessageBusClientV1._BuildCloudEventProtoMessage  s\     	$$NN223CD O  r   c                 (   Uc  g U R                   R                  R                  UR                  5        VVs/ s HJ  u  p#U R                   R                  R                  R	                  UU R                   R                  US9S9PML     snnS9$ s  snnf )N)ceString)keyvalue)additionalProperties)r/   r   AttributesValueitemsAdditionalPropertyAGoogleCloudEventarcPublishingV1CloudEventCloudEventAttributeValue)r1   rx   r   r   s       r   r   -MessageBusClientV1._BuildCloudEventAttributes#  s    $$NN^^ /446
 7
 %%OO__rr//qq" r  s  7
 _ 
 

s   AB
c                     g)Nzmessage-busesr   r   s    r   _resource_label_plural)MessageBusClientV1._resource_label_plural2  s    r   )r,   r/   r0   r.   )F)r   r   r   r   r   r'   r?   rH   rZ   r_   re   rq   r}   r   r   r   rp   r   propertyr   r   __classcell__)r4   s   @r   r#   r#   )   s]    OQ&,,&0**, ,2\"!<1&  r   r#   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.eventarcr   r   r	   googlecloudsdk.api_lib.utilr
   googlecloudsdk.corer   r   Errorr   r!   EventarcClientBaser#   r   r   r   <module>r      sU    / &  ' ' 0 2 = , * )CZ-- C"K00 Kr   