
    ?g."                         d dl Z d dlZd dlZd dlmZ dZdZdZej                  d    dk(  Z	e	rd dl
Z
e
j                  Znd dlZej                  j                  Z G d d      Zd	 Zd
 Z G d de      Zy)    N)clientz:return:z:param bool follow:List   c                       e Zd Zd Zy)SimpleNamespacec                 :    | j                   j                  |       y N)__dict__update)selfkwargss     K/var/www/openai/venv/lib/python3.12/site-packages/kubernetes/watch/watch.py__init__zSimpleNamespace.__init__+   s    V$    N)__name__
__module____qualname__r    r   r   r   r   )   s    %r   r   c                     t        j                  |       j                         D ]9  }|j                  t              s|t        t              d  j                         c S  y)N )pydocgetdoc
splitlines
startswithPYDOC_RETURN_LABELlenstrip)funclines     r   _find_return_typer    /   sM    T"--/??-../017799 0 r   c              #     K   t               }| j                  d d      D ]  }t        |t              r|j	                  |       nIt        |t
              r!|j	                  |j                  d             nt        dt        |       d      |j                  d      }|dk7  s|d | j                  dd	      }||d
z   d  }|r| |j                  d      }|dk7  r; y w)NF)amtdecode_contentzutf-8zReceived invalid segment type, z-, from stream. Accepts only 'str' or 'bytes'.   
replace)errors   )	bytearraystream
isinstancebytesextendstrencode	TypeErrortypefinddecode)respbuffersegmentnext_newliner   s        r   iter_resp_linesr8   6   s     [F;;4;> gu%MM'"%MM'..121$w-@mnp p {{5)b -<(//	 0 +DLNO,F
!;;u-L b % ?s   B"C#%:C# C#c                   2    e Zd ZddZd Zd Zd Zd Zd Zy)	WatchNc                 `    || _         d| _        t        j                         | _        d | _        y )NF)_raw_return_type_stopr   	ApiClient_api_clientresource_version)r   return_types     r   r   zWatch.__init__V   s*     +
!++- $r   c                     d| _         y )NT)r=   )r   s    r   stopz
Watch.stop\   s	    
r   c                     | j                   r| j                   S t        |      }|j                  t              r|d t	        t                S |S r	   )r<   r    endswithTYPE_LIST_SUFFIXr   )r   r   rA   s      r   get_return_typezWatch.get_return_type_   sM      ((('- 016%5!6 677r   c                 <    t         t        j                  |      v ryy)Nfollowwatch)PYDOC_FOLLOW_PARAMr   r   )r   r   s     r   get_watch_argument_namezWatch.get_watch_argument_nameg   s    d!33r   c                    t        j                  |      }|d   |d<   |r|d   dk7  r|d   dk7  rt        t        j                  |d               }| j                  j                  ||      |d<   t        |d   d      r |d   j                  j                  | _        |S t        |d   t              r!d|d   v rd|d   d   v r|d   d   d   | _        |S )	Nobject
raw_objectr1   ERRORBOOKMARK)datametadataresourceVersion)jsonloadsr   dumpsr?   deserializehasattrrS   r@   r+   dict)r   rR   rA   jsobjs        r   unmarshal_eventzWatch.unmarshal_eventm   s    ZZh<<
 2f:0RZ:5M!tzz"\2B'CDC++77[IBxLr(|Z0(*8(=(=(N(N% 		 R\40Z2h<5O'2h<
+CC(*8Z(@%)'%	r   c              /   (  K   d| _         | j                  |      }| j                  |      }d||<   d|d<   d|v r
|d   | _        d|v }d}	  ||i |}	 t	        |      D ]  }	|dk(  r{| j                  |	|      }
t        |
t              rR|
d   dk(  rJ|
d	   }|s|s|d
   t        k(  rd} nL|d   d|d   }t        j                  j                  |d
   |      d}|
 n|	 | j                   s n |j                          |j                          | j                  | j                  |d<   nd| _         	 | j                   s|ry# |j                          |j                          | j                  | j                  |d<   w d| _         w xY ww)aj  Watch an API resource and stream the result back via a generator.

        Note that watching an API resource can expire. The method tries to
        resume automatically once from the last result, but if that last result
        is too old as well, an `ApiException` exception will be thrown with
        ``code`` 410. In that case you have to recover yourself, probably
        by listing the API resource to obtain the latest state and then
        watching from that state on by setting ``resource_version`` to
        one returned from listing.

        :param func: The API function pointer. Any parameter to the function
                     can be passed after this parameter.

        :return: Event object with these keys:
                   'type': The type of event such as "ADDED", "DELETED", etc.
                   'raw_object': a dict representing the watched object.
                   'object': A model representation of raw_object. The name of
                             model will be determined based on
                             the func's doc string. If it cannot be determined,
                             'object' value will be the same as 'raw_object'.

        Example:
            v1 = kubernetes.client.CoreV1Api()
            watch = kubernetes.watch.Watch()
            for e in watch.stream(v1.list_namespace, resource_version=1127):
                type_ = e['type']
                object_ = e['object']  # object is one of type return_type
                raw_object = e['raw_object']  # raw_object is a dict
                ...
                if should_stop:
                    watch.stop()
        FT_preload_contentr@   timeout_secondsrJ   r1   rP   rO   codereasonz: message)statusrb   N)r=   rG   rL   r@   r8   r]   r+   rZ   HTTP_STATUS_GONEr   restApiExceptioncloserelease_conn)r   r   argsr   rA   	watch_argdisable_retriesretry_after_410r4   r   eventr\   rb   s                r   r*   zWatch.stream   s    D 
**40006	 y%*!"'$*+=$>D! -6((D!&+D1D !G+ $ 4 4T; G%eT2$)&MW$<"'"5C $3?$'K3C$C26 % %(M3y>*C&,kk&>&>+.v;v '? 'G !G /4O"'K"
zz3 26 

!!#((4151F1FF-.!%DJzz_M < 

!!#((4151F1FF-.!%DJs'   AFBE
 3E
 6AF
AFFr	   )	r   r   r   r   rC   rG   rL   r]   r*   r   r   r   r:   r:   T   s!    %(Tr   r:   )rU   r   sys
kubernetesr   r   rK   rF   version_infoPY2httplibGONEre   http
HTTPStatusr   r    r8   rN   r:   r   r   r   <module>rw      s      
  *    
qQ||++% %.<AF Ar   