
    CT                         d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	 ddl
mZm
Z
 ddlmZmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ  G d de      Zy)z
    Kubernetes

    No description provided (generated by Swagger Codegen
    https://github.com/swagger-api/swagger-codegen)

    OpenAPI spec version: v1.14.4

    Generated by: https://github.com/swagger-api/swagger-codegen.git
    )absolute_importN)
ThreadPool)datedatetime)PY3integer_types	iteritems	text_type)quote   )models)Configuration)ApiExceptionRESTClientObjectc            	       R   e Zd ZdZeeeefez   Z	e
ere
neeeeeeedZdZ	 	 	 	 	 ddZd Zed        Zed        Zej0                  d        Zd	 Z	 	 	 	 	 	 	 	 	 	 	 	 dd
Zd Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZd Z ddZ!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*y) 	ApiClienta  
    Generic API client for Swagger client library builds.

    Swagger generic API client. This client handles the client-
    server communication, and is invariant across implementations. Specifics of
    the methods and models for each application are generated from the Swagger
    templates.

    NOTE: This class is auto generated by the swagger code generator program.
    Ref: https://github.com/swagger-api/swagger-codegen
    Do not edit the class manually.

    :param host: The base path for the server to call.
    :param header_name: a header to pass when making calls to the API.
    :param header_value: a header value to pass when making calls to the API.
    )intlongfloatstrboolr   r   objectNc                     |
t               }|| _        || _        t        |      | _        i | _        ||| j
                  |<   || _        d| _        y )Nz&Swagger-Codegen/10.0.0-snapshot/python)r   configurationpool_threadsr   rest_clientdefault_headerscookie
user_agent)selfr   header_nameheader_valuer   r   s         /lib/third_party/kubernetes/client/api_client.py__init__zApiClient.__init__@   sZ     #om&D$D'6DD*6d;'DK>DO    c                     | j                   r<| j                   j                          | j                   j                          d | _         y y N)_poolclosejoinr    s    r#   __del__zApiClient.__del__S   s3    zz
jj
jjoodj r%   c                 f    | j                   t        | j                        | _         | j                   S )zsCreate thread pool on first request

         avoids instantiating unused threadpool for blocking clients.
        )r(   r   r   r+   s    r#   poolzApiClient.poolY   s*     zzd//0dj::r%   c                      | j                   d   S )z"
        Gets user agent.
        
User-Agentr   r+   s    r#   r   zApiClient.user_agentc   s    
 --r%   c                 "    || j                   d<   y)z"
        Sets user agent.
        r0   Nr1   r    values     r#   r   zApiClient.user_agentj   s    
 */D&r%   c                 "    || j                   |<   y r'   r1   )r    r!   r"   s      r#   set_default_headerzApiClient.set_default_headerq   s    (4D%r%   c           
         | j                   }|xs i }|j                  | j                         | j                  r| j                  |d<   |r,| j	                  |      }t        | j                  ||            }|r`| j	                  |      }| j                  ||      }|D ]8  \  }}|j                  d|z  t        t        |      |j                              }: |r#| j	                  |      }| j                  ||      }|s|r5| j                  ||      }| j	                  |      }| j                  ||      }| j                  |||
       |r| j	                  |      }| j                   j                  |z   }| j                  ||||||||      }|| _        |}|r|	r| j!                  ||	      }nd }|r|S ||j"                  |j%                         fS )NCookiez{%s})safe)query_paramsheaderspost_paramsbody_preload_content_request_timeout)r   updater   r   sanitize_for_serializationdictparameters_to_tuplesreplacer   r   safe_chars_for_path_paramprepare_post_parametersupdate_params_for_authhostrequestlast_responsedeserializestatus
getheaders)r    resource_pathmethodpath_paramsr:   header_paramsr=   r<   filesresponse_typeauth_settings_return_http_data_onlycollection_formatsr>   r?   configkvurlresponse_datareturn_datas                        r#   
__call_apizApiClient.__call_apit   s     F "'RM--.{{ $mH55mDm

#
#M3E
FHm 33K@k--k;MNk$!Q%--QJc!f6+K+KLN  44\Bl..|=OPl e00eDk33K@k--k;MNk 	|]K ,,T2d 


!
!M
1C LL!)) ! +M 'DK	&&}mD=//1I1I1KLLr%   c           	      f    |yt        | j                        r|S t        |t              r|D cg c]  } j                  |       c}S t        |t              rt	         fd|D              S t        |t
        t        f      r|j                         S t        |t              r|}nKt        |j                        D ci c]+  \  }}t        ||      |j                  |   t        ||      - }}}t        |      D ci c]  \  }}| j                  |       c}}S c c}w c c}}w c c}}w )a  
        Builds a JSON POST object.

        If obj is None, return None.
        If obj is str, int, long, float, bool, return directly.
        If obj is datetime.datetime, datetime.date
            convert to string in iso8601 format.
        If obj is list, sanitize each element in the list.
        If obj is dict, return the dict.
        If obj is swagger model, return the properties dict.

        :param obj: The data to serialize.
        :return: The serialized form of data.
        Nc              3   @   K   | ]  }j                  |        y wr'   )rA   ).0sub_objr    s     r#   	<genexpr>z7ApiClient.sanitize_for_serialization.<locals>.<genexpr>   s     O34227;3s   )
isinstancePRIMITIVE_TYPESlistrA   tupler   r   	isoformatrB   r	   swagger_typesgetattrattribute_map)r    objra   obj_dictattr_keyvals   `       r#   rA   z$ApiClient.sanitize_for_serialization   s1    {	C--	.j	C	FIJc7d--g6cJJ	C	O3OOO	C(D)	*]]_#th #3#4#455gdAS$+ 

