
    #                         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	\	R                  5      r " S
 S\	R                  5      rS r " S S\R                  5      rg)z,Utilities for Eventarc GoogleAPISources API.    )
list_pager)base)common)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       9lib/googlecloudsdk/api_lib/eventarc/google_api_sources.pyr
   r
      s    Br   r
   c                       \ rS rSrSrSrg)$NoProjectSubscriptionsSpecifiedError   z3Error when no project subscriptions were specified.r   Nr   r   r   r   r   r      s    ;r   r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nz,eventarc.projects.locations.googleApiSources)
collection)r   REGISTRYParseRelativeNamenameSelfLink)resourcegoogle_api_sourcess     r   GetGoogleAPISourceURIr!   "   s9     ));;mm N <  
	$	$	&&r   c                   x   ^  \ 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 5       rSrU =r$ )GoogleApiSourceClientV1)   zPGoogleApiSource Client for interaction with v1 of Eventarc GoogleApiSources API.c                   > [         [        U ]  [        R                  [        R
                  S5        [        R                  " [        R                  [        R
                  5      nUR                  U l	        UR                  U l        g )NzGoogle API source)superr#   __init__r   API_NAMEAPI_VERSION_1r   GetClientInstanceMESSAGES_MODULE	_messages#projects_locations_googleApiSources_service)selfclient	__class__s     r   r'    GoogleApiSourceClientV1.__init__,   s]    	
!41--/B
 ##FOOV5I5IJF++DN>>DMr   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 GoogleAPISource.

Args:
  google_api_source_ref: Resource, the GoogleAPISource to create.
  google_api_source_message: GoogleAPISource, the googleApiSource message
    that holds googleApiSource's name, destination message bus, logging
    config, crypto key name, etc.
  dry_run: If set, the changes will not be committed, only validated

Returns:
  A long-running operation for create.
)parentgoogleApiSourcegoogleApiSourceIdvalidateOnly)r,   6EventarcProjectsLocationsGoogleApiSourcesCreateRequestParentRelativeNameNamer.   Create)r/   google_api_source_refgoogle_api_source_messagedry_run
create_reqs        r   r<   GoogleApiSourceClientV1.Create7   s_      	MM(//1>>@5388: 	 	N 	
  ==
++r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zGets the requested GoogleApiSource.

Args:
  google_api_source_ref: Resource, the GoogleApiSource to get.

Returns:
  The GoogleApiSource message.
r   )r,   3EventarcProjectsLocationsGoogleApiSourcesGetRequestr:   r.   Get)r/   r=   get_reqs      r   rE   GoogleApiSourceClientV1.GetP   sD     	JJ&335 	K 	
 
 ==W%%r   c           	          U R                   R                  UR                  5       US9n[        R                  " U R
                  USUUSS9$ )ab  List available googleApiSources in location.

