
                             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 d
 dej                        Zd Zd Z G d de      Zy)z$Utilities for Eventarc Channels API.    )absolute_import)division)unicode_literals)common)EventarcClientBase)apis)
exceptions)
propertiesc                       e Zd ZdZy)NoFieldsSpecifiedErrorz:Error when no fields were specified for a Patch operation.N)__name__
__module____qualname____doc__     6lib/googlecloudsdk/api_lib/eventarc/google_channels.pyr   r      s    Br   r   c                     | j                   xs2 t        j                  j                  j                   j	                         S )z=Gets project resource from either argument flag or attribute.)projectr
   VALUEScore	GetOrFailargss    r   
GetProjectr       s,    		C**//77AACCr   c                     | j                   xs2 t        j                  j                  j                   j	                         S )z>Gets location resource from either argument flag or attribute.)locationr
   r   eventarcr   r   s    r   GetLocationr   %   s,    		I*++44==GGIIr   c                   @     e Zd ZdZ fdZd Zd Zd Zd Zd Z	 xZ
S )GoogleChannelConfigClientV1zGGoogle Channel Client for interaction with v1 of Eventarc Channels API.c                    t         t        |   t        j                  t        j
                  d       t        j                  t        j                  t        j
                        }|j                  | _	        |j                  | _        y )NGoogleChannelConfig)superr!   __init__r   API_NAMEAPI_VERSION_1r   GetClientInstanceMESSAGES_MODULE	_messagesprojects_locations_service)selfclient	__class__s     r   r%   z$GoogleChannelConfigClientV1.__init__-   s`    	
%
&*>*>.0 ##FOOV5I5IJF++DN--DMr   c                 p    | j                   j                  |      }| j                  j                  |      S )zGets the requested GoogleChannelConfig.

    Args:
      google_channel_config_name: str, the name of GoogleChannelConfig to get.

    Returns:
      The GoogleChannelConfig message.
    )name)r*   6EventarcProjectsLocationsGetGoogleChannelConfigRequestr,   GetGoogleChannelConfig)r-   google_channel_config_nameget_reqs      r   GetzGoogleChannelConfigClientV1.Get8   s6     nnSS' T )G==//88r   c                 t    | j                   j                  |||      }| j                  j                  |      S )a  Updates the specified Channel.

    Args:
      google_channel_config_name: str, the name of GoogleChannelConfig to
        update.
      google_channel_config_message: GoogleChannelConfig, the config message
        that holds KMS encryption info.
      update_mask: str, a comma-separated list of GoogleChannelConfig fields to
        update.

    Returns:
      Response for update.
    )r1   googleChannelConfig
updateMask)r*   9EventarcProjectsLocationsUpdateGoogleChannelConfigRequestr,   UpdateGoogleChannelConfig)r-   r4   google_channel_config_messageupdate_mask
update_reqs        r   Updatez"GoogleChannelConfigClientV1.UpdateE   s>     YY'9 Z  J ==22:>>r   c                 >    | j                   j                  |||      S )N)r1   cryptoKeyNamelabels)r*   r#   )r-   r4   crypto_key_namerB   s       r   BuildGoogleChannelConfigz4GoogleChannelConfigClientV1.BuildGoogleChannelConfigZ   s)     >>--'% .  r   c                     g }|r|j                  d       |r|j                  d       |r|j                  d       |st        d      dj                  |      S )aa  Builds an update mask for updating a channel.

    Args:
      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.
    rA   rB   z*Must specify at least one field to update.,)appendr   join)r-   
crypto_keyclear_crypto_keyrB   r=   s        r   BuildUpdateMaskz+GoogleChannelConfigClientV1.BuildUpdateMaskc   sZ     K))""#OPP88K  r   c                 B    | j                   j                  j                  S )zReturns the labels value class.)r*   r#   LabelsValue)r-   s    r   LabelsValueClassz,GoogleChannelConfigClientV1.LabelsValueClass}   s    >>--999r   )r   r   r   r   r%   r6   r?   rD   rK   rN   __classcell__)r/   s   @r   r!   r!   *   s$    O	.9?*!4:r   r!   N)r   
__future__r   r   r   googlecloudsdk.api_lib.eventarcr   $googlecloudsdk.api_lib.eventarc.baser   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer	   r
   Errorr   r   r   r!   r   r   r   <module>rV      sQ    + &  ' 2 C , * *CZ-- CD
J
U:"4 U:r   