
    "                        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  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S jrS rS r S r!S r"\RF                  " \RH                  RJ                  \RH                  RL                  \RH                  RN                  5       " S S\RP                  5      5       r)g)z$Import target HTTPS Proxies command.    )absolute_import)division)unicode_literals)
exceptions)base_classes)base)flags)operation_utils)scope)target_https_proxies_utils)util)yaml_validator)
console_ioc                      SSSS.$ )NzImport a target HTTPS proxy.zN          Imports a target HTTPS proxy's configuration from a file.
          a            A global target HTTPS proxy can be imported by running:

            $ {command} NAME --source=<path-to-file>

          A regional target HTTPS proxy can be imported by running:

            $ {command} NAME --source=<path-to-file> --region=REGION_NAME
          )briefDESCRIPTIONEXAMPLES r       2lib/surface/compute/target_https_proxies/import.py_DetailedHelpr   #   s     )
 r   c                     U [         R                  R                  :X  a  gU [         R                  R                  :X  a  gg)z3Returns the API version based on the release track.alphabetav1)r   ReleaseTrackALPHABETA)release_tracks    r   _GetApiVersionr    8   s3    d''---))...	r   c                 B    [         R                  " S[        U 5      SUS9$ )z!Returns the resource schema path.computeTargetHttpsProxyfor_help)export_utilGetSchemaPathr    )r   r%   s     r   _GetSchemaPathr(   A   s&    		"	"]#	
 r   c                    [         R                  " U5      (       aU  U R                  R                  nUR	                  U R
                  R                  UR                  UR                  US95      nOIU R                  R                  nUR	                  U R
                  R                  UR                  US95      n[        XUUS5      $ )z(Sends Target HTTPS Proxy insert request.)projectregiontargetHttpsProxy)r*   r,   zInserting TargetHttpsProxy)r   IsRegionalTargetHttpsProxiesRefapitools_clientregionTargetHttpsProxiesInsertmessages,ComputeRegionTargetHttpsProxiesInsertRequestr*   r+   targetHttpsProxies&ComputeTargetHttpsProxiesInsertRequest_WaitForOperationclient	resourcestarget_https_proxy_reftarget_https_proxyservice	operations         r   _SendInsertRequestr=   J   s      ?? $$==GDD*22)00/ 	E 	12I $$77G>>*22/ 	? 	12I
 
