
                             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 r " S S\5      rg)z/Utilities for Eventarc channel connections API.    )absolute_import)division)unicode_literals)
list_pager)common)common_publishing)EventarcClientBase)apis)	resourcesc                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nz.eventarc.projects.locations.channelConnections)
collection)r   REGISTRYParseRelativeNamenameSelfLink)resourcechannel_connectionss     :lib/googlecloudsdk/api_lib/eventarc/channel_connections.pyGetChannelConnectionsURIr      s:    !**<<mmA = C 
	%	%	''    c                   P   ^  \ rS rSrSrU 4S jrS rS rS rS r	S r
S	 rS
rU =r$ )ChannelConnectionClientV1$   z/Channel connections client for Eventarc API V1.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Channel Connection)superr   __init__r   API_NAMEAPI_VERSION_1r
   GetClientInstanceMESSAGES_MODULE	_messages%projects_locations_channelConnections_servicer   _publishing_messages_publishing_service)selfclientpublishing_client	__class__s      r   r   "ChannelConnectionClientV1.__init__'   s    	
#
&*>*>-/ ##FOOV5I5IJF++DN@@DM ../@/I/I/@/N/NP 1 A AD0VVDr   c                     U R                   R                  UR                  5       R                  5       UUR	                  5       S9nU R
                  R                  U5      $ )a,  Creates a new Channel Connection.

Args:
  channel_connection_ref: Resource, the Channel connection to create.
  channel_connection_message: Channel connection, the channel connection
    message that holds channel's reference, activation token, etc.

Returns:
  A long-running operation for create.
)parentchannelConnectionchannelConnectionId)r!   8EventarcProjectsLocationsChannelConnectionsCreateRequestParentRelativeNameNamer#   Create)r&   channel_connection_refchannel_connection_message
create_reqs       r   r3    ChannelConnectionClientV1.Create7   sY     XX%,,.;;=42779 Y ;J ==
++r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes the specified Channel Connection.

Args:
  channel_connection_ref: Resource, the Channel Connection to delete.

Returns:
  A long-running operation for delete.
r   )r!   8EventarcProjectsLocationsChannelConnectionsDeleteRequestr1   r#   Delete)r&   r4   
delete_reqs      r   r;    ChannelConnectionClientV1.DeleteH   s?     XX#002 Y 4J==
++r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zGets the requested Channel Connection.

Args:
  channel_connection_ref: Resource, the Channel Connection to get.

Returns:
  The Channel Connection message.
r9   )r!   5EventarcProjectsLocationsChannelConnectionsGetRequestr1   r#   Get)r&   r4   get_reqs      r   r@   ChannelConnectionClientV1.GetU   s?     nnRR#002 S 4G==W%%r   c           	          U R                   R                  UR                  5       US9n[        R                  " U R
                  USUUSS9$ )ak  List available channel connections in location.

Args:
  location_ref: Resource, the location to list Channel Connections 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 Channel Connections in the location.
)r,   pageSizechannelConnectionsrD   )servicerequestfieldlimit
batch_sizebatch_size_attribute)r!   6EventarcProjectsLocationsChannelConnectionsListRequestr1   r   YieldFromListr#   )r&   location_refrI   	page_sizelist_reqs        r   ListChannelConnectionClientV1.Listb   sV     ~~TT((*Y U @H##"') )r   c                 (   [         R                  " U R                  R                  R                  U5      nU R                  R                  U/S9nU R                  R                  UR                  5       US9nU R                  R                  U5        g)zPublish to a Channel Conenction.

Args:
  channel_connection_ref: Resource, the channel connection to publish from.
  cloud_event: A CloudEvent representation to be passed as the request body.
)events)r-   DgoogleCloudEventarcPublishingV1PublishChannelConnectionEventsRequestN)	r   TransformEventsForPublishingr$   DGoogleCloudEventarcPublishingV1PublishChannelConnectionEventsRequestEventsValueListEntryIEventarcpublishingProjectsLocationsChannelConnectionsPublishEventsRequestr1   r%   PublishEvents)r&   r4   cloud_eventevents_value_list_entrypublish_events_requestpublish_reqs         r   Publish!ChannelConnectionClientV1.Publishx   s     0LL!!	M	M		{,
 "66{{'( |  ++uu0==?Mc v K
 	**;7r   c                 P   S nUbr  U R                   R                  R                  UR                  5        VVs/ s H3  u  pgU R                   R                  R                  R	                  UUS9PM5     snnS9nU R                   R                  UR                  5       UUUS9$ s  snnf )N)keyvalue)additionalProperties)r   channelactivationTokenlabels)r!   ChannelConnectionLabelsValueitemsAdditionalPropertyr1   )r&   r4   re   activation_tokenrg   channel_connection_labelsrb   rc   s           r   BuildChannelConnection0ChannelConnectionClientV1.BuildChannelConnection   s     $"&.."B"B"N"N !' 
 !/*#	 nn..::MM N  !/  #O # >>++#002((	 , 
 
 s   :B"
)r!   r$   r%   r#   )__name__
__module____qualname____firstlineno____doc__r   r3   r;   r@   rQ   r_   rn   __static_attributes____classcell__)r)   s   @r   r   r   $   s/    7W ,",&),80
 
r   r   N)rt   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.eventarcr   r   $googlecloudsdk.api_lib.eventarc.baser	   googlecloudsdk.api_lib.utilr
   googlecloudsdk.corer   r   r    r   r   <module>r~      s9    6 &  ' ' 2 = C , )(~
 2 ~
r   