
                         P   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KJr  \R$                  " \R&                  R(                  \R&                  R*                  5      \R,                   " S S\R.                  5      5       5       rg)zICommand for creating or replacing an application from YAML specification.    )absolute_import)division)unicode_literals)types_utils)base)pretty_print)deprecation_util)flags)messages_util)run_apps_operations)
exceptionsc                   >    \ rS rSrSrSSS.r\S 5       rS rS r	S	r
g
)Create   zCreate a Cloud Run Integration.z"          {description}
          a-            To create and attach a redis instance to a Cloud Run service

              $ {command} --type=redis --service=myservice

          To attach a custom domain to a Cloud Run service

              $ {command} --type=custom-domains --parameters='set-mapping=example.com/*:myservice'

         )DESCRIPTIONEXAMPLESc                     [         R                  " U5        [         R                  " U5        [         R                  " U5        [         R                  " U5        [         R
                  " U5        g)zPSet up arguments for this command.

Args:
  parser: An argparse.ArgumentParser.
N)r
   
AddTypeArg
AddNameArgAddServiceCreateArgAddParametersArgAddServiceAccountArg)clsparsers     &lib/surface/run/integrations/create.pyArgsCreate.Args4   sJ     
V	V	f%	6"	v&    c                    [         R                  " 5         [         R                  " 5         UR                  nUR                  nUR
                  n[        R                  " U5      n[        R                  " X%U5        [        R                  " U5        U R                  5       n[        R                  " X5       nUR                  5         U R                  UUUUS9  UR                  UUUUS9nSSS5        WR!                  W5      n	UR#                  U	R$                  5      n
[&        R(                  " U5      n[*        R,                  " S5        [*        R.                  " [0        R2                  " UUSS95        [0        R4                  " XU
5      nU(       aW  [*        R,                  " S5        [*        R,                  " U5        [*        R,                  " [0        R6                  " Xh5      5        gg! , (       d  f       GN= f)z Creates a Cloud Run Integration.)integration_typeserviceintegration_name)r    
parametersr!   nameN created)r    r"   action)r	   CheckIfEndOfSaleAppliesDeprecationNoticetyper!   r$   r
   GetParametersValidateCreateParametersValidateEnabledGcpApisReleaseTrackr   ConnectVerifyLocation'_validateServiceNameAgainstIntegrationsCreateIntegrationGetIntegrationGenericGetIntegrationStatusidr   GetTypeMetadatar   InfoSuccessr   GetSuccessMessageGetCallToActionCheckStatusMessage)selfargsr    r!   
input_namer#   release_trackclientr"   resourceresource_statusmetadatacall_to_actions                r   Run
Create.RunA   s   ,,.&&(yyllGJ$$T*J	""#3I	  !12%%'M		$	$T	9V
22
+%	 3   11+	 2  
: ++,<=H11(++>O**+;<Hb''--	
 #22ON '

*
*=
K = 
:	9s   85G--
G<c                     U(       d  g[         R                  " S5      nXC:X  a  UeUR                  US5      nU H  nUR                  U:X  d  M  Ue   g)z7Checks if the service name matches an integration name.Nz`Service name cannot be the same as the provided integration name or an existing integration name)r   ArgumentErrorListIntegrationsr"   )r<   r@   r    r"   r!   errorintegrationsintegrations           r   r1   .Create._validateServiceNameAgainstIntegrationsr   s\     $$	&E
 "k**+;TBL#		%	%	0 $r    N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr   rE   r1   __static_attributes__rN   r   r   r   r      s7     (		-  
' 
'/br   r   N)rS   
__future__r   r   r   'googlecloudsdk.api_lib.run.integrationsr   googlecloudsdk.callioper   googlecloudsdk.command_lib.runr   +googlecloudsdk.command_lib.run.integrationsr	   r
   r   r   "googlecloudsdk.command_lib.runappsr   ReleaseTracksr.   ALPHABETADefaultUniverseOnlyCommandr   rN   r   r   <module>rb      s    P &  ' ? ( 7 H = E K 9 D%%++T->->-C-CDaT\\ a  Ear   