
    9h                       S SK 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J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JrJrJrJrJrJrJrJrJr  S S	K J!r!J"r"  S S
K	J#r#  S SK$J%r%  SSK&J'r'J(r(   \)r*S\+S\+4S jr,\R\                  " \/5      r0SS/r1 " S S\ Rd                  S9r3 " S S\35      r4 " S S\35      r5 " S S\35      r6 " S S\75      r8 " S S \85      r9S!\:S\;4S" jr<S!\:S\;4S# jr=S$\:S%\:S&\:S\>4S' jr? " S( S)\75      r@ " S* S+\75      rA\" S,5      rB " S- S.\+\5      rC " S/ S0\+\5      rD\ " S1 S25      5       rE\" S3S49 " S5 S65      5       rF\ " S7 S85      5       rG\ " S9 S:5      5       rH\ " S; S<5      5       rI\" S3S49 " S= S>5      5       rJ\" S3S49 " S? S@5      5       rK " SA SB\+\5      rL\ " SC SD5      5       rM\" S3S3SE9 " SF SG5      5       rN\" S3S3SE9 " SH SI5      5       rOg! \- a    \+r*S\+S\+4S jr, GNf = f)J    N)unquoteurlparse)define)field)defaultdict)Enum)Lock)
ListDictTypeTypeVarcastOptionalUnionAnyTupleCallable)TTLCacheLRUCache)Response)OAuth2Client   )SchemaRegistryErrorOAuthTokenErrorvaluereturnc                 ,    [         R                  " U SS9$ N )safe)urllibquoter   s    {C:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\confluent_kafka/schema_registry/schema_registry_client.py
_urlencoder%   5   s    ||E++    c                 >    [         R                  R                  U SS9$ r   )r!   parser"   r#   s    r$   r%   r%   :   s    ||!!%b!11r&   URL	USER_INFOc                   @    \ rS rSr\R
                  S\4S j5       rSrg)_BearerFieldProviderA   r   c                     [         eNNotImplementedErrorselfs    r$   get_bearer_fields&_BearerFieldProvider.get_bearer_fieldsB   s    !!r&    N)	__name__
__module____qualname____firstlineno__abcabstractmethoddictr4   __static_attributes__r6   r&   r$   r,   r,   A   s!    "4 " "r&   r,   )	metaclassc                   8    \ rS rSrS\S\S\4S jrS\4S jrSrg	)
_StaticFieldProviderG   tokenlogical_clusteridentity_poolc                 (    Xl         X l        X0l        g r/   rC   rD   rE   )r3   rC   rD   rE   s       r$   __init___StaticFieldProvider.__init__H   s    
.*r&   r   c                 J    U R                   U R                  U R                  S.$ N)bearer.auth.tokenbearer.auth.logical.clusterbearer.auth.identity.pool.idrG   r2   s    r$   r4   &_StaticFieldProvider.get_bearer_fieldsM   s'    %)ZZPTPdPd040B0BD 	Dr&   )rE   rD   rC   N)	r7   r8   r9   r:   strrH   r=   r4   r>   r6   r&   r$   rA   rA   G   s*    +c +C + +
D4 Dr&   rA   c                   @    \ rS rSrS\\/\4   S\4S jrS\4S jrSr	g)	_CustomOAuthClientR   custom_functioncustom_configc                     Xl         X l        g r/   rT   rU   )r3   rT   rU   s      r$   rH   _CustomOAuthClient.__init__S   s    .*r&   r   c                 8    U R                  U R                  5      $ r/   rW   r2   s    r$   r4   $_CustomOAuthClient.get_bearer_fieldsW   s    ##D$6$677r&   )rU   rT   N)
r7   r8   r9   r:   r   r   r=   rH   r4   r>   r6   r&   r$   rR   rR   R   s,    +$(> +t +84 8r&   rR   c                   v    \ rS rSrS\S\S\S\S\S\S\S	\S
\4S jrS\4S jrS\	4S jr
S\4S jrSS jrSrg)_OAuthClient[   	client_idclient_secretscopetoken_endpointrD   rE   max_retriesretries_wait_msretries_max_wait_msc
                     S U l         XPl        X`l        [        XUS9U l        X@l        Xpl        Xl        Xl        SU l	        g )N)r^   r_   r`   g?)
rC   rD   rE   r   clientra   rb   rc   rd   token_expiry_threshold)
r3   r^   r_   r`   ra   rD   rE   rb   rc   rd   s
             r$   rH   _OAuthClient.__init__\   sD    
.*"Y[`a,&.#6 &)#r&   r   c                 R    U R                  5       U R                  U R                  S.$ rK   )get_access_tokenrD   rE   r2   s    r$   r4   _OAuthClient.get_bearer_fieldsh   s,    %)%:%:%<]a]q]q040B0BD 	Dr&   c                     U R                   S   U R                  -  nU R                   S   [        R                  " 5       U-   :  $ )N
expires_in
expires_at)rC   rg   time)r3   expiry_windows     r$   token_expired_OAuthClient.token_expiredl   s:    