D
!73#5
55   "(++HC 	T,,S11+ ) Ks   D"0D'D-c                     |dk(  r| j                  |      S 	 t        j                  |j                        }| j                  ||      S # t        $ r |j                  }Y )w xY w)a
  
        Deserializes response into an object.

        :param response: RESTResponse object to be deserialized.
        :param response_type: class literal for
            deserialized object, or string of class name.

        :return: deserialized object.
        file)_ApiClient__deserialize_filejsonloadsdata
ValueError_ApiClient__deserialize)r    responserS   rv   s       r#   rK   zApiClient.deserialize   sc     $$X..ZZ&d dM22  ]]ds   A	 	A! A!c           	         |yt        |      t        k(  r|j                  d      rEt        j                  d|      j                  d      }|D cg c]  }| j                  ||       c}S |j                  d      rTt        j                  d|      j                  d      }t        |      D ci c]  \  }}|| j                  ||       c}}S || j                  v r| j                  |   }nt        t        |      }|| j                  v r| j                  ||      S |t        k(  r| j                  |      S |t        k(  r| j!                  |      S |t"        k(  r| j%                  |      S | j'                  ||      S c c}w c c}}w )z
        Deserializes dict, list, str into an object.

        :param data: dict, list or str.
        :param klass: class literal, or string of class name.

        :return: object.
        Nzlist[z
list[(.*)]r   zdict(zdict(([^,]*), (.*))   )typer   
startswithrematchgrouprx   r	   NATIVE_TYPES_MAPPINGri   r   rd   !_ApiClient__deserialize_primitiver   _ApiClient__deserialize_objectr   _ApiClient__deserialize_dater    _ApiClient__deserialize_datatime_ApiClient__deserialize_model)r    rv   klasssub_klssub_datarX   rY   s          r#   __deserializezApiClient.__deserialize  sq    |E{c			'	"((=%066q9FJKd(""8W5dKK			'	"((159??B>GoNoda4%%a11oNN 
$++	+))%0&$$$))$66	&&&t,,	$$$T**	(	((..%%dE22+ L Os   E?0Fc                     |s| j                  |||||||||	|
||||      S | j                  j                  | j                   |||||||||	|
||||f      }|S )ac  
        Makes the HTTP request (synchronous) and return the deserialized data.
        To make an async request, set the async parameter.

        :param resource_path: Path to method endpoint.
        :param method: Method to call.
        :param path_params: Path parameters in the url.
        :param query_params: Query parameters in the url.
        :param header_params: Header parameters to be
            placed in the request header.
        :param body: Request body.
        :param post_params dict: Request post form parameters,
            for `application/x-www-form-urlencoded`, `multipart/form-data`.
        :param auth_settings list: Auth Settings names for the request.
        :param response: Response data type.
        :param files dict: key -> filename, value -> filepath,
            for `multipart/form-data`.
        :param async_req bool: execute request asynchronously
        :param _return_http_data_only: response data without head status code
        and headers
        :param collection_formats: dict of collection formats for path, query,
            header, and post parameters.
        :param _preload_content: if False, the urllib3.HTTPResponse object will
        be returned without
                                 reading/decoding response data. Default is
                                 True.
        :param _request_timeout: timeout setting for this request. If one number
        provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return:
            If async parameter is True,
            the request will be called asynchronously.
            The method will return the request thread.
            If parameter async is False or missing,
            then the method will return the response directly.
        )_ApiClient__call_apir.   apply_async)r    rN   rO   rP   r:   rQ   r=   r<   rR   rS   rT   	async_reqrU   rV   r>   r?   threads                    r#   call_apizApiClient.call_api2  s    j __]FK*D+u*M35G-/?	A A yy$$
