
    ^              	          S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSK	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rSSKrSSKrSSKJr  SSKJr  SSKrSSKJr   SSK J!r"  Sr$Sq%       S2S jr& " S S\RN                  " S/ SQ5      5      r(S r) " S S\RT                  RV                  5      r+S r,Sr-S r.S r/      S3S jr0  S4S jr1S  r2 " S! S"\Rf                  5      r3 " S# S$\Rh                  5      r4 " S% S&\Rj                  5      r5S' r6 " S( S)5      r7S5S* jr8 " S+ S,\Rr                  " \Rt                  5      5      r; " S- S.5      r<S/ r=S0 r>S1 r?g! \# a    SSKr" GNf = f)6z;A module to get an unauthenticated requests.Session object.    )absolute_import)division)unicode_literalsN)requests_MutualTlsOffloadAdapter)context_aware)log)
properties)	transport)http_proxy_types)	platforms)http_client)urllibcreate_urllib3_contextah  It appears that the current proxy configuration is using an HTTPS scheme for contacting the proxy server, which likely indicates an error in your HTTPS_PROXY environment variable setting. This can usually be resolved by setting HTTPS_PROXY=http://... instead of HTTPS_PROXY=https://... See https://cloud.google.com/sdk/docs/proxy-settings for more information.Fc                 R    [        XUXV5      n[        5       R                  UUUS9nU$ )a  Get a requests.Session that is properly configured for use by gcloud.

This method does not add credentials to the client. For a requests.Session
that has been authenticated, use core.credentials.requests.GetSession().

Args:
  timeout: double, The timeout in seconds. This is the
      socket level timeout. If timeout is None, timeout is infinite. If
      default argument 'unset' is given, a sensible default is selected using
      transport.GetDefaultTimeout().
  ca_certs: str, absolute filename of a ca_certs file that overrides the
      default. The gcloud config property for ca_certs, in turn, overrides
      this argument.
  session: requests.Session instance
  streaming_response_body: bool, True indicates that the response body will
      be a streaming body.
  redact_request_body_reason: str, the reason why the request body must be
      redacted if --log-http is used. If None, the body is not redacted.
  client_certificate: str, absolute filename of a client_certificate file that
      is set explicitly for client certificate authentication
  client_key: str, absolute filename of a client_key file that
      is set explicitly for client certificate authentication

Returns:
  A requests.Session object configured with all the required settings
  for gcloud.
)streaming_response_bodyredact_request_body_reason)_CreateRawSessionRequestWrapperWrapWithDefaults)timeoutca_certssessionr   r   client_certificate
client_keyr   s           :/root/google-cloud-sdk/lib/googlecloudsdk/core/requests.py
GetSessionr   >   s@    D "'W"4B+ 115!; 2 =+ 
    c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )ClientSideCertificatei   zHolds information about a client side certificate.

Attributes:
  certfile: str, path to a cert file.
  keyfile: str, path to a key file.
  password: str, password to the private key.
c                 ,   > [         [        U ]  XX#5      $ N)superr"   __new__)clscertfilekeyfilepassword	__class__s       r   r'   ClientSideCertificate.__new__t   s    &4w* *r     r%   )__name__
__module____qualname____firstlineno____doc__r'   __static_attributes____classcell__r,   s   @r   r"   r"   i   s    * *r    r"   )r)   r*   r+   c                      [        5       $ )zReturns a urrlib3 SSL context.r   r.   r    r   CreateSSLContextr8   y   s    		!!r    c                   J   ^  \ rS rSrSrU 4S jrU 4S jrU 4S jrS rSr	U =r
$ )HTTPAdapter~   a3  Transport adapter for requests.

Transport adapters provide an interface to extend the default behavior of the
requests library using the full power of the underlying urrlib3 library.

See https://requests.readthedocs.io/en/master/user/advanced/
    #transport-adapters for more information about adapters.