<043N3NNzz,'$))+*EEEr&   c                     U R                   (       a  U R                  5       (       a  U R                  5         U R                   S   $ )Naccess_token)rC   rq   generate_access_tokenr2   s    r$   rj   _OAuthClient.get_access_tokenq   s2    zzT//11&&(zz.))r&   Nc           
         [        U R                  S-   5       H-  n U R                  R                  U R                  SS9U l          g    g ! [         av  nXR                  :  a$  [        SU R                   S[        U5       35      e[        R                  " [        U R                  U R                  U5      S-  5         S nAM  S nAff = f)Nr   client_credentials)url
grant_typezFailed to retrieve token after z attempts due to error:   )rangerb   rf   fetch_tokenra   rC   	Exceptionr   rP   ro   sleepfull_jitterrc   rd   )r3   ies      r$   ru   "_OAuthClient.generate_access_tokenw   s    t''!+,Ab![[449L9LYm4n
 -  b(((),KDL\L\K] ^DDGF8+M N N

;t';';T=U=UWXY\``aa	bs   )A
CA+CC)	rf   rE   rD   rb   rd   rc   rC   ra   rg   )r   N)r7   r8   r9   r:   rP   intrH   r=   r4   boolrq   rj   ru   r>   r6   r&   r$   r\   r\   [   sz    
*# 
*c 
*# 
*WZ 
*mp 
* #
*25
*HK
*be
*D4 DFt F
*# *	br&   r\   c                       \ rS rSrS\4S jrSS\S\\   S\4S jjr	S\S	\\   S\4S
 jr
S\S\4S jrSS\S	\\   S\4S jjrSrg)_BaseRestClient   confc                 &   UR                  5       nUR                  SS 5      nUc  [        S5      e[        U[        5      (       d   [        S[        [        U5      5      -   5      e/ nUR                  S5       Hy  nUR                  5       R                  S5      nUR                  S5      (       d0  UR                  S5      (       d  [        SR                  U5      5      eUR                  U5        M{     U(       d  [        S5      eX@l        S	U l        UR                  S
S 5      nUb  X`l        UR                  SS 5      nUR                  SS 5      nS U l        Ub  Ub  X4U l        Ub	  Uc  Xl        Ub  Uc  [        S5      e[#        U R                  S   5      n	 [%        U	R&                  5      [%        U	R(                  5      4n
SU;   aV  U
S:w  a  [        S5      e[-        UR                  SS5      R                  SS5      5      n
[/        U
5      S:w  a  [        S5      eU
S:w  a  U
OS U l        S U l        UR                  SS 5      nUb  Xl        S U l        UR                  SS 5      nUb  Xl        SU l        UR                  SS 5      nUbA  [        U[8        [:        45      (       d   [        S[        [        U5      5      -   5      eXl        S U l        UR                  SS 5      nUbA  [        U[8        [:        45      (       d   [        S[        [        U5      5      -   5      eXl        SU l        UR                  SS 5      nUbA  [        U[8        [:        45      (       d   [        S [        [        U5      5      -   5      eXl        SU l         UR                  S!S 5      nUbB  [        U[8        [:        45      (       d   [        S"[        [        U5      5      -   5      eUU l         S#U l!        UR                  S$S 5      nUbB  [        U[8        [:        45      (       d   [        S%[        [        U5      5      -   5      eUU l!        S U l"        S nS nUR                  S&S 5      U l#        U RF                  Gb  S U l        U RF                  S';   a  S(S)/nU Vs/ s H  nUU;  d  M  UPM     nnU(       a)  [        S*R                  S+RI                  U5      5      5      eUR                  S(5      n[        U[        5      (       d   [        S,[        [        U5      5      -   5      eUR                  S)5      n[        U[        5      (       d   [        S-[        [        U5      5      -   5      eU RF                  S.:X  Ga*  / S/QnU Vs/ s H  nUU;  d  M  UPM     nnU(       a)  [        S0R                  S+RI                  U5      5      5      eUR                  S15      U l%        [        U RJ                  [        5      (       d*  [        S2[        [        U RJ                  5      5      -   5      eUR                  S35      U l&        [        U RL                  [        5      (       d*  [        S4[        [        U RL                  5      5      -   5      eUR                  S55      U l'        [        U RN                  [        5      (       d*  [        S6[        [        U RN                  5      5      -   5      eUR                  S75      U l(        [        U RP                  [        5      (       d*  [        S8[        [        U RP                  5      5      -   5      e[S        U RJ                  U RL                  U RN                  U RP                  UUU R>                  U R@                  U RB                  5	      U l"        GO}U RF                  S9:X  ak  S:U;  a  [        S;5      eUR                  S:5      n[U        UUU5      U l"        [        U[        5      (       d   [        S<[        [        U5      5      -   5      eGOU RF                  S=:X  a  S>S?/nU Vs/ s H  nUU;  d  M  UPM     nnU(       a)  [        S@R                  S+RI                  U5      5      5      eUR                  S>5      n[W        U5      (       d   [        SA[        [        U5      5      -   5      eUR                  S?5      n[        U[X        5      (       d   [        SB[        [        U5      5      -   5      e[[        UU5      U l"        O[        SC5      e[/        U5      S:  a7  [        SDR                  S+RI                  UR]                  5       5      5      5      eg ! [*        [
        4 a    Sn
 GNf = fs  snf s  snf s  snf )ENry   z+Missing required configuration property urlzurl must be a str, not ,/httpmockzInvalid url {}Tzssl.ca.locationzssl.key.locationzssl.certificate.locationzCssl.certificate.location required when configuring ssl.key.locationr   )r   r   zbasic.auth.user.infozbasic.auth.user.info configured with userinfo credentials in the URL. Remove userinfo credentials from the url or remove basic.auth.user.info from the configurationr   :r      zAbasic.auth.user.info must be in the form of {username}:{password}proxytimeoutr{   zcache.capacityz%cache.capacity must be a number, not zcache.latest.ttl.secz+cache.latest.ttl.sec must be a number, not    zmax.retriesz"max.retries must be a number, not zretries.wait.msz&retries.wait.ms must be a number, not i N  zretries.max.wait.msz*retries.max.wait.ms must be a number, not zbearer.auth.credentials.source>   OAUTHBEARERSTATIC_TOKENrM   rN   z4Missing required bearer configuration properties: {}, z#logical cluster must be a str, not z$identity pool id must be a str, not r   )bearer.auth.client.idbearer.auth.client.secretbearer.auth.scopebearer.auth.issuer.endpoint.urlz3Missing required OAuth configuration properties: {}r   z)bearer.auth.client.id must be a str, not r   z-bearer.auth.client.secret must be a str, not r   z%bearer.auth.scope must be a str, not r   z3bearer.auth.issuer.endpoint.url must be a str, not r   rL   zMissing bearer.auth.tokenz%bearer.auth.token must be a str, not CUSTOMz$bearer.auth.custom.provider.functionz"bearer.auth.custom.provider.configz:Missing required custom OAuth configuration properties: {}z=bearer.auth.custom.provider.function must be a callable, not z7bearer.auth.custom.provider.config must be a dict, not z+Unrecognized bearer.auth.credentials.sourcezUnrecognized properties: {})/copypop
ValueError
isinstancestring_type	TypeErrorrP   typesplitstriprstrip
startswithformatappend	base_urlsverifycertr   r   usernamepasswordAttributeErrortuplelenauthr   r   cache_capacityr   floatcache_latest_ttl_secrb   rc   rd   bearer_field_providerbearer_auth_credentials_sourcejoinr^   r_   r`   ra   r\   rA   callabler=   rR   keys)r3   r   	conf_copybase_urlr   ry   cakeyclient_certparseduserinfor   r   r   r   rb   rc   rd   rD   rE   headersheadermissing_headersproperties_listpropmissing_propertiesstatic_tokencustom_bearer_propertiesmissing_custom_propertiesrT   rU   s                                  r$   rH   _BaseRestClient.__init__   s   IIK	==-JKK(K005DN8KKLL	>>#&C))+$$S)C>>&))#..2H2H !1!8!8!=>>S!	 '
 JKK"]],d3>K&]]+=tD%.]]3Mt%T7;	"s$*DI"s{#I?{2 = > > $..+,	 0'&//2JKH "Y.8#  "2 3 3 Y]]+A2FLLSRSTUH8}!  "= > > !)H 4H$	 
gt,J--	40"L""'7>%nsEl;; G#dSaNbJc cdd"0$(!(}}-CTJ+2S%LAA MPSTXYmTnPo opp(<%mmM48"kC<88 Ds4P[K\G] ]^^*##--(94@&oU|<< H"%d?&;"<!= > >#2D #( 'mm,A4H*1C<@@ L"%d+>&?"@!A B B':D$%)".7mm<\^b.c+..:DI226UU8:XY8?"[f6QZCZ6"["$%[&,fTYY-G&HJ J #,--0M"N!/377#$ICPTUdPeLf$fgg ).L M!-55#$JSQUVcQdMe$eff22mC#F7F%`t$V_J_d"%`%$%Z%+VDII6H,I%JL L "+/F!G!$..+>>#$ORUVZ[_[i[iVjRk$kll%.]]3N%O"!$"4"4kBB#$SVYZ^_c_q_qZrVs$stt&]]+>?
!$**k::#$KcRVW[WaWaRbNc$cdd&/mm4U&V#!$"5"5{CC#$Y&)$t/B/B*C&D%E F F .:$..$J\J\^b^h^h:>:M:M`m:>:J:JDL`L`:>:R:R.T* 44F&i7$%@AA(}}-@A-A,P_an-o*!,<<#$KcRVWcRdNe$eff =44@,R,P,R(>V,p>VdZ^foZoT>V),p,$%a%+VDII6O,P%QS S #,--0V"W00#$c&)$*?&@%A B B !*.R S!-66#$]&)$}*=&>%? @ @ .@Q^-_* !NOO y>A:$fTYYy~~/?%@AC C i 	* 	 H	 X #\  &aH -qs6   *e+ 
f(f
f	f	:
ff+f fNry   queryr   c                     [        5       er/   r0   r3   ry   r   s      r$   get_BaseRestClient.getF      !##r&   bodyc                     [        5       er/   r0   r3   ry   r   kwargss       r$   post_BaseRestClient.postI  r   r&   c                     [        5       er/   r0   r3   ry   s     r$   delete_BaseRestClient.deleteL  r   r&   c                     [        5       er/   r0   r3   ry   r   s      r$   put_BaseRestClient.putO  r   r&   )r   r   r   r   r   r   r   r^   r_   rb   r   rd   rc   r`   r   ra   r   r/   )r7   r8   r9   r:   r=   rH   rP   r   r   r   r   r   r   r>   r6   r&   r$   r   r      s    CT CB$s $8D> $S $$ $8D> $ $$# $# $$s $(4. $C $ $r&   r   c                   $  ^  \ rS rSrSrS\4U 4S jjrS\SS4S jrSS	\S
\	\   S\
4S jjrS	\S\	\   S\
4S jrS	\S\
4S jrSS	\S\	\   S\
4S jjr  SS	\S\S\	\   S
\	\   S\
4
S jjr SS\S	\S\S\	\   S\	\   S
\	\   S\4S jjrSrU =r$ )_RestClientiS  z
HTTP client for Confluent Schema Registry.

See SchemaRegistryClient for configuration details.

Args:
    conf (dict): Dictionary containing _RestClient configuration
r   c                    > [         TU ]  U5        [        R                  " U R                  U R
                  U R                  U R                  U R                  S9U l	        g )N)r   r   r   r   r   )
superrH   httpxClientr   r   r   r   r   session)r3   r   	__class__s     r$   rH   _RestClient.__init__]  sC    ||;;**LL
r&   r   r   Nc                 4   U R                   R                  5       n/ SQn/ nU H  nXR;  d  M
  UR                  U5        M     U(       a)  [        SR	                  SR                  U5      5      5      eSR	                  US   5      US'   US   US'   US	   US
'   g )N)rL   rN   rM   zUMissing required bearer auth fields, needs to be set in config or custom function: {}r   z	Bearer {}rL   AuthorizationrN   zConfluent-Identity-Pool-IdrM   ztarget-sr-cluster)r   r4   r   r   r   r   )r3   r   bearer_fieldsrequired_fieldsmissing_fieldsr   s         r$   handle_bearer_auth_RestClient.handle_bearer_authh  s    22DDFn$E)%%e, % t$fTYY~%>?A A $/#5#5mDW6X#Y 0=>\0],-'45R'S#$r&   ry   r   c                 $    U R                  USUS9$ )NGET)methodr   send_requestr   s      r$   r   _RestClient.gety  s      U% @@r&   r   c                 $    U R                  USUS9$ )NPOSTr   r   r   r   s       r$   r   _RestClient.post|  s      V$ ??r&   c                 "    U R                  USS9$ )NDELETE)r   r   r   s     r$   r   _RestClient.delete  s      X 66r&   c                 $    U R                  USUS9$ )NPUTr   r   r   s      r$   r   _RestClient.put  s      U >>r&   r   c           	      |   SS0nUb-  [         R                  " U5      n[        [        U5      5      SS.nU R                  (       a  U R                  U5        Sn[        U R                  5       H}  u  px U R                  XX%X45      n[        UR                  5      (       a  UR                  5       s  $ [        UR                  5      (       a  U[        U R                  5      S-
  :X  a    OM      [        UR                  UR                  5       R                  S5      UR                  5       R                  S5      5      e! [         a*  n	U[        U R                  5      S-
  :X  a  U	e Sn	A	GM  Sn	A	ff = f! [        [         ["        4 a.    [        UR                  S	S
[        UR$                  5      -   5      ef = f)a
  
Sends HTTP request to the SchemaRegistry, trying each base URL in turn.

All unsuccessful attempts will raise a SchemaRegistryError with the
response contents. In most cases this will be accompanied by a
Schema Registry supplied error code.

In the event the response is malformed an error_code of -1 will be used.

Args:
    url (str): Request path

    method (str): HTTP method

    body (str): Request content

    query (dict): Query params to attach to the URL

Returns:
    dict: Schema Registry response content.
Acceptz]application/vnd.schemaregistry.v1+json, application/vnd.schemaregistry+json, application/jsonNz&application/vnd.schemaregistry.v1+json)zContent-LengthzContent-Typer   
error_codemessagezUnknown Schema Registry Error: )jsondumpsrP   r   r   r   	enumerater   send_http_request
is_successstatus_codeis_retriabler~   r   r   r   KeyErrorr   content)
r3   ry   r   r   r   r   responser   r   r   s
             r$   r   _RestClient.send_request  s   4  1 2 ::d#D),SY'OQG ..##G,$T^^4KA116DA h2233#==?*#H$8$899Q#dnnBUXYBY=Y >Z 5		?%h&:&:&.mmo&9&9,&G&.mmo&9&9)&DF F  DNN+a//G 0 Hn5 	?%h&:&:&(&G(+H,<,<(='>? ?	?s,   4<E36E0AE8 
E5E00E58AF;r   c           	         Sn[        U R                  S-   5       H  nU R                  R                  USR	                  X/5      XEUS9n[        UR                  5      (       a  Us  $ [        UR                  5      (       a  XR                  :  a  Us  $ [        R                  " [        U R                  U R                  U5      S-  5        M     U$ )a;  
Sends HTTP request to the SchemaRegistry.

All unsuccessful attempts will raise a SchemaRegistryError with the
response contents. In most cases this will be accompanied by a
Schema Registry supplied error code.

In the event the response is malformed an error_code of -1 will be used.

Args:
    base_url (str): Schema Registry base URL

    url (str): Request path

    method (str): HTTP method

    headers (dict): Headers

    body (str): Request content

    query (dict): Query params to attach to the URL

Returns:
    Response: Schema Registry response content.
Nr   r   )ry   r   r  paramsr{   )r|   rb   r   requestr   r  r	  r
  ro   r   r   rc   rd   )	r3   r   ry   r   r   r   r   r  r   s	            r$   r  _RestClient.send_http_request  s    : t''!+,A||++CHHh_5e , =H (..// 4 455>N>N9NJJ{4#7#79Q9QSTUX\\] - r&   )r   r/   NN)r7   r8   r9   r:   __doc__r=   rH   r   rP   r   r   r   r   r   r   r   r   r  r>   __classcell__)r   s   @r$   r   r   S  s6   	
T 	
T$ T4 T"As A8D> AS A@ @8D> @ @7# 7# 7?s ?(4. ?C ? =A $???? #??+3D>??~?? 
??F =A**"%*/2*=Ed^*sm*+3D>* 
* *r&   r   r	  c                 ,    SU s=:*  =(       a    S:*  $ s  $ )N   i+  r6   r	  s    r$   r  r    s    +$$$$$$r&   c                     U S;   $ )N)i  i  i  i  i  i  r6   r  s    r$   r
  r
    s    888r&   base_delay_msmax_delay_msretries_attemptedc                 T    U SU-  -  n[         R                   " 5       [        X15      -  $ )Ng       @)randommin)r  r  r  no_jitter_delays       r$   r   r     s(    #s.?'?@O==?S???r&   c                       \ rS rSrSrS rS\S\SS4S jrSS
 jr	S\S\S\
S   4S jrS\SSS\
\   4S jrS\SSS\
S	   4S jrS\S\S\
S	   4S jrS\S\S\
S	   4S jrS\4S jrS\S\4S jrS rSrg)_SchemaCachei   z
Thread-safe cache for use with the Schema Registry Client.

This cache may be used to retrieve schema ids, schemas or to check
known subject membership.
c                     [        5       U l        [        [        5      U l        [        [        5      U l        [        [        5      U l        [        [        5      U l        [        [        5      U l        g r/   )	r	   lockr   r=   schema_id_indexschema_indexrs_id_indexrs_version_indexrs_schema_indexr2   s    r$   rH   _SchemaCache.__init__  sL    F	*40'-&t, +D 1*40r&   subject	schema_idschemaSchemac                     U R                      X0R                  U   U'   X R                  U   U'   SSS5        g! , (       d  f       g= f)z
Add a Schema identified by schema_id to the cache.

Args:
    subject (str): The subject this schema is associated with

    schema_id (int): Schema's registration id

    schema (Schema): Schema instance
N)r$  r%  r&  )r3   r+  r,  r-  s       r$   
set_schema_SchemaCache.set_schema  s;     YY7=  ))41:g&v. YYs	   #9
ARegisteredSchemac                 B   UR                   nUR                  nUR                  nU R                     XR                  U   U'   X@R
                  U   U'   X R                  U   U'   X R                  U   U'   X R                  U   U'   SSS5        g! , (       d  f       g= f)zq
Add a RegisteredSchema to the cache.

Args:
    registered_schema (RegisteredSchema): RegisteredSchema instance
N)	r+  r,  versionr$  r%  r&  r'  r(  r)  )r3   r-  registered_schemar+  r,  r4  s         r$   set_registered_schema"_SchemaCache.set_registered_schema   s     $++%//	#++YY7=  ))41:g&v.3DW%i06G!!'*734E  )&1 YYs   AB
Br   c                     U R                      U R                  R                  U0 5      R                  US5      sSSS5        $ ! , (       d  f       g= f)z
Get the schema instance associated with schema id from the cache.

Args:
    subject (str): The subject this schema is associated with

    schema_id (int): Id used to identify a schema

Returns:
    Schema: The schema if known; else None
N)r$  r%  r   r3   r+  r,  s      r$   get_schema_by_id_SchemaCache.get_schema_by_id2  s8     YY''++GR8<<YM YY   ,A
Ac                     U R                      U R                  R                  U0 5      R                  US5      sSSS5        $ ! , (       d  f       g= f)z
Get the schema id associated with schema instance from the cache.

Args:
    subject (str): The subject this schema is associated with

    schema (Schema): The schema

Returns:
    int: The schema id if known; else None
N)r$  r&  r   r3   r+  r-  s      r$   get_id_by_schema_SchemaCache.get_id_by_schemaB  s8     YY$$(("599&$G YYr<  c                     U R                      U R                  R                  U0 5      R                  US5      sSSS5        $ ! , (       d  f       g= f)a  
Get the schema associated with this schema registered under subject.

Args:
    subject (str): The subject this schema is associated with

    schema (Schema): The schema associated with this schema

Returns:
    RegisteredSchema: The registered schema if known; else None
N)r$  r)  r   r>  s      r$    get_registered_by_subject_schema-_SchemaCache.get_registered_by_subject_schemaR  s8     YY''++GR8<<VTJ YYr<  c                     U R                      U R                  R                  U0 5      R                  US5      sSSS5        $ ! , (       d  f       g= f)a  
Get the schema associated with this id registered under subject.

Args:
    subject (str): The subject this schema is associated with

    schema_id (int): The schema id associated with this schema

Returns:
    RegisteredSchema: The registered schema if known; else None
N)r$  r'  r   r9  s      r$   get_registered_by_subject_id)_SchemaCache.get_registered_by_subject_idb  s8     YY##''488DI YYr<  r4  c                     U R                      U R                  R                  U0 5      R                  US5      sSSS5        $ ! , (       d  f       g= f)a  
Get the schema associated with this version registered under subject.

Args:
    subject (str): The subject this schema is associated with

    version (int): The version associated with this schema

Returns:
    RegisteredSchema: The registered schema if known; else None
N)r$  r(  r   )r3   r+  r4  s      r$   !get_registered_by_subject_version._SchemaCache.get_registered_by_subject_versionr  s8     YY((,,Wb9==gtL YYr<  c                 h   U R                      XR                  ;   a  U R                  U	 XR                  ;   a  U R                  U	 XR                  ;   a  U R                  U	 XR                  ;   a  U R                  U	 XR
                  ;   a  U R
                  U	 SSS5        g! , (       d  f       g= f)zN
Remove schemas with the given subject.

Args:
    subject (str): The subject
N)r$  r%  r&  r'  r(  r)  )r3   r+  s     r$   remove_by_subject_SchemaCache.remove_by_subject  s     YY...((1+++%%g.***$$W-///))'2...((1 YYs   BB##
B1c                 6   U R                      XR                  ;   aH  U R                  U   R                  5        H'  u  p4UR                  U:X  d  M  U R                  U   U	 M)     XR                  ;   aH  U R                  U   R                  5        H'  u  pTUR                  U:X  d  M  U R                  U   U	 M)     SnXR
                  ;   a4  X R
                  U   ;   a"  U R
                  U   U   nU R
                  U   U	 Ub}  XR                  ;   an  UR                  U R                  U   ;   a  U R                  U   UR                  	 UR                  U R                  U   ;   a  U R                  U   UR                  	 SSS5        g! , (       d  f       g= f)zm
Remove schemas with the given subject.

Args:
    subject (str): The subject

    version (int) The version
N)
r$  r'  itemsr4  r)  r(  r%  r,  r-  r&  )r3   r+  r4  r,  r5  r-  rss          r$   remove_by_subject_version&_SchemaCache.remove_by_subject_version  sn    YY***484D4DW4M4S4S4U0I(00G; 009)D 5V ...151E1Eg1N1T1T1V-F(00G; 009&A 2W B///33G<<..w7@B--g6w?~222||t';';G'DD 009",,GyyD$5$5g$>> --g6ryyA' YYs   A F
AF
(CF


Fc                 T   U R                      U R                  R                  5         U R                  R                  5         U R                  R                  5         U R
                  R                  5         U R                  R                  5         SSS5        g! , (       d  f       g= f)z
Clear the cache.
N)r$  r%  clearr&  r'  r(  r)  r2   s    r$   rS  _SchemaCache.clear  so    
 YY  &&(##%""$!!'')  &&( YYs   BB
B')r$  r'  r)  r(  r%  r&  N)r-  r.  r5  r2  )r7   r8   r9   r:   r  rH   rP   r   r0  r6  r   r:  r?  rB  rE  rH  rK  rP  rS  r>   r6   r&   r$   r"  r"     s   1;# ;# ;x ; F$N N N@R N H HX H(3- H K KX KRZ[mRn K JC JC JHUgLh J M Ms MxXjOk M 2 2(B Bs B>
)r&   r"  c                      \ rS rSrSrS\4S jrS rS rS r	 S,S\
S	S
S\S\4S jjr S,S\
S	S
S\SS4S jjr S-S\S\\
   S\\
   SS
4S jjr S.S\
S	S
S\S\SS4
S jjrS\\
   4S jrS,S\
S\S\\   4S jjr S/S\
S\\
   SS4S jjr S0S\
S\\
\
4   S\S\\
   SS4
S jjr S0S\
S\S\S\\
   SS4
S jjrS\
S\\   4S jrS,S\
S\S\S\4S jjrS-S\\
   S \\
   S\
4S! jjrS/S\\
   S\
4S" jjr S1S\
S	S
S\\\
4   S\4S# jjr  S-S\\
   S$\S%   SS%4S& jjrS/S\\
   SS%4S' jjr S( r!S) r"\#S\SS 4S* j5       r$S+r%g)2SchemaRegistryClienti  ac  
A Confluent Schema Registry client.

Configuration properties (* indicates a required field):

+------------------------------+------+-------------------------------------------------+
| Property name                | type | Description                                     |
+==============================+======+=================================================+
| ``url`` *                    | str  | Comma-separated list of Schema Registry URLs.   |
+------------------------------+------+-------------------------------------------------+
|                              |      | Path to CA certificate file used                |
| ``ssl.ca.location``          | str  | to verify the Schema Registry's                 |
|                              |      | private key.                                    |
+------------------------------+------+-------------------------------------------------+
|                              |      | Path to client's private key                    |
|                              |      | (PEM) used for authentication.                  |
| ``ssl.key.location``         | str  |                                                 |
|                              |      | ``ssl.certificate.location`` must also be set.  |
+------------------------------+------+-------------------------------------------------+
|                              |      | Path to client's public key (PEM) used for      |
|                              |      | authentication.                                 |
| ``ssl.certificate.location`` | str  |                                                 |
|                              |      | May be set without ssl.key.location if the      |
|                              |      | private key is stored within the PEM as well.   |
+------------------------------+------+-------------------------------------------------+
|                              |      | Client HTTP credentials in the form of          |
|                              |      | ``username:password``.                          |
| ``basic.auth.user.info``     | str  |                                                 |
|                              |      | By default userinfo is extracted from           |
|                              |      | the URL if present.                             |
+------------------------------+------+-------------------------------------------------+
|                              |      |                                                 |
| ``proxy``                    | str  | Proxy such as http://localhost:8030.            |
|                              |      |                                                 |
+------------------------------+------+-------------------------------------------------+
|                              |      |                                                 |
| ``timeout``                  | int  | Request timeout.                                |
|                              |      |                                                 |
+------------------------------+------+-------------------------------------------------+
|                              |      |                                                 |
| ``cache.capacity``           | int  | Cache capacity.  Defaults to 1000.              |
|                              |      |                                                 |
+------------------------------+------+-------------------------------------------------+
|                              |      |                                                 |
| ``cache.latest.ttl.sec``     | int  | TTL in seconds for caching the latest schema.   |
|                              |      |                                                 |
+------------------------------+------+-------------------------------------------------+
|                              |      |                                                 |
| ``max.retries``              | int  | Maximum retries for a request.  Defaults to 2.  |
|                              |      |                                                 |
+------------------------------+------+-------------------------------------------------+
|                              |      | Maximum time to wait for the first retry.       |
|                              |      | When jitter is applied, the actual wait may     |
| ``retries.wait.ms``          | int  | be less.                                        |
|                              |      |                                                 |
|                              |      | Defaults to 1000.                               |
+------------------------------+------+-------------------------------------------------+

Args:
    conf (dict): Schema Registry client configuration.

See Also:
    `Confluent Schema Registry documentation <http://confluent.io/docs/current/schema-registry/docs/intro.html>`_
r   c                 .   Xl         [        U5      U l        [        5       U l        U R                  R
                  nU R                  R                  nUb!  [        X#5      U l        [        X#5      U l	        g [        U5      U l        [        U5      U l	        g r/   )_confr   _rest_clientr"  _cacher   r   r   _latest_version_cache_latest_with_metadata_cacher   )r3   r   r   	cache_ttls       r$   rH   SchemaRegistryClient.__init__  sy    
'-"n**99%%::	 )1.)LD&/7/RD,)1.)AD&/7/GD,r&   c                     U $ r/   r6   r2   s    r$   	__enter__SchemaRegistryClient.__enter__  s    r&   c                 h    U R                   b%  U R                   R                  R                  5         g g r/   )rY  r   close)r3   argss     r$   __exit__SchemaRegistryClient.__exit__  s+    (%%++- )r&   c                     U R                   $ r/   )rX  r2   s    r$   configSchemaRegistryClient.config  s    zzr&   subject_namer-  r.  normalize_schemasr   c                 >    U R                  XU5      nUR                  $ )  
Registers a schema under ``subject_name``.

Args:
    subject_name (str): subject to register a schema under
    schema (Schema): Schema instance to register
    normalize_schemas (bool): Normalize schema before registering

Returns:
    int: Schema id

Raises:
    SchemaRegistryError: if Schema violates this subject's
        Compatibility policy or is otherwise invalid.

See Also:
    `POST Subject API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#post--subjects-(string-%20subject)-versions>`_
)register_schema_full_responser,  )r3   rj  r-  rk  r5  s        r$   register_schema$SchemaRegistryClient.register_schema  s$    . !>>|Ufg ***r&   r2  c                 X   U R                   R                  X5      nUb  [        XBUS5      $ UR                  5       nU R                  R                  SR                  [        U5      U5      US9n[        R                  U5      nU R                   R                  XR                  U5        U$ )rm  Nz!subjects/{}/versions?normalize={}r   )rZ  r?  r2  to_dictrY  r   r   r%   	from_dictr0  r,  )r3   rj  r-  rk  r,  r  r  r5  s           r$   rn  2SchemaRegistryClient.register_schema_full_response5  s    . KK00F	 #I|TJJ.."$$))/66z,7OQbc *  -66x@ 	|-H-H&Q  r&   Nr,  fmtc                 .   U R                   R                  X!5      nUb  U$ Ub  SU0OSnUb  Ub  X5S'   OSU0nU R                  R                  SR	                  U5      U5      n[
        R                  U5      nU R                   R                  X!U5        U$ )aR  
Fetches the schema associated with ``schema_id`` from the
Schema Registry. The result is cached so subsequent attempts will not
require an additional round-trip to the Schema Registry.

Args:
    schema_id (int): Schema id
    subject_name (str): Subject name the schema is registered under
    fmt (str): Format of the schema

Returns:
    Schema: Schema instance identified by the ``schema_id``

Raises:
    SchemaRegistryError: If schema can't be found.

See Also:
 `GET Schema API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--schemas-ids-int-%20id>`_
Nr+  r   zschemas/ids/{})rZ  r:  rY  r   r   r.  rt  r0  )r3   r,  rj  rv  r-  r   r  s          r$   
get_schemaSchemaRegistryClient.get_schema]  s    . --lFM-9-EL)4? "%h!3$$(()9)@)@)KUS!!(+|?r&   deletedc                    U R                   R                  X5      nUb  U$ UR                  5       nU R                  R	                  SR                  [        U5      X45      US9n[        R                  U5      n[        UR                  UR                  UR                  US9nU R                   R                  X%5        U$ )a_  
Returns ``schema`` registration information for ``subject``.

Args:
    subject_name (str): Subject name the schema is registered under
    schema (Schema): Schema instance.
    normalize_schemas (bool): Normalize schema before registering
    deleted (bool): Whether to include deleted schemas.

Returns:
    RegisteredSchema: Subject registration information for this schema.

Raises:
    SchemaRegistryError: If schema or subject can't be found

See Also:
    `POST Subject API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#post--subjects-(string-%20subject)-versions>`_
z#subjects/{}?normalize={}&deleted={}rr  )r,  r+  r4  r-  )rZ  rB  rs  rY  r   r   r%   r2  rt  r,  r+  r4  r6  )	r3   rj  r-  rk  rz  r5  r  r  results	            r$   lookup_schema"SchemaRegistryClient.lookup_schema  s    . !KKHH^($$.."$$))*O+16*\2JL]+g/6 * 8 "++H5 -&&NNNN	
 	))&D  r&   c                 8    U R                   R                  S5      $ )aC  
List all subjects registered with the Schema Registry

Returns:
    list(str): Registered subject names

Raises:
    SchemaRegistryError: if subjects can't be found

See Also:
    `GET subjects API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--subjects-(string-%20subject)-versions>`_
subjects)rY  r   r2   s    r$   get_subjects!SchemaRegistryClient.get_subjects  s       $$Z00r&   	permanentc                    U(       aP  U R                   R                  SR                  [        U5      5      5      nU R                  R                  U5        U$ U R                   R                  SR                  [        U5      5      5      nU$ )aS  
Deletes the specified subject and its associated compatibility level if
registered. It is recommended to use this API only when a topic needs
to be recycled or in development environments.

Args:
    subject_name (str): subject name
    permanent (bool): True for a hard delete, False (default) for a soft delete

Returns:
    list(int): Versions deleted under this subject

Raises:
    SchemaRegistryError: if the request was unsuccessful.

See Also:
    `DELETE Subject API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#delete--subjects-(string-%20subject)>`_
zsubjects/{}?permanent=truezsubjects/{})rY  r   r   r%   rZ  rK  )r3   rj  r  versionss       r$   delete_subject#SchemaRegistryClient.delete_subject  sz    ( ((//0L17
<8P1QSHKK)),7
  ((//17
<8P1QSH r&   c                 
   U R                   R                  US5      nUb  U$ Ub  SU0OSnU R                  R                  SR                  [	        U5      S5      U5      n[
        R                  U5      nX0R                   U'   U$ )a  
Retrieves latest registered version for subject

Args:
    subject_name (str): Subject name.
    fmt (str): Format of the schema

Returns:
    RegisteredSchema: Registration information for this version.

Raises:
    SchemaRegistryError: if the version can't be found or is invalid.

See Also:
    `GET Subject Version API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--subjects-(string-%20subject)-versions-(versionId-%20version)>`_
Nr   subjects/{}/versions/{}latest)r[  r   rY  r   r%   r2  rt  )r3   rj  rv  r5  r   r  s         r$   get_latest_version'SchemaRegistryClient.get_latest_version  s    ( !66::<N($$#&?3$$(()B*0&L1I19+;<AC -66x@3D""<0  r&   metadatac                    U[        UR                  5       5      U4nU R                  R                  US5      nUb  U$ Ub  X4S.OSU0nUR	                  5       nU(       a@  U V	s/ s H  n	[        U	5      PM     sn	US'   U V	s/ s H  n	[        X)   5      PM     sn	US'   U R                  R                  SR                  [        U5      5      U5      n
[        R                  U
5      nX`R                  U'   U$ s  sn	f s  sn	f )a  
Retrieves latest registered version for subject with the given metadata

Args:
    subject_name (str): Subject name.
    metadata (dict): The key-value pairs for the metadata.
    deleted (bool): Whether to include deleted schemas.
    fmt (str): Format of the schema

Returns:
    RegisteredSchema: Registration information for this version.

Raises:
    SchemaRegistryError: if the version can't be found or is invalid.
Nrz  r   rz  r   r   zsubjects/{}/metadata)
	frozensetrN  r\  r   r   r%   rY  r   r2  rt  )r3   rj  r  rz  rv  	cache_keyr5  r   r   r   r  s              r$   get_latest_with_metadata-SchemaRegistryClient.get_latest_with_metadata  s    ( "9X^^-=#>H	 <<@@DQ($$7:G3YX_L`}}7;<tJsOt<E%LCGH4Cj74HE'N$$(()?*0&L1I*JES -66x@6G((3   =Hs   $C9C>r4  c                 <   U R                   R                  X5      nUb  U$ Ub  X4S.OSU0nU R                  R                  SR	                  [        U5      U5      U5      n[        R                  U5      nU R                   R                  UR                  U5        U$ )a]  
Retrieves a specific schema registered under ``subject_name``.

Args:
    subject_name (str): Subject name.
    version (int): version number. Defaults to latest version.
    deleted (bool): Whether to include deleted schemas.
    fmt (str): Format of the schema

Returns:
    RegisteredSchema: Registration information for this version.

Raises:
    SchemaRegistryError: if the version can't be found or is invalid.

See Also:
    `GET Subject Version API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--subjects-(string-%20subject)-versions-(versionId-%20version)>`_
r  rz  r  )
rZ  rH  rY  r   r   r%   r2  rt  r6  r-  )r3   rj  r4  rz  rv  r5  r   r  s           r$   get_version SchemaRegistryClient.get_version.  s    . !KKII,`($$7:G3YX_L`$$(()B*0&L1I18+:;@B -66x@))*;*B*BDUV  r&   c                 h    U R                   R                  SR                  [        U5      5      5      $ )av  
Get a list of all versions registered with this subject.

Args:
    subject_name (str): Subject name.

Returns:
    list(int): Registered versions

Raises:
    SchemaRegistryError: If subject can't be found

See Also:
    `GET Subject Versions API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#post--subjects-(string-%20subject)-versions>`_
zsubjects/{}/versions)rY  r   r   r%   )r3   rj  s     r$   get_versions!SchemaRegistryClient.get_versionsT  s,    "   $$%;%B%B:lC[%\]]r&   c                    U(       aQ  U R                   R                  SR                  [        U5      U5      5      nU R                  R                  X5        U$ U R                   R                  SR                  [        U5      U5      5      nU$ )a  
Deletes a specific version registered to ``subject_name``.

Args:
    subject_name (str) Subject name

    version (int): Version number

    permanent (bool): True for a hard delete, False (default) for a soft delete

Returns:
    int: Version number which was deleted

Raises:
    SchemaRegistryError: if the subject or version cannot be found.

See Also:
    `Delete Subject Version API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#delete--subjects-(string-%20subject)-versions-(versionId-%20version)>`_
z&subjects/{}/versions/{}?permanent=truer  )rY  r   r   r%   rZ  rP  )r3   rj  r4  r  r  s        r$   delete_version#SchemaRegistryClient.delete_versiong  s    * ((//0X17
<8P8?2ABH KK11,H 	 ((//0I17
<8P8?2ABH r&   levelc                     Uc  [        S5      eUc*  U R                  R                  SSUR                  5       0S9$ U R                  R                  SR	                  [        U5      5      SUR                  5       0S9$ )a.  
Update global or subject level compatibility level.

Args:
    level (str): Compatibility level. See API reference for a list of
        valid values.

    subject_name (str, optional): Subject to update. Sets global compatibility
        level policy if not set.

Returns:
    str: The newly configured compatibility level.

Raises:
    SchemaRegistryError: If the compatibility level is invalid.

See Also:
    `PUT Subject Compatibility API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#put--config-(string-%20subject)>`_
zlevel must be setrh  compatibilityrr  	config/{})r   rY  r   upperr   r%   )r3   rj  r  s      r$   set_compatibility&SchemaRegistryClient.set_compatibility  s    * =011$$((/>.N ) P P   $$[&,fZ-E&F+:EKKM*J % L 	Lr&   c                     Ub  SR                  [        U5      5      nOSnU R                  R                  U5      nUS   $ )a  
Get the current compatibility level.

Args:
    subject_name (str, optional): Subject name. Returns global policy
        if left unset.

Returns:
    str: Compatibility level for the subject if set, otherwise the global compatibility level.

Raises:
    SchemaRegistryError: if the request was unsuccessful.

See Also:
    `GET Subject Compatibility API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--config-(string-%20subject)>`_
r  rh  compatibilityLevel)r   r%   rY  r   r3   rj  ry   r|  s       r$   get_compatibility&SchemaRegistryClient.get_compatibility  sF    $ #$$Z%=>CC""&&s+*++r&   c                     UR                  5       nU R                  R                  SR                  [	        U5      U5      US9nUS   $ )a  Test the compatibility of a candidate schema for a given subject and version

Args:
    subject_name (str): Subject name the schema is registered under
    schema (Schema): Schema instance.
    version (int or str, optional): Version number, or the string "latest". Defaults to "latest".

Returns:
    bool: True if the schema is compatible with the specified version

Raises:
    SchemaRegistryError: if the request was unsuccessful.

See Also:
    `POST Test Compatibility API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#post--compatibility-subjects-(string-%20subject)-versions-(versionId-%20version)>`_
z%compatibility/subjects/{}/versions/{}rr  is_compatible)rs  rY  r   r   r%   )r3   rj  r-  r4  r  r  s         r$   test_compatibility'SchemaRegistryClient.test_compatibility  sQ    * .."$$))3:::l;SU\]dk * 
 ((r&   rh  ServerConfigc                     Uc  [        S5      eUc(  U R                  R                  SUR                  5       S9$ U R                  R                  SR	                  [        U5      5      UR                  5       S9$ )a  
Update global or subject config.

Args:
    config (ServerConfig): Config. See API reference for a list of
        valid values.

    subject_name (str, optional): Subject to update. Sets global config
        if not set.

Returns:
    str: The newly configured config.

Raises:
    SchemaRegistryError: If the config is invalid.

See Also:
    `PUT Subject Config API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#put--config-(string-%20subject)>`_
zconfig must be setrh  rr  r  )r   rY  r   rs  r   r%   )r3   rj  rh  s      r$   
set_configSchemaRegistryClient.set_config  s    0 >122$$((.4nn.> ) @ @   $$[&,fZ-E&F*0..*: % < 	<r&   c                     Ub  SR                  [        U5      5      nOSnU R                  R                  U5      n[        R                  U5      $ )a  
Get the current config.

Args:
    subject_name (str, optional): Subject name. Returns global config
        if left unset.

Returns:
    ServerConfig: Config for the subject if set, otherwise the global config.

Raises:
    SchemaRegistryError: if the request was unsuccessful.

See Also:
    `GET Subject Config API Reference <https://docs.confluent.io/current/schema-registry/develop/api.html#get--config-(string-%20subject)>`_
r  rh  )r   r%   rY  r   r  rt  r  s       r$   
get_configSchemaRegistryClient.get_config  sK    $ #$$Z%=>CC""&&s+%%f--r&   c                 l    U R                   R                  5         U R                  R                  5         g r/   )r[  rS  r\  r2   s    r$   clear_latest_caches(SchemaRegistryClient.clear_latest_caches  s&    ""((*((..0r&   c                     U R                   R                  5         U R                  R                  5         U R                  R                  5         g r/   )r[  rS  r\  rZ  r2   s    r$   clear_caches!SchemaRegistryClient.clear_caches   s6    ""((*((..0r&   c                     SSK Jn  U R                  S5      nUR                  S5      (       a  U" U 5      $ [	        U 5      $ )Nr   )MockSchemaRegistryClientry   zmock://)mock_schema_registry_clientr  r   r   rV  )r   r  ry   s      r$   
new_clientSchemaRegistryClient.new_client%  s7    Ihhuo>>)$$+D11#D))r&   )rZ  rX  r[  r\  rY  )Fr  )FFr/   )FN)r  )&r7   r8   r9   r:   r  r=   rH   r`  re  rh  rP   r   r   ro  rn  r   rx  r}  r
   r  r  r  r   r  r  r  r  r  r  r   r  r  r  r  r  staticmethodr  r>   r6   r&   r$   rV  rV    s   ?BHT H.
 #(++)1++ 
+8 #(&!&!)1&!&! 
&!R X\'',4SM'GOPS}'	'V :?-!-!)1-!-!26-! 
-!^1d3i 1 3 4 DQTI > 7;!!!!&.sm!!	!!J 59&!&!+/S>&!&!$,SM&! 
&!T 59$!$!*-$!$!$,SM$! 
$!L^ ^c ^&3   Z] BLhsm L8TW= Ldg L@,hsm ,s ,8 $,)))1)sCx) 
)< -1+/!<$SM!<(!< 
!<F.x} . .41
 * *"8 * *r&   rV  Tc                   *    \ rS rSrSrSrS\4S jrSrg)RuleKindi1  	CONDITION	TRANSFORMr   c                 ,    [        U R                  5      $ r/   rP   r   r2   s    r$   __str__RuleKind.__str__5      4::r&   r6   N)	r7   r8   r9   r:   r  r  rP   r  r>   r6   r&   r$   r  r  1  s    II r&   r  c                   :    \ rS rSrSrSrSrSrSrSr	S\
4S	 jrS
rg)RuleModei9  UPGRADE	DOWNGRADEUPDOWNREADWRITE	WRITEREADr   c                 ,    [        U R                  5      $ r/   r  r2   s    r$   r  RuleMode.__str__A  r  r&   r6   N)r7   r8   r9   r:   r  r  r  r  r  r  rP   r  r>   r6   r&   r$   r  r  9  s,    GIFDEI r&   r  c                       \ rS rSr% \" \SS9r\\\4   \	S'   S\\\
4   4S jr\S\\   S\\\
4   S\4S	 j5       rS
 rSrg)