//&+|]e]M!#57Gf Mr%   c	           	      0   |dk(  r | j                   j                  |||||      S |dk(  r | j                   j                  |||||      S |dk(  r"| j                   j                  |||||||      S |dk(  r"| j                   j	                  |||||||      S |dk(  r"| j                   j                  |||||||      S |dk(  r"| j                   j                  |||||||      S |d	k(  r!| j                   j                  ||||||
      S t        d      )z:
        Makes the HTTP request using RESTClient.
        GET)r:   r>   r?   r;   HEADOPTIONS)r:   r;   r<   r>   r?   r=   POSTPUTPATCHDELETE)r:   r;   r>   r?   r=   zQhttp method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.)	r   r   r   r   r   r   r   r   rw   )	r    rO   rZ   r:   r;   r<   r=   r>   r?   s	            r#   rI   zApiClient.requestv  s    !!
#++ "   
6	""
#++ #   
9	%%
#!++ &   
6	""
#!++ #   
5!!
#!++ "   
7	##
#!++ $   
8	$$
#++ %    > ? ?r%   c                 ^   g }|i }t        |t              rt        |      n|D ]  \  }|v ri|   }|dk(  r|j                  fd|D               /|dk(  rd}n|dk(  rd}n
|dk(  rd}nd	}|j	                  |j                  d
 |D              f       s|j	                  |f        |S )a  
        Get parameters as list of tuples, formatting collections.

        :param params: Parameters as dict or list of two-tuples
        :param dict collection_formats: Parameter collection formats
        :return: Parameters as list of tuples, collections formatted
        multic              3   &   K   | ]  }|f 
 y wr'    )r`   r4   rX   s     r#   rb   z1ApiClient.parameters_to_tuples.<locals>.<genexpr>  s     6A5QJAs   ssv tsv	pipes|,c              3   2   K   | ]  }t        |        y wr'   )r   )r`   r4   s     r#   rb   z1ApiClient.parameters_to_tuples.<locals>.<genexpr>  s     .Iqes5zqs   )rc   rB   r	   extendappendr*   )r    paramsrV   
new_paramsrY   collection_format	delimiterrX   s          @r#   rC   zApiClient.parameters_to_tuples  s     J!%/%=	&!6I1	
 	 .q1'


6A6
6%'I E)I G+II


Q	.Iq.I IJ
K1a&!! J" r%   c                    g }|r|}|rt        |      D ]  \  }}|s	t        |      t        u r|n|g}|D ]  }t        |d      5 }t        j
                  j                  |j                        }	|j                         }
t        j                  |	      d   xs d}|j                  t        |t        |	|
|g      g             ddd         |S # 1 sw Y   xY w)z
        Builds form parameters.

        :param post_params: Normal form parameters.
        :param files: File parameters.
        :return: Form parameters with files.
        rbr   zapplication/octet-streamN)r	   r|   re   openospathbasenamenameread	mimetypes
guess_typer   rf   )r    r<   rR   r   rX   rY   
file_namesnffilenamefiledatamimetypes               r#   rF   z!ApiClient.prepare_post_parameters  s     FfE"$!Q
q'T/Qs
AAt}ww''/HvvxH 
8%%&( F+E MM%E8Xx*H$I JKL } 	 # M }s   A>CCc                 x    |sy|D cg c]  }|j                          }}d|v rydj                  |      S c c}w )z
        Returns `Accept` based on an array of accepts provided.

        :param accepts: List of headers.
        :return: Accept (e.g. application/json).
        Napplication/jsonz, )lowerr*   )r    acceptsxs      r#   select_header_acceptzApiClient.select_header_accept  sC     ")*'Qqwwy'G*W$YYw +s   7c                 h    |sy|D cg c]  }|j                          }}d|v sd|v ry|d   S c c}w )z
        Returns `Content-Type` based on an array of content_types provided.

        :param content_types: List of content-types.
        :return: Content-Type (e.g. application/json).
        r   z*/*r   )r   )r    content_typesr   s      r#   select_header_content_typez$ApiClient.select_header_content_type  sF     (561QWWYM6]*e}.D1 7s   /c                     |sy|D ]t  }| j                   j                         j                  |      }|s/|d   s5|d   dk(  r|d   ||d   <   I|d   dk(  r|j                  |d   |d   f       kt	        d       y)a  
        Updates header and query params based on authentication setting.

        :param headers: Header parameters dict to be updated.
        :param querys: Query parameters tuple list to be updated.
        :param auth_settings: Authentication setting identifiers list.
        Nr4   inheaderro   queryz3Authentication token must be in `query` or `header`)r   rT   getr   rw   )r    r;   querysrT   authauth_settings         r#   rG   z ApiClient.update_params_for_auth  s     ''557;;DAl	G$
$8+)5g)>',u%
&$7*
--e,l7.CD
ECE E r%   c                    t        j                  | j                  j                        \  }}t	        j
                  |       t	        j                  |       |j                  d      }|rbt        j                  d|      j                  d      }t        j                  j                  t        j                  j                  |      |      }t        |d      5 }|j                  |j                          ddd       |S # 1 sw Y   |S xY w)z
        Saves response body into a file in a temporary folder,
        using the filename from the `Content-Disposition` header if provided.

        :param response:  RESTResponse.
        :return: file path.
        )dirzContent-Dispositionz filename=[\'"]?([^\'"\s]+)[\'"]?r   wN)tempfilemkstempr   temp_folder_pathr   r)   remove	getheaderr~   searchr   r   r*   dirnamer   writerv   )r    ry   fdr   content_dispositionr   r   s          r#   __deserialize_filezApiClient.__deserialize_file4  s     D$6$6$G$GHHBHHRLIIdO",,-BC
&46IK
%(  WW\\"''//$/:d	dCAgghmm 
 K 
 Ks   C??D	c                 `    	  ||      S # t         $ r t        |      cY S t        $ r |cY S w xY w)z
        Deserializes string to primitive type.

        :param data: str.
        :param klass: class literal.

        :return: int, long, float, str, bool.
        )UnicodeEncodeErrorunicode	TypeError)r    rv   r   s      r#   __deserialize_primitivez!ApiClient.__deserialize_primitiveL  s7    4[ T] ks   
 -
