
                             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 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\\\4   4S jrS rg)z6Provides common arguments for the Run command surface.    )absolute_import)division)print_function)unicode_literals)Dict)types_utils)	validator)arg_parsers)
propertiesc                 L    U R                  S[        R                  " 5       SS9  g)zAdds a FILE positional arg.FILEzVThe absolute path to the YAML file with an application definition to update or deploy.typehelpN)add_argumentr
   YAMLFileContentsparsers    8lib/googlecloudsdk/command_lib/run/integrations/flags.py
AddFileArgr      s)    '')(  )    c                 $    U R                  SSS9  g)z(Adds an integration type positional arg.r   zType of the integration.r   Nr   r   s    r   AddPositionalTypeArgr   '       %  'r   c                 $    U R                  SSS9  g)z Adds a service-account argument.z--service-accountzBName of the service account to use when deploying the integration.r   Nr   r   s    r   AddServiceAccountArgr   .   s    O  r   c                 &    U R                  SSSS9  g)zAdds an integration type arg.--typeTzlType of the integration. To see available types and usage, use "gcloud run integrations types list" command.)requiredr   Nr   r   s    r   
AddTypeArgr"   6   s!    ?  @r   c                 $    U R                  SSS9  g)Adds an integration name arg.z--nameName of the integration.r   Nr   r   s    r   
AddNameArgr&   ?   s    %  'r   c                 $    U R                  SSS9  g)r$   namer%   r   Nr   r   s    r   AddNamePositionalArgr)   F   r   r   c                 $    U R                  SSS9  g)zAdds a service arg for create.	--servicezaName of the Cloud Run service to attach to the integration. It is required for some integrations.r   Nr   r   s    r   AddServiceCreateArgr,   M   s    .  /r   c                 d    U R                  5       nUR                  SSS9  UR                  SSS9  g)z"Adds service arguments for update.z--add-servicez;Name of the Cloud Run service to attach to the integration.r   z--remove-servicez=Name of the Cloud Run service to remove from the integration.N)add_mutually_exclusive_groupr   )r   groups     r   AddServiceUpdateArgsr0   U   sF    

-
-
/%H  J J  Lr   c           	      n    U R                  S[        R                  " 5       [        R                  0 SSS9  g)zAdds a parameters arg.z--parameterszPARAMETER=VALUEzComma-separated list of parameter names and values. Names must be one of the parameters shown when describing the integration type. Only simple values can be specified with this flag.)r   actiondefaultmetavarr   N)r   r
   ArgDictUpdateActionr   s    r   AddParametersArgr7   `   s:     %%N  Or   c                 |    [         R                  " U 5        [        R                  " U 5      nUR	                  5         g)z@Validates user has enabled APIs, or else prompts user to enable.N)r   CheckValidIntegrationTyper	   GetIntegrationValidatorValidateEnabledGcpApis)integration_typevalidates     r   r;   r;   m   s.    ''(89../?@(
!!#r   c                 ~    [         R                  " U 5        [        R                  " U 5      nUR	                  X5        g)zGValidates given params conform to what's expected from the integration.N)r   r9   r	   r:   ValidateCreateParameters)r<   
parametersservicer=   s       r   r?   r?   t   s0    ''(89../?@(
##J8r   c                 ~    [         R                  " U 5        [        R                  " U 5      nUR	                  U5        g)z<Validate params for update commands for a given integration.N)r   r9   r	   r:   ValidateUpdateParameters)r<   r@   r=   s      r   rC   rC   {   s0    ''(89../?@(
##J/r   c                 .    U R                  S[        SS9  g)zFilter by Service Name.r+   z1Filter Integrations by Name of Cloud Run service.r   Nr   strr   s    r   ListIntegrationsOfServicerG      s    >  @r   c                 .    U R                  S[        SS9  g)zFilter by Integration Type.r    z+Filter Integrations by Type of Integration.r   NrE   r   s    r   ListIntegrationsOfTyperI      s    SL  Nr   returnc                 l    0 nU R                  S5      (       a  UR                  U R                  5        U$ )z6Validates all parameters and returns a dict of values.r@   )IsSpecifiedupdater@   )argsr@   s     r   GetParametersrO      s0    *	l##doo&	r   c                    [        U SS5      (       a  U R                  $ [        R                  R                  R
                  R                  5       (       a2  [        R                  R                  R
                  R                  5       $ g)zDecides the service account to use.

Service account is decided in the following order:
- service_account flag
- service_account gcloud config;

Args:
  args: Namespace, the args namespace.

Returns:
  A str representing service account.
service_accountN)getattrrQ   r   VALUESrunappsdeployment_service_accountIsExplicitlySetGet)rN   s    r   GetServiceAccountrX      sh     T$d++99IIKK$$??CCEE Lr   N) __doc__
__future__r   r   r   r   typingr   'googlecloudsdk.api_lib.run.integrationsr   r	   googlecloudsdk.callioper
   googlecloudsdk.corer   r   r   r   r"   r&   r)   r,   r0   r7   r;   r?   rC   rG   rI   rF   rO   rX    r   r   <module>r`      s    = &  % '  ? = / *)'@''/L
O$90@N4S> Fr   