RuleParamsiE  Ffactoryhashr  r   c                 @    0 nUR                  U R                  5        U$ r/   )updater  r3   
field_dicts     r$   rs  RuleParams.to_dictI  s    %'
$++&r&   clssrc_dictc                 2    UR                  5       nU " US9nU$ )N)r  r   )r  r  drule_paramss       r$   rt  RuleParams.from_dictO  s    MMOmr&   c                 Z    [        [        U R                  R                  5       5      5      $ r/   )r  r  r  rN  r2   s    r$   __hash__RuleParams.__hash__W  s    Idkk//1233r&   r6   N)r7   r8   r9   r:   _attrs_fieldr=   r  r   rP   __annotations__r   rs  classmethodr   r  rt  r  r>   r6   r&   r$   r  r  E  si    )$UCFDcNCc3h  tAw $sCx. Q  4r&   r  T)frozenc                       \ rS rSr% \\   \S'   \\   \S'   \\   \S'   \\   \S'   \\   \S'   \	" SS9r
\\\      \S	'   \\   \S
'   \\   \S'   \\   \S'   \\   \S'   \\   \S'   S\\\4   4S jr\S\\   S\\\4   S\4S j5       rSrg)Rulei[  namedockindmoder   Fr  tagsr  expr
on_success
on_failuredisabledr   c                 t   U R                   nU R                  nS nU R                  b  U R                  R                  nS nU R                  b  U R                  R                  nU R
                  nU R                  nS nU R                  b  U R                  R                  5       nU R                  nU R                  n	U R                  n