9y13O
Q Qr   c           	         [         R                  " U5      (       ad  U R                  R                  nUR	                  U R
                  R                  UR                  UR                  UR                  5       US95      nOXU R                  R                  nUR	                  U R
                  R                  UR                  UR                  5       US95      n[        XUUS5      $ )z%Make target HTTP proxy patch request.)r*   r+   r,   targetHttpsProxyResource)r*   r,   r?   zUpdating TargetHttpsProxy)r   r-   r.   r/   Patchr1   +ComputeRegionTargetHttpsProxiesPatchRequestr*   r+   Namer3   %ComputeTargetHttpsProxiesPatchRequestr5   r6   s         r   _SendPatchRequestrD   `   s      ?? $$==GCC*22)00388:%7	 	D 	9:I $$77G==*22388:%7 	> 	9:I 
9y13N
P Pr   c                     [         R                  " U5      (       a  [        R                  " 5       nO[        R                  " 5       n[        R
                  " XUXSU5      $ )z3Waits for the TargetHttpsProxy operation to finish.)r   r-   r
   GetRegionalOperationsCollectionGetGlobalOperationsCollectionWaitForOperation)r8   r;   r<   r9   message
collections         r   r5   r5   x   sS      ??  @@BJ >>@J		)	))i*4*1
3 3r   c                    UR                   nUR                  nUR                  U UR                  [        R                  R
                  [        R                  " U5      S9n[        R                  " U R                  =(       d    SSS9n [        R                  " UR                  R                  U[        U5      S9n [(        R*                  " XF5      n
X:X  a  g[        R4                  " SR7                  UR9                  5       5      S	S
9  U
R:                  Ul        [=        U
S5      (       a  U
R>                  Ul        / nUR@                  c  URC                  S5        URD                  c  URC                  S5        URF                  c  URC                  S5        [=        US5      (       a  URH                  c  URC                  S5        [=        US5      (       a"  URJ                  (       d  URC                  S5        URL                  c  URC                  S5        URN                  c  URC                  S5        URP                  (       d  URC                  S5        URR                  c  URC                  S5        URT                  c  URC                  S5        URV                  RY                  U5         [[        XEUU5      sSSS5        $ ! [         R"                   a$  n	[$        R"                  " ['        U	5      5      eSn	A	ff = f! [,        R.                   a)  nUR0                  S:w  a  Ue[3        XEUU5      s SnA$ SnAff = f! , (       d  f       g= f)z9Issues requests necessary to import target HTTPS proxies.)default_scopescope_lister-F)binary)message_typestreamschema_pathNi  z-Target Https Proxy [{0}] will be overwritten.T)rI   cancel_on_nofingerprintdescriptionserverTlsPolicyauthorizationPolicycertificateMaphttpFilters	proxyBindquicOverridesslCertificates	sslPolicyurlMap).r7   r8   ResolveAsResourcecompute_scope	ScopeEnumGLOBALcompute_flagsGetDefaultScopeListerr   ReadFromFileOrStdinsourcer&   Importr1   r#   r(   r   ValidationErrorcompute_exceptionsstrr   SendGetRequestapitools_exceptions	HttpErrorstatus_coder=   PromptContinueformatrB   idhasattrrT   rU   appendrV   rW   rX   rY   rZ   r[   r\   r]   r^   r.   IncludeFieldsrD   )argsholdertarget_https_proxy_argr   r7   r8   r9   datar:   eold_target_https_proxyerrorcleared_fieldss                r   _Runr}      s   ==&)1CC
!++22 66v>	 D @ 
	'	'(:s5	I$5$++__55"=1327FF( 1
>FF
 
%
%
') 133#]33%;%G%G" .##+-(''/+,++3/0 #5#D#D#L*+ $6$B$B-(!!)+&$$,.)		+	++,!!)+&&(#++N;V0F/1 <;m 
	'	' 5

,
,SV
445 
	&	& 2Ckf1G02 2	2^ <;sB   
3K	 >L 2M	LK<<LML<6M<M
Mc                   @    \ rS rSrSr\" 5       rSr\S 5       r	S r
Srg)rg      zImport a target HTTPS Proxy.Nc                     [         R                  " 5       U l        U R                  R                  USS9  [        R
                  " U[        U R                  5       SS95        g )Nimport)operation_typeTr$   )r	   TargetHttpsProxyArgumentTARGET_HTTPS_PROXY_ARGAddArgumentr&   AddImportFlagsr(   r   )clsparsers     r   ArgsImport.Args   sP    !&!?!?!AC**6(*Ks//1DACr   c                     [         R                  " U R                  5       5      n[        XU R                  U R                  5       5      $ )N)r   ComputeApiHolderr   r}   r   )selfru   rv   s      r   Run
Import.Run   s9    **4+<+<+>?Fd994;L;L;NOOr   r   )__name__
__module____qualname____firstlineno____doc__r   detailed_helpr   classmethodr   r   __static_attributes__r   r   r   rg   rg      s.     %/-C CPr   rg   N)F)*r   
__future__r   r   r   apitools.base.pyr   rl   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computeri   r	   rc   r
   r   r`   7googlecloudsdk.command_lib.compute.target_https_proxiesr   !googlecloudsdk.command_lib.exportr   r&   googlecloudsdk.corer   googlecloudsdk.core.consoler   r   r    r(   r=   rD   r5   r}   ReleaseTracksr   GAr   r   UpdateCommandrg   r   r   r   <module>r      s    + &  ' > 7 ( O E > E I ^ A . 2*Q,P03J1Z D%%(($*;*;*@*@%%++-PT P-Pr   