c                 :   > Xl         [        [        U ]  " U0 UD6  g r%   )
_cert_infor&   r:   __init__)selfclient_side_certificateargskwargsr,   s       r   r>   HTTPAdapter.__init__   s    -O	+t%t6v6r    c                 N   > U R                  U5        [        [        U ]  " U0 UD6$ r%   )_add_ssl_contextr&   r:   init_poolmanagerr?   rA   rB   r,   s      r   rF   HTTPAdapter.init_poolmanager   s(    &!d4dEfEEr    c                 N   > U R                  U5        [        [        U ]  " U0 UD6$ r%   )rE   r&   r:   proxy_manager_forrG   s      r   rJ   HTTPAdapter.proxy_manager_for   s(    &!d5tFvFFr    c                    U R                   (       d  g [        5       nUR                  5         0 nU R                   R                  (       a  U R                   R                  US'   U R                   R                  (       a  U R                   R                  US'   UR
                  " U R                   R                  40 UD6  X!S'   g )Nr*   r+   ssl_context)r=   r8   load_default_certsr*   r+   load_cert_chainr)   )r?   rB   contextcert_chain_kwargss       r   rE   HTTPAdapter._add_ssl_context   s    ?? G %)__%<%<	"&*oo&>&>
#DOO44J8IJ#=r    )r=   )r/   r0   r1   r2   r3   r>   rF   rJ   rE   r4   r5   r6   s   @r   r:   r:   ~   s#    7FG$ $r    r:   c                     [         R                  R                  R                  R	                  5       n [         R                  R                  R
                  R	                  5       n[         R                  R                  R                  R                  5       n[        XU4 Vs/ s H  o3(       d  M  UPM     sn5      nUS:  a  US:w  a  [         R                  " S5      eU(       d  g[         R                  R                  R                  R                  5       n[         R                  R                  R                  R	                  5       n[         R                  R                  R                  R	                  5       n[        R                  U    nU[         R"                  :X  a  U(       a  SOSn	OQU[         R$                  :X  a  U(       a  SOSn	O1U[         R&                  :X  a  S	n	O[)        S
R+                  U 5      5      eU(       d  U(       a  SR-                  S Xg4 5       5      n
U
S-  n
OSn
SR+                  XUU5      $ s  snf )zReturns the proxy string for use by requests from gcloud properties.

See https://requests.readthedocs.io/en/master/user/advanced/#proxies.
r      z\Please set all or none of the following properties: proxy/type, proxy/address and proxy/portNsocks4asocks4socks5hsocks5httpzUnsupported proxy type: {}:c              3   r   #    U  H-  n[         R                  R                  U5      =(       d    S v   M/     g7f) N)r   parsequote).0xs     r   	<genexpr>GetProxyInfo.<locals>.<genexpr>   s,      G-E1##-Es   57@r\   z{}://{}{}:{})r   VALUESproxy
proxy_typeGetaddressportGetIntlenInvalidValueErrorrdnsGetBoolusernamer+   r   PROXY_TYPE_MAPsocksPROXY_TYPE_SOCKS4PROXY_TYPE_SOCKS5PROXY_TYPE_HTTP
ValueErrorformatjoin)rf   proxy_address
proxy_portfproxy_prop_set
proxy_rdns
proxy_user
proxy_passhttp_proxy_typeproxy_scheme
proxy_auths              r   GetProxyInfor      s   
   &&11557*##))11557-  &&++224*j9?9QQq9?A.aNa/

&
&	34 4 

  &&++335*  &&//335*  &&//335*$33J?//// *9L%111 *9L%///L
188D
EE: G.8-EG GJ#JJ			|)
+ +; @s   "
I0Ia  Please use the installed gcloud CLI (`apt install google-cloud-cli`)
 This version of gcloud you are currently using will encounter issues due to
 changes in internal security policy enforcement in the near future.

 If this is not possible due to dev requirements, please apply for
 policy exemption at go/gcloud-cba-exemption-internal-version-gcloud using this error message to self-exempt or reach out to
 go/gcloud-cba-investigation for investigation.
c                     [        U 5      $ r%   r   )certificate_config_file_paths    r   CreateMutualTlsOffloadAdapterr      s    	!">	??r    c                  T   [         R                  R                  5       [         R                  R                  :H  n [        R
                  =(       a    S[        R
                  ;   n[        R                  " 5       nU (       a)  U(       d"  U(       a  [        R                  " [        5        gg)a]  Warn users if running non-bundled Python on Linux and is a Googler.

Checks if the current OS is Linux, running Python that is not bundled and if
the user is a Googler. If all conditions are true, a warning message will be
emitted, along with returning true to bypass the mTLS code path.

Returns:
  True if the conditions are met, False otherwise.
bundledTF)r   OperatingSystemCurrentLINUXsys
executabler   IsInternalUserCheckr
   warning_GOOGLER_BUNDLED_PYTHON_WARNING)is_linuxis_bundled_pythonis_internal_users      r   %_LinuxNonbundledPythonAndGooglerCheckr      so     '')Y-F-F-L-LL nnDcnn)D335',<KK/0r    c                   ^ ^
^ U=(       d    [         R                  " 5       n[        5       mUR                  m
U
UU 4S jnXcl        T(       a  SUl        TTS.Ul        O6[        5       (       a'  [        (       d  Sq[        R                  " [        5        SnUb5  Ub2  Ub/  [        R                  " SXU5        [        XE5      n[        U5      nO[        R                  " 5       n	U	(       a  [!        5         U	R"                  [        R$                  R&                  :X  a  [)        U	R*                  5      nOU	R"                  [        R$                  R,                  :X  aX  [        R                  " SU	R.                  5        [        U	R.                  U	R.                  U	R0                  5      n[        U5      nO[        S5      nO[        S5      nU(       a  SUl        OU(       a  Xl        UR5                  SU5        U$ )	a  Returns a requests.Session subclass.

Args:
  timeout: float, Request timeout, in seconds.
  ca_certs: str, absolute filename of a ca_certs file
  disable_ssl_certificate_validation: bool, If true, disable ssl certificate
      validation.
  session: requests.Session instance. Otherwise, a new requests.Session will
      be initialized.
  client_certificate: str, absolute filename of a client_certificate file
  client_key: str, absolute filename of a client_key file

Returns: A requests.Session subclass.
c                     > SU;  a  TUS'   [        5       (       a-  SU;  a'  [        T[        R                  " 5       T/U Q70 UD6US'   T" U 0 UD6$ )Nr   proxies)_HasBpo42627_AdjustProxiesKwargForBpo42627urllib_requestgetproxies_environment)rA   rB   orig_request_method
proxy_infor   s     r   WrappedRequestSession.<locals>.WrappedRequest  sg    !fY ~~)618
n;;=
0 $0(.0fY ///r    F)rY   httpsTNzVUsing provided server certificate %s, client certificate %s, client certificate key %szUsing client certificate %shttps://)r   Sessionr   request	trust_envr   !_HasInvalidHttpsProxyEnvVarScheme*_invalid_https_proxy_env_var_warning_shownr
   r   $_INVALID_HTTPS_PROXY_ENV_VAR_WARNINGdebugr"   r:   r	   Configr   config_type
ConfigTypeENTERPRISE_CERTIFICATEr   r   ON_DISK_CERTIFICATEencrypted_client_cert_pathencrypted_client_cert_passwordverifymount)r   r   "disable_ssl_certificate_validationr   r   r   r   r@   adapter	ca_configr   r   s   `         @@r   r   r      s   * )x'')'~*
0 #/GGO )** 65 480	kk67 #
(>8CWII`j2 4(12G$$&I+-			-":":"Q"Q	Q/224  M$<$<$P$PP		/66	8"7000044#6 56d#D!g'GNN	--
G$	.r    c           	      X   U S:w  a  U nO[         R                  " 5       n[        R                  R                  R
                  R                  5       =(       d    Sn[        R                  R                  R                  R                  5       nU(       a  UnU(       a  Sn[        UUUUUUS9$ )zECreate a requests.Session matching the appropriate gcloud properties.unsetFN)r   r   r   r   r   r   )r   GetDefaultTimeoutr   rd   authdisable_ssl_validationrn   corecustom_ca_certs_filerg   r   )r   r   r   r   r   effective_timeoutno_validateca_certs_propertys           r   r   r   S  s     !335!!&&==EEGP5+ '',,AAEEG HH	*"4? $6&
( (r    c                 ~   [         R                  R                  U 5      n[         R                  R                  UR                  SS9n[
        R                  " U=(       d    0 5       H	  u  pEXSU'   M     [        U5      n[         R                  R                  USS9US'   [         R                  R                  U5      $ )zFGets the complete URI by merging url and params from the request args.T)keep_blank_values)doseqrT   )
r   r]   urlsplitparse_qsquerysix	iteritemslist	urlencode
urlunsplit)urlparams	url_partsquery_paramsparamvalues         r   _GetURIFromRequestArgsr   m  s    ll##C()&&y$&O,mmFLb1le 2 9o)''D'A)A, 
	 	 	++r    c                   F   ^  \ rS rSrSr\S 5       rSU 4S jjrS rSr	U =r
$ )Requesti|  a  Encapsulates parameters for making a general HTTP request.

This implementation does additional manipulation to ensure that the request
parameters are specified in the same way as they were specified by the
caller. That is, if the user calls:
    request('URI', 'GET', None, {'header': '1'})

After modifying the request, we will call request using positional
parameters, instead of transforming the request into:
    request('URI', method='GET', body=None, headers={'header': '1'})
c                     U " U0 UD6$ r%   r.   )r(   rA   rB   s      r   FromRequestArgsRequest.FromRequestArgs  s    r    c                 d   > X`l         [        X#5      n[        [        U ]  XqU=(       d    0 U5        g r%   )_kwargsr   r&   r   r>   )	r?   methodr   r   dataheadersrB   urir,   s	           r   r>   Request.__init__  s)    L
 
-C	'4!#w}"dCr    c                     U R                   U R                  /n[        U R                  5      nU R                  US'   U R
                  (       a  U R
                  US'   X4$ )Nr   r   )r   r   dictr   r   body)r?   rA   rB   s      r   ToRequestArgsRequest.ToRequestArgs  sL    KK"D$,,FF9yyyyfVn<r    )r   )NNN)r/   r0   r1   r2   r3   classmethodr   r>   r   r4   r5   r6   s   @r   r   r   |  s,    
    D r    r   c                   (    \ rS rSrSr\S 5       rSrg)Responsei  z:Encapsulates responses from making a general HTTP request.c                 R    U " UR                   UR                  UR                  5      $ r%   )status_coder   content)r(   responses     r   FromResponseResponse.FromResponse  s#    x##X%5%5x7G7GHHr    r.   N)r/   r0   r1   r2   r3   r   r   r4   r.   r    r   r   r     s    BI Ir    r   c                   &    \ rS rSrSr\r\rS r	Sr
g)r   i  z,Class for wrapping request.Session requests.c                     AU$ )z&Returns the response without decoding.r.   )r?   r   response_encodings      r   DecodeResponseRequestWrapper.DecodeResponse  s
    Or    r.   N)r/   r0   r1   r2   r3   r   request_classr   response_classr   r4   r.   r    r   r   r     s    4-.r    r   c                  :    [         R                  " [        5       S9$ )zGReturns a gcloud's requests session to refresh google-auth credentials.)r   )google_auth_requestsr   r   r.   r    r   GoogleAuthRequestr     s    		%	%jl	;;r    c                        \ rS rSrS rS rSrg)_GoogleAuthApitoolsCredentialsi  c                     Xl         g r%   credentials)r?   r   s     r   r>   '_GoogleAuthApitoolsCredentials.__init__  s    "r    c                 P    A[        5       nU R                  R                  U5        g r%   )r   r   refresh)r?   r   auth_requests      r   r   &_GoogleAuthApitoolsCredentials.refresh  s!    $&L\*r    r   N)r/   r0   r1   r2   r>   r   r4   r.   r    r   r   r     s    #+r    r   c                    ^ [        XU5      n[        U S5      (       aD  [        U R                  5      nUR                  mU4S jnXSl        [        UR                  SU5        U$ )zGReturns an authenticated httplib2.Http-like object for use by apitools._googlecloudsdk_credentialsc                     > T" U 0 UD6$ r%   r.   )rA   rB   r   s     r   HttpRequest(GetApitoolsRequests.<locals>.HttpRequest  s     $1&11r    r   )_ApitoolsRequestshasattrr   r   r   setattr)r   response_handlerr   r   credsr  r   s         @r   GetApitoolsRequestsr    sa    !'=NO+ W344*7+N+NOE%--2 &K6	r    c                   B    \ rS rSrSrS r\R                  S 5       rSr	g)ResponseHandleri  zHandler to process the Http Response.

Attributes:
  use_stream: bool, if True, the response body gets returned as a stream
      of data instead of returning the entire body at once.
c                     Xl         g)zInitializes ResponseHandler.

Args:
  use_stream: bool, if True, the response body gets returned as a stream of
    data instead of returning the entire body at once.
N
use_stream)r?   r  s     r   r>   ResponseHandler.__init__  s	     !Or    c                     g)zHandles the http response.Nr.   )r?   response_streams     r   handleResponseHandler.handle  s    r    r  N)
r/   r0   r1   r2   r3   r>   abcabstractmethodr  r4   r.   r    r   r
  r
    s&    ! % %r    r
  c                   <    \ rS rSrSrSS jrS r     S	S jrSrg)
r  i  z0A httplib2.Http-like object for use by apitools.Nc                     Xl         0 U l        U(       a   [        U[        5      (       d  [	        S5      eX l        X0l        g )Nz3response_handler should be of type ResponseHandler.)r   connections
isinstancer
  ru   _response_handler_response_encoding)r?   r   r  r   s       r   r>   _ApitoolsRequests.__init__  s:    L D(/::NOO-/r    c                 4   AAUR                   [        R                  [        R                  4;  a  [        R
                  " S5        gU R                  R                  (       a  [        R                  R                  R                  R                  5       (       aX  [        R                  R                  R                  R                  5       (       a!  [        R                  " UR                   5      nOUR"                  nU R                  R%                  U5        g)z:Response hook to be used if response_handler has been set.z1Skipping response_handler as response is invalid.N)r   httplibOKPARTIAL_CONTENTr
   r   r  r  r   rd   r   log_httprn   log_http_streaming_bodyioBytesIOr   rawr  )r?   r   rA   rB   streams        r   ResponseHook_ApitoolsRequests.ResponseHook  s    fGJJ0G0G#HH	iiCD))''//1166>>@@ zz(**+f||f!!&)r    c           	         AUS:  a  XPR                   l        0 nU R                  b&  U R                  US'   U R                  R                  nOSnU R                   R                  X!X4XS9n	[        U	R                  5      nU	R                  US'   U(       a  Sn
O7U R                  b  U R                  U	l
        U	R                  n
OU	R                  n
[        R                  " U5      U
4$ )z/Makes an HTTP request using httplib2 semantics.r   r   F)r   r   r%  hooksstatusr    )r   max_redirectsr  r&  r  r   r   r   r   r  encodingtextr   httplib2r   )r?   r   r   r   r   redirectionsconnection_typer)  r  r   r   s              r   r   _ApitoolsRequests.request  s     	a#/ll E)++eJ))44jj||##$
 $ QH8##$G ,,GH g		 	 	,
 11hg  gW%w..r    )r  r  r  r   NN)GETNNr   N)	r/   r0   r1   r2   r3   r>   r&  r   r4   r.   r    r   r  r    s%    8	0** )/r    r  c                  n    [         R                  " 5       n U R                  SS5      R                  S5      $ )zAReturns whether the HTTPS proxy env var is using an HTTPS scheme.r   r\   r   )r   r   get
startswith)env_proxiess    r   r   r   7  s.    
 557+	"	%	0	0	<<r    c                     [         R                  R                  5       [         R                  R                  :H  =(       aK    [	        [
        S5      =(       a4    [
        R                  " 5       R                  SS5      R                  S5      $ )a  Returns whether Python is affected by https://bugs.python.org/issue42627.

Due to a bug in Python's standard library, urllib.request misparses the
Windows registry proxy settings and assumes that HTTPS URLs should use an
HTTPS proxy, when in fact they should use an HTTP proxy.

This bug affects PY<3.9, as well as lower patch versions of 3.9, 3.10, and
3.11.

Returns:
  True if proxies read from the Windows registry are being parsed incorrectly.
getproxies_registryr   r\   r   )	r   r   r   WINDOWSr  r   r9  r5  r6  r.   r    r   r   r   @  sh     '')Y-F-F-N-NN 
."7
8

,
,
.
2
27B
?
J
J
r    c                 "   U (       d  U(       a  g[         R                  " U/UQ70 UD6S   n[        R                  R	                  U5      nUR                  S5      nU(       d  gUR                  S5      (       d  gSUR                  SSS5      0$ )a  Returns proxies to workaround https://bugs.python.org/issue42627 if needed.

Args:
  gcloud_proxy_info: str, Proxy info from gcloud properties.
  environment_proxies: dict, Proxy config from http/https_proxy env vars.
  orig_request_method: function, The original requests.Session.request method.
  *args: Positional arguments to the original request method.
  **kwargs: Keyword arguments to the original request method.
Returns:
  Optional[dict], Adjusted proxies to pass to the request method, or None if
    no adjustment is necessary.
Nr   r   r   zhttp://   )inspectgetcallargsr   utilsget_environ_proxiesr5  r6  replace)gcloud_proxy_infoenvironment_proxiesr   rA   rB   r   r   https_proxys           r   r   r   U  s    & - 	/A$A&A%H#NN..s3'G$+				
	+	+
  {"":y!<
 r    )r   NNFNNN)NNFNNN)r   NNNNr2  )@r3   
__future__r   r   r   r  collectionsr=  r"  r   google.auth.transportr   r   google.auth.transport.requestsr   googlecloudsdk.corer	   r
   r   r   googlecloudsdk.core.utilr   r   r.  r   	six.movesr   r  r   rq   urllib3.util.ssl_r   urllib.requestr   r   ImportErrorr   r   r   
namedtupler"   r8   adaptersr:   r   r   r   r   r   r   r   r   r   r   r   r   r  with_metaclassABCMetar
  r  r   r   r   r.   r    r   <module>rS     s    B &  ' 
   	 
 B C - # * ) 5 .   
 ,   4")Q % .3 * ',*."&(V*2>@* "
%$(##// %$P(+X8  @, ',[| ?C:>(4,i @Iy!! I
Y-- 
<
+ +(%c((5 %,I/ I/X=*,K  "!"s   <E< <
F
	F