U R                  n0 nUR                  0 5        Ub  XS'   Ub  X,S'   Ub  X<S'   Ub  XLS'   [
        b  X\S'   Ub  XlS'   Ub  X|S'   Ub  XS'   U	b  XS	'   U
b  XS
'   Ub  XS'   U$ )Nr  r  r  r  r   r  r  r  	onSuccess	onFailurer  )r  r  r  r   r  r   r  r  rs  r  r  r  r  r  )r3   r  r  kind_strmode_str	rule_typer  _paramsr  r  r  r  r  s                r$   rs  Rule.to_dicti  sU   yyhh"&99 yyH"&99 yyHII	yy,0;;"kk))+Gyy__
__
==%'
"!%v? #u!)v!)v!*v!%v#*x !%v!&0{#!&0{#%-z"r&   r  r  c                 p   UR                  5       nUR                  SS 5      nUR                  SS 5      nUR                  SS 5      nS nUb  [        U5      nUR                  SS 5      nS nUb  [        U5      nUR                  SS 5      n	[	        [
        [           UR                  SS 5      5      n
UR                  SS 5      nS nUb  [        R                  U5      nUR                  SS 5      nUR                  S	S 5      nUR                  S
S 5      nUR                  SS 5      nU " UUUUU	U
UUUUUS9nU$ )Nr  r  r  r  r   r  r  r  r  r  r  )r  r  r  r  r   r  r  r  r  r  r  )	r   r   r  r  r   r
   rP   r  rt  )r  r  r  r  r  _kindr  _moder  r  r  r  r  r  r  r  r  rules                     r$   rt  Rule.from_dict  s=   MMOuuVT"eeE4 fd##'E?Dfd##'E?DEE&$'	DIquuVT23,-EE(D,A'+))'2FuuVT"UU;-
UU;-
55T*!!
 r&   r6   N)r7   r8   r9   r:   r   rP   r  r  r  r  r  r
   r  r   r   r   rs  r  r   r  rt  r>   r6   r&   r$   r  r  [  s    
3-	#
8

8

3- ,% 8D(49
8Z  
3-tn6c3h 6p /tAw /$sCx. /Q / /r&   r  c                       \ rS rSr% \" SS9r\\S      \S'   \" SS9r	\\S      \S'   S\
\\4   4S jr\S	\\   S
\
\\4   S\4S j5       rS rSrg)RuleSeti  Fr  r  migration_rulesdomain_rulesr   c                 \   S nU R                   b6  / nU R                    H$  nUR                  5       nUR                  U5        M&     S nU R                  b6  / nU R                   H$  nUR                  5       nUR                  U5        M&     0 nUR	                  0 5        Ub  XS'   Ub  XGS'   U$ )NmigrationRulesdomainRules)r  rs  r   r  r  )r3   _migration_rulesmigration_rules_item_datamigration_rules_item_domain_rulesdomain_rules_item_datadomain_rules_itemr  s           r$   rs  RuleSet.to_dict  s    ;?+!-1-A-A)'@'H'H'J$ ''(<= .B 9=(M*.*;*;&$:$B$B$D!$$%67 +< &(
"'+;'($(5}%r&   r  r  c                 d   UR                  5       n/ nUR                  SS 5      nU=(       d    /  H)  n[        R                  U5      nUR	                  U5        M+     / nUR                  SS 5      nU=(       d    /  H)  n	[        R                  U	5      n
UR	                  U
5        M+     U " UUS9nU$ )Nr
  r  )r  r  )r   r   r  rt  r   )r  r  r  r  r  r  r  r  r  r  r  rule_sets               r$   rt  RuleSet.from_dict  s    MMO55!148)9)?R)?%#'>>2K#L ""#78 *@ mT2&3&9r&9" $/E F 12 ': +%

 r&   c                 |    [        [        U R                  =(       d    / U R                  =(       d    / -   5      5      $ r/   )r  r  r  r  r2   s    r$   r  RuleSet.__hash__  s.    It339rd>O>O>USUVWXXr&   r6   N)r7   r8   r9   r:   r  r  r   r
   r  r  r   rP   r   rs  r  r   r  rt  r  r>   r6   r&   r$   r  r    s    .:.FOXd6l+F+7U+CL(4<(Cc3h 0 tAw $sCx. Q  *Yr&   r  c                       \ rS rSr% \" \SS9r\\\	\   4   \
S'   S\\\4   4S jr\S\\   S\\\4   S\4S	 j5       rS
 rSrg)MetadataTagsi  Fr  r  r   c                 X    0 nU R                   R                  5        H	  u  p#X1U'   M     U$ r/   )r  rN  )r3   r  	prop_namer   s       r$   rs  MetadataTags.to_dict  s.    %'
#yy0OI$(y!  1 r&   r  r  c                     UR                  5       n0 nUR                  5        H   u  pE[        [        [           U5      nXcU'   M"     U " US9nU$ )N)r  )r   rN  r   r
   rP   )r  r  r  r  r  	prop_dicttagmetadata_tagss           r$   rt  MetadataTags.from_dict  sM    MMO$%GGI ItCy),C!O %.
 r&   c                 Z    [        [        U R                  R                  5       5      5      $ r/   )r  r  r  rN  r2   s    r$   r  MetadataTags.__hash__$  s    Idiioo/011r&   r6   N)r7   r8   r9   r:   r  r=   r  r   rP   r
   r  r   rs  r  r   r  rt  r  r>   r6   r&   r$   r  r    sn    !-d!GD$sDI~
Gc3h  tAw $sCx. Q  2r&   r  c                       \ rS rSr% \" \SS9r\\\4   \	S'   S\\\
4   4S jr\S\\   S\\\
4   S\4S	 j5       rS
 rSrg)MetadataPropertiesi(  Fr  
propertiesr   c                 @    0 nUR                  U R                  5        U$ r/   )r  r&  r  s     r$   rs  MetadataProperties.to_dict,  s    %'
$//*r&   r  r  c                 2    UR                  5       nU " US9nU$ )N)r&  r  )r  r  r  metadata_propertiess       r$   rt  MetadataProperties.from_dict2  s    MMO!Q/""r&   c                 Z    [        [        U R                  R                  5       5      5      $ r/   )r  r  r&  rN  r2   s    r$   r  MetadataProperties.__hash__:  s    Idoo335677r&   r6   N)r7   r8   r9   r:   r  r=   r&  r   rP   r  r   rs  r  r   r  rt  r  r>   r6   r&   r$   r%  r%  (  si    !-d!GJS#XGc3h  #tAw #$sCx. #Q # #8r&   r%  c                       \ rS rSr% \\   \S'   \\   \S'   \" SS9r	\\
\      \S'   S\\\4   4S jr\S	\\   S
\\\4   S\4S j5       rSrg)Metadatai>  r  r&  Fr  	sensitiver   c                 B   S nU R                   b  U R                   R                  5       nS nU R                  b  U R                  R                  5       nS nU R                  b&  / nU R                   H  nUR	                  U5        M     0 nUb  XS'   Ub  X%S'   Ub  X5S'   U$ )Nr  r&  r0  )r  rs  r&  r0  r   )r3   _tags_propertiesr0  sensitive_itemr  s         r$   rs  Metadata.to_dictD  s    *.99 II%%'E04??&//113K)-	>>%I"&..  0 #1 &(
!&v"'2|$ &/{#r&   r  r  c                 T   UR                  5       nUR                  SS 5      nS nUb  [        R                  U5      nUR                  SS 5      nS nUb  [        R                  U5      n/ nUR                  SS 5      nU=(       d    /  H  n	UR                  U	5        M     U " UUUS9n
U
$ )Nr  r&  r0  )r  r&  r0  )r   r   r  rt  r%  r   )r  r  r  r2  r  r3  r&  r0  
_sensitiver4  r  s              r$   rt  Metadata.from_dict]  s    MMO*+%%*='+))%0D01lD0I37
"+55kBJ	UU;-
(.B.N^, / !
 r&   r6   N)r7   r8   r9   r:   r   r  r  r%  r  r0  r
   rP   r   r   rs  r  r   r  rt  r>   r6   r&   r$   r/  r/  >  sz    