--c                     |S )zD
        Return a original value.

        :return: object.
        r   r3   s     r#   __deserialize_objectzApiClient.__deserialize_object\  s	     Lr%   c                     	 ddl m}  ||      j                         S # t        $ r |cY S t        $ r t        ddj                  |            w xY w)zb
        Deserializes string to date.

        :param string: str.
        :return: date.
        r   parsez(Failed to parse `{0}` into a date objectrL   reason)dateutil.parserr   r   ImportErrorrw   r   formatr    stringr   s      r#   __deserialize_datezApiClient.__deserialize_dated  s\    L'6]!! m L;BB6JL LLs    A%Ac                     	 ddl m}  ||      S # t        $ r |cY S t        $ r t	        ddj                  |            w xY w)z
        Deserializes string to datetime.

        The string should be in iso8601 datetime format.

        :param string: str.
        :return: datetime.
        r   r   z,Failed to parse `{0}` into a datetime objectr   )r   r   r   rw   r   r   r   s      r#   __deserialize_datatimez ApiClient.__deserialize_datatimeu  sS    	N'6] m N<CCFKN NNs    A%Ac                    |j                   st        |d      s|S i }|j                   pt        |j                         D ]X  \  }}|	|j                  |   |v st	        |t
        t        f      s2||j                  |      }| j                  ||      ||<   Z  |di |}t        |d      r%|j                  |      }|r| j                  ||      }|S )z
        Deserializes list or dict to model.

        :param data: dict, list.
        :param klass: class literal.
        :return: model object.
        get_real_child_modelr   )	rh   hasattrr	   rj   rc   re   rB   rx   r   )	r    rv   r   kwargsrm   	attr_typer4   instance
klass_names	            r#   __deserialize_modelzApiClient.__deserialize_model  s     wu6L'MkF&&u':':;/$	""4(D0$t-u**401%++E9=&, < vHx/0006j	%%dJ7Or%   )NNNNN)NNNNNNNNNNTN)NNNNNNNNNNNTN)NNNNTN)NN)+__name__
__module____qualname____doc__r   r   bytesr
   r   rd   r   r   r   r   r   r   r   r   r(   r$   r,   propertyr.   r   setterr6   r   rA   rK   rx   r   rI   rC   rF   r   r   rG   rs   r   r   r   r   r   r   r%   r#   r   r   !   sm   " D%3mC/cd	 % "  ?&   . . / /5 ""#!##(,$("&"&RMh+Z3.$3R   !!!&*"& $ $BN  ##H?T<8 ""E00 L"N(r%   r   )r   
__future__r   r   r~   rt   r   r   multiprocessing.poolr   r   r   sixr   r   r	   r
   six.moves.urllib.parser    r   r   r   restr   r   r   r   r   r%   r#   <module>r     sF   	 ' 	 	    + # 9 8 (  ( 0C
 C
r%   