Args:
  location_ref: Resource, the location to list GoogleApiSources 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 GoogleApiSources in the location.
)r4   pageSizegoogleApiSourcesrI   )servicerequestfieldlimit
batch_sizebatch_size_attribute)r,   4EventarcProjectsLocationsGoogleApiSourcesListRequestr:   r   YieldFromListr.   )r/   location_refrN   	page_sizelist_reqs        r   ListGoogleApiSourceClientV1.List`   sZ     	KK,,. 	L 	
 
 ## ' r   c                     U R                   R                  UR                  5       UUS9nU R                  R	                  U5      $ )a  Updates the specified GoogleApiSource.

Args:
  google_api_source_ref: Resource, the GoogleApiSource to update.
  google_api_source_message: GoogleApiSource, the googleApiSource message
    that holds googleApiSource's name, destination message bus, logging
    config, crypto key name, etc.
  update_mask: str, a comma-separated list of GoogleApiSource fields to
    update.

Returns:
  A long-running operation for update.
)r   r5   
updateMask)r,   5EventarcProjectsLocationsGoogleApiSourcesPatchRequestr:   r.   Patch)r/   r=   r>   update_mask	patch_reqs        r   r[   GoogleApiSourceClientV1.Patchz   sJ    " 	LL&3355" 	M 	
  ==y))r   c                     U R                   R                  UR                  5       S9nU R                  R	                  U5      $ )zDeletes the specified GoogleApiSource.

Args:
  google_api_source_ref: Resource, the GoogleApiSource to delete.

Returns:
  A long-running operation for delete.
rC   )r,   6EventarcProjectsLocationsGoogleApiSourcesDeleteRequestr:   r.   Delete)r/   r=   
delete_reqs      r   ra   GoogleApiSourceClientV1.Delete   sD     	MM&335 	N 	
 
 ==
++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b  UR	                  5       OSUUUS9n	UbH  U(       a   U R                   R                  SS9U	l        U	$ U R                   R                  SS9U	l         U	$ U(       a  U R                  U5      U	l        U	$ )N)logSeverity )r   destinationloggingConfigcryptoKeyNamelabelsT)enabledF)	r,   LoggingConfigLogSeverityValueValuesEnumGoogleApiSourcer:   OrganizationSubscriptionorganizationSubscription_BuildProjectSubscriptionsListprojectSubscriptions)
r/   r=   destination_reflogging_configcrypto_key_namerj   organization_subscriptionproject_subscriptionslogging_config_enumgoogle_api_sources
             r   BuildGoogleApiSource,GoogleApiSourceClientV1.BuildGoogleApiSource   s    ! NN88nn22MM 9 
 66"//1& $002)% 7  !,	"NN33 4  	2  NN33 4  	2 	 


-
-.C
D , r   c	                    / n	U(       a  U	R                  S5        U(       a  U	R                  S5        U(       d  U(       a  U	R                  S5        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 GoogleApiSource.

Args:
  destination: bool, whether to update the destination.
  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.
  organization_subscription: bool, whether to update the organization
    subscription.
  project_subscriptions: bool, whether to update the project subscriptions.
  clear_project_subscriptions: bool, whether to clear the project
    subscriptions.

Returns:
  The update mask as a string.


Raises:
  NoFieldsSpecifiedError: No fields are being updated.
rg   rh   ri   rj   rp   rr   z*Must specify at least one field to update.,)appendr
   join)
r/   rg   rt   
crypto_keyclear_crypto_keyrj   rv   rw   clear_project_subscriptionsr\   s
             r   BuildUpdateMask'GoogleApiSourceClientV1.BuildUpdateMask   s    @ K')%)" 34 ;/0"#OPP88K  r   c                 B    U R                   R                  R                  $ )zReturns the labels value class.)r,   rn   LabelsValuer/   s    r   LabelsValueClass(GoogleApiSourceClientV1.LabelsValueClass  s    >>))555r   c                 j    U(       d  [        S5      eU R                  R                  [        U5      S9$ )NzTMust specify at least one project number or project ID in the project subscriptions.)list)r   r,   ProjectSubscriptionsr   )r/   rw   s     r   rq   6GoogleApiSourceClientV1._BuildProjectSubscriptionsList  s7     0$  >>..D9N4O.PPr   c                     g)Nzgoogle-api-sourcesr   r   s    r   _resource_label_plural.GoogleApiSourceClientV1._resource_label_plural  s    r   )r,   r.   )F)r   r   r   r   r   r'   r<   rE   rV   r[   ra   rz   r   r   rq   propertyr   r   __classcell__)r1   s   @r   r#   r#   )   sV    X	? GL,2& 4*2, +Z0!d6Q    r   r#   N)r   apitools.base.pyr   googlecloudsdk.api_lib.eventarcr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   Errorr
   r   r!   EventarcClientBaser#   r   r   r   <module>r      s]    3 ( 0 2 , * )CZ-- C<:+;+; <'g d55 g r   