<
  +,,%1u%=IxS	"=c3h 2 tAw $sCx. Q  r&   r/  c                       \ rS rSr% \\   \S'   \\   \S'   \\   \S'   S\\\	4   4S jr
\S\\   S\\\	4   S\4S	 j5       rS
rg)SchemaReferenceix  r  r+  r4  r   c                 |    U R                   nU R                  nU R                  n0 nUb  XS'   Ub  X$S'   Ub  X4S'   U$ )Nr  r+  r4  r  r+  r4  )r3   r  r+  r4  r  s        r$   rs  SchemaReference.to_dict~  sR    yy,,,,%'
!%v$+y!$+y!r&   r  r  c                     UR                  5       nUR                  SS 5      nUR                  SS 5      nUR                  SS 5      nU " UUUS9nU$ )Nr  r+  r4  r<  )r   r   )r  r  r  r  r+  r4  schema_references          r$   rt  SchemaReference.from_dict  sY    MMOuuVT"%%	4(%%	4(
  r&   r6   N)r7   r8   r9   r:   r   rP   r  r   r   r   rs  r  r   r  rt  r>   r6   r&   r$   r:  r:  x  si    
3-c]c]c3h "  tAw  $sCx.  Q    r&   r:  c                   >    \ rS rSrSrSrSrSrSrSr	Sr
S	\4S
 jrSrg)ConfigCompatibilityLeveli  BACKWARDBACKWARD_TRANSITIVEFORWARDFORWARD_TRANSITIVEFULLFULL_TRANSITIVENONEr   c                 ,    [        U R                  5      $ r/   r  r2   s    r$   r   ConfigCompatibilityLevel.__str__  r  r&   r6   N)r7   r8   r9   r:   rC  rD  rE  rF  rG  rH  rI  rP   r  r>   r6   r&   r$   rB  rB    s3    H/G-D'OD r&   rB  c                       \ rS rSr% Sr\\   \S'   Sr\\   \S'   Sr	\\
   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S	'   S
\\
\4   4S jr\S\\   S\\
\4   S
\4S j5       rSrg)r  i  Nr  compatibility_levelcompatibility_groupdefault_metadataoverride_metadatadefault_rule_setoverride_rule_setr   c                 H   S nU R                   b  U R                   R                  nS nU R                  b  U R                  R                  nU R                  n[	        U R
                  [        5      (       a  U R
                  R                  5       nOU R
                  n[	        U R                  [        5      (       a  U R                  R                  5       nOU R                  n[	        U R                  [        5      (       a  U R                  R                  5       nOU R                  n[	        U R                  [        5      (       a  U R                  R                  5       nOU R                  n0 nUb  XS'   Ub  X(S'   Ub  X8S'   Ub  XHS'   Ub  XXS'   Ub  XhS'   Ub  XxS'   U$ )Nr  r  compatibilityGroupdefaultMetadataoverrideMetadatadefaultRuleSetoverrideRuleSet)r  r   rM  rN  r   rO  r/  rs  rP  rQ  r  rR  )	r3   _compatibility_compatibility_levelrN  _default_metadata_override_metadata_default_rule_set_override_rule_setr  s	            r$   rs  ServerConfig.to_dict  s   (,)!//55N.2##/#'#;#;#A#A "66 d++X66 $ 5 5 = = ? $ 5 5 d,,h77!%!7!7!?!?!A!%!7!7 d++W55 $ 5 5 = = ? $ 5 5 d,,g66!%!7!7!?!?!A!%!7!7%'
%*8'+/C+,*/B+,(,=())-?)*(+<'(),>()r&   r  r  c           
      n   UR                  5       nUR                  SS 5      nUc  S nO[        U5      nUR                  SS 5      nUc  S nO[        U5      nUR                  SS 5      nS[        S[        [
           4S jnU" UR                  SS 5      5      n	S[        S[        [
           4S jn
U
" UR                  S	S 5      5      nS[        S[        [           4S
 jnU" UR                  SS 5      5      nS[        S[        [           4S jnU" UR                  SS 5      5      nU " UUUU	UUUS9nU$ )Nr  r  rT  datar   c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   r   r=   r   r/  rt  ra  s    r$   _parse_default_metadata7ServerConfig.from_dict.<locals>._parse_default_metadata   2    |dD))k!%%d++r&   rU  c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   rc  rd  s    r$   _parse_override_metadata8ServerConfig.from_dict.<locals>._parse_override_metadata	  rg  r&   rV  c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   r   r=   r   r  rt  rd  s    r$   _parse_default_rule_set7ServerConfig.from_dict.<locals>._parse_default_rule_set  2    |dD))k!$$T**r&   rW  c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   rl  rd  s    r$   _parse_override_rule_set8ServerConfig.from_dict.<locals>._parse_override_rule_set  ro  r&   rX  )r  rM  rN  rO  rP  rQ  rR  )r   r   rB  objectr   r/  r  )r  r  r  rY  r  rZ  rM  rN  re  rO  ri  rP  rm  rQ  rq  rR  rh  s                    r$   rt  ServerConfig.from_dict  sX   MMO5! M4^DM uu%94@'"&":;O"Pee$8$?	,& 	,Xh5G 	, 31559JD3QR	,6 	,hx6H 	, 5QUU;Mt5TU	+& 	+Xg5F 	+ 31559I43PQ	+6 	+hw6G 	+ 5QUU;Ld5ST' 3 3-/-/
 r&   r6   )r7   r8   r9   r:   r  r   rB  r  rM  rN  rP   rO  r/  rP  rQ  r  rR  r   r   rs  r  r   r  rt  r>   r6   r&   r$   r  r    s    8<M845<>B":;B)-#-+/hx(/,0x)0*.hw'.+/x(/3c3h 3j @tAw @$sCx. @Q @ @r&   r  )r  
cache_hashc                       \ rS rSr% Sr\\   \S'   Sr\\   \S'   \	" \
SS9r\\\      \S'   S	r\\   \S
'   S	r\\   \S'   S\\\4   4S jr\S\\   S\\\4   S\4S j5       rSrg	)r.  i1  z
An unregistered schema.

schema_strAVROschema_typeFr  
referencesNr  r  r   c                    U R                   nU R                  n/ nU R                  b4  U R                   H$  nUR                  5       nUR	                  U5        M&     S n[        U R                  [        5      (       a  U R                  R                  5       nS n[        U R                  [        5      (       a  U R                  R                  5       n0 nUb  XS'   Ub  X(S'   Ub  X8S'   Ub  XhS'   Ub  XxS'   U$ )Nr-  
schemaTyperz  r  ruleSet)
rw  ry  rz  rs  r   r   r  r/  r  r  )	r3   r-  ry  _referencesreferences_item_datareferences_item	_metadata	_rule_setr  s	            r$   rs  Schema.to_dict=  s    &&68??&(,$"6">">"@""?3 )8 /3	dmmX..--/I.2	dmmW----/I%'
#)x "'2|$"'2|$ %.z" $-y!r&   r  r  c                    UR                  5       nUR                  SS 5      nUR                  SS5      n/ nUR                  SS 5      nU=(       d    /  H)  n[        R                  U5      nUR	                  U5        M+     S[
        S[        [           4S jn	U	" UR                  SS 5      5      n
S[
        S[        [           4S	 jnU" UR                  S
S 5      5      nU " UUUU
US9nU$ )Nr-  r|  rx  rz  ra  r   c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   rc  rd  s    r$   _parse_metadata)Schema.from_dict.<locals>._parse_metadatam  rg  r&   r  c                 t    U c  U $ [        U [        5      (       d
  [        5       e[        R	                  U 5      $ r/   rl  rd  s    r$   _parse_rule_set)Schema.from_dict.<locals>._parse_rule_setv  ro  r&   r}  )rw  ry  rz  r  r  )	r   r   r:  rt  r   rs  r   r/  r  )r  r  r  r-  ry  rz  r~  r  r  r  r  r  r  s                r$   rt  Schema.from_dict^  s    MMOx&eeL&1
eeL$/$/$52$5 -778LMOo. %6
	,& 	,Xh-? 	, #155T#:;	+& 	+Xg-> 	+ #155D#9:#!
 r&   r6   )r7   r8   r9   r:   r  r   rP   r  ry  r  listrz  r
   r:  r  r/  r  r  r   r   rs  r  r   r  rt  r>   r6   r&   r$   r.  r.  1  s     !'K#'2>tRW2XJo./X#'Hhx '"&Hhw&c3h B (tAw ($sCx. (Q ( (r&   r.  c                       \ rS rSr% Sr\\   \S'   \\   \S'   \\	   \S'   \\   \S'   S\
\	\4   4S jr\S	\\   S
\
\	\4   S\4S j5       rSrg)r2  i  z
An registered schema.
r,  r-  r+  r4  r   c                     U R                   nU R                  nU R                  nU R                  n0 nUb  UR	                  5       nUb  X%S'   Ub  X5S'   Ub  XES'   U$ )Nidr+  r4  )r-  r,  r+  r4  rs  )r3   r-  r,  r+  r4  r  s         r$   rs  RegisteredSchema.to_dict  sm    NN	,,,,%'
)J (t$+y!$+y!r&   r  r  c                     UR                  5       n[        R                  U5      nUR                  SS 5      nUR                  SS 5      nUR                  SS 5      nU " UUUUS9nU$ )Nr  r+  r4  )r,  r-  r+  r4  )r   r.  rt  r   )r  r  r  r-  r,  r+  r4  s          r$   rt  RegisteredSchema.from_dict  sj    MMO!!!$EE$%	%%	4(%%	4(	
 r&   r6   N)r7   r8   r9   r:   r  r   r   r  r.  rP   r   r   rs  r  r   r  rt  r>   r6   r&   r$   r2  r2    s{     }Vc]c]c3h * tAw $sCx. Q  r&   r2  )Pr;   r  loggingr  ro   r!   urllib.parser   r   r   attrsr   _attrs_definer   r  collectionsr   enumr   	threadingr	   typingr
   r   r   r   r   r   r   r   r   r   
cachetoolsr   r   r   !authlib.integrations.httpx_clientr   errorr   r   
basestringr   rP   r%   	NameError	getLoggerr7   logVALID_AUTH_PROVIDERSABCMetar,   rA   rR   r\   rs  r   r   r   r   r  r
  r   r   r"  rV  r  r  r  r  r  r  r  r%  r/  r:  rB  r  r.  r2  r6   r&   r$   <module>r     s  $       *  ) ' #  0 0 0 *  : 7	2K,# ,# , !{+ "S[[ "D/ D8- 8%b' %bPM$f M$`]/ ]@%C %D %9c 9d 9@s @# @# @RW @
)6 )Di	*6 i	*X CLsD 	sD 	 4 4 4* du u up 3Y 3Y 3Yl 2 2 28 8 8 8* d6 6 6r d%  %  % P
sD 
   D dt,U U -Up dt,2 2 -2i:  2K2# 2# 22s   8G1 1HH