3 fYd@sdZddlmZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z m Z mZmZddlmZddlmZmZdd lmZdd lmZmZGd d d eZdS) a Copyright 2016 SmartBear Software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ref: https://github.com/swagger-api/swagger-codegen )absolute_importN)datedatetime)PY3 integer_types iteritems text_type)quote)models ws_client) configuration) ApiExceptionRESTClientObjectc @seZdZdZddddefddZeddZejddZdd Z d-d d Z d dZ ddZ ddZ d.ddZd/ddZddZd0ddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,ZdS)1 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. NcCsV||_t|jd|_i|_|dk r,||j|<|dkr@|jj|_n||_||_d|_dS)z+ Constructor of the class. )configNz%Swagger-Codegen/1.0.0-snapshot/python)rr rest_clientdefault_headershostcookie user_agent)selfr header_name header_valuerrrM/Users/olari/OneDrive/sandbox/awsBlog2/lambda/kubernetes/client/api_client.py__init__:s  zApiClient.__init__cCs |jdS)z" Gets user agent. z User-Agent)r)rrrrrLszApiClient.user_agentcCs||jd<dS)z" Sets user agent. z User-AgentN)r)rvaluerrrrSscCs||j|<dS)N)r)rrrrrrset_default_headerZszApiClient.set_default_headerTc Cs||pi}|j|j|jr$|j|d<|rB|j|}t|j|| }|r|j|}|j|| }x(|D] \}}|jd|tt|}qbW|r|j|}|j|| }|s|r|j ||}|j|}|j|| }|j ||| |r|j|}|j |}|j ||||||||d}||_ |}|r2| r.|j|| }nd}| r^| rH| |n| ||j|jfn| rh|S||j|jfSdS)NCookiez{%s}) query_paramsheaders post_paramsbody_preload_content_request_timeout)updaterrsanitize_for_serializationdictparameters_to_tuplesreplacer strprepare_post_parametersupdate_params_for_authrrequest last_response deserializestatus getheaders)r resource_pathmethod path_paramsr header_paramsr#r"files response_type auth_settingscallback_return_http_data_onlycollection_formatsr$r%kvurlZ response_dataZ return_datarrrZ __call_api]sb          zApiClient.__call_apicsttttftttf}ttdr,dSt|r:Stt rVfddDSttrvtfddDStt t frj Stt r}nfddtjD}fddt|DSdS) 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. Ncsg|]}j|qSr)r').0sub_obj)rrr sz8ApiClient.sanitize_for_serialization..c3s|]}j|VqdS)N)r')r@rA)rrr sz7ApiClient.sanitize_for_serialization..cs0i|](\}}t|dk rt|j|qS)N)getattr attribute_map)r@attr_)objrr sz8ApiClient.sanitize_for_serialization..csi|]\}}j||qSr)r')r@keyval)rrrrIs)r+floatboolbytestuplerr isinstancetypelistrr isoformatr(r swagger_types)rrHtypesZobj_dictr)rHrrr's&         z$ApiClient.sanitize_for_serializationc CsJd|kr|j|Sytj|j}Wntk r<|j}YnX|j||S)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_filejsonloadsdata ValueError_ApiClient__deserialize)rresponser8rZrrrr0s   zApiClient.deserializecs|dkr dSt|tr|jdrFtjd|jdfdd|DS|jdrztjd|jd fd d t|DS|dkrt|}n"|dkrtrt nt }n td|}|t ks|t tt fkrЈj||S|tkrj|S|tkrj|S|tkr j|Sj||SdS)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. Nzlist[z list\[(.*)\]r csg|]}j|qSr)r\)r@Zsub_data)rsub_klsrrrBsz+ApiClient.__deserialize..zdict(zdict\(([^,]*), (.*)\)csi|]\}}j||qSr)r\)r@r=r>)rr^rrrIsz+ApiClient.__deserialize..intrLr+rMrrobjectlongzmodels.)r`rLr+rMrrra)rPr+ startswithrematchgrouprevalrr`rbrrLrM!_ApiClient__deserialize_primitivera_ApiClient__deserialize_objectr_ApiClient__deserialize_dater _ApiClient__deserialize_datatime_ApiClient__deserialize_model)rrZklassr)rr^rZ __deserializes4               zApiClient.__deserializecCsh| dkr.|j||||||||| | | | | ||Stj|j||||||||| | | | | ||fd}|j|S)a Makes the HTTP request (synchronous) and return the deserialized data. To make an async request, define a function for callback. :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 callback function: Callback function for asynchronous request. If provide this parameter, the request will be called 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 provide parameter callback, the request will be called asynchronously. The method will return the request thread. If parameter callback is None, then the method will return the response directly. N)targetargs)_ApiClient__call_api threadingThreadstart)rr3r4r5r r6r#r"r7r8r9r:r;r<r$r%threadrrrcall_apis&- zApiClient.call_apic Cs0|jds|jdr<|dks$|dkr.Zssv Ztsv Zpipes|,css|]}t|VqdS)N)r+)r@rrrrrCs)rPr(rextendappendjoin)rparamsr< new_paramsr>Zcollection_format delimiterr)r=rr)s& zApiClient.parameters_to_tuplesc Csg}|r |}|rxt|D]\}}|s(qt|tr6|n|g}xf|D]^}t|dJ}tjj|j} |j} t j | dpxd} |j t |t | | | ggWdQRXqBWqW|S)z Builds form parameters. :param post_params: Normal form parameters. :param files: File parameters. :return: Form parameters with files. rbrzapplication/octet-streamN) rrPrRopenospathbasenamenameread mimetypes guess_typerrO) rr"r7rr=r>Z file_namesnffilenameZfiledatamimetyperrrr,s"   z!ApiClient.prepare_post_parameterscCs4|sdSttdd|}d|kr&dSdj|SdS)z Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. :return: Accept (e.g. application/json). NcSs|jS)N)lower)xrrrsz0ApiClient.select_header_accept..zapplication/jsonz, )rRmapr)rZacceptsrrrselect_header_accepts zApiClient.select_header_acceptcCs:|sdSttdd|}d|ks*d|kr.dS|dSdS)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). zapplication/jsoncSs|jS)N)r)rrrrrsz6ApiClient.select_header_content_type..z*/*rN)rRr)rZ content_typesrrrselect_header_content_types z$ApiClient.select_header_content_typecCs|sdSxv|D]n}|jjj|}|r|ds2qq|ddkrP|d||d<q|ddkrt|j|d|dfqtdqWdS)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. NrinheaderrJqueryz3Authentication token must be in `query` or `header`)rr9getrr[)rr!Zquerysr9authZ auth_settingrrrr-s    z ApiClient.update_params_for_authc Cstj|jjd\}}tj|tj||jd}|r^tj d|j d}tj j tj j ||}t|d}|j|jWdQRX|S)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. )dirzContent-Dispositionz filename=[\'"]?([^\'"\s]+)[\'"]?r wN)tempfilemkstemprtemp_folder_pathrcloseremove getheaderrdsearchrfrrdirnamerwriterZ)rr]fdrcontent_dispositionrrrrrZ__deserialize_files     zApiClient.__deserialize_filec CsDy ||}Wn2tk r(t|}Yntk r>|}YnX|S)z Deserializes string to primitive type. :param data: str. :param klass: class literal. :return: int, long, float, str, bool. )UnicodeEncodeErrorunicode TypeError)rrZrmrrrrZ__deserialize_primitive6s    z!ApiClient.__deserialize_primitivecCs|S)zD Return a original value. :return: object. r)rrrrrZ__deserialize_objectGszApiClient.__deserialize_objectc Cs^|sdSyddlm}||jStk r4|Stk rXtddj|dYnXdS)zb Deserializes string to date. :param string: str. :return: date. Nr)parsez(Failed to parse `{0}` into a date object)r1reason)dateutil.parserrr ImportErrorr[rformat)rstringrrrrZ__deserialize_dateOs  zApiClient.__deserialize_datec CsZ|sdSyddlm}||Stk r0|Stk rTtddj|dYnXdS)z Deserializes string to datetime. The string should be in iso8601 datetime format. :param string: str. :return: datetime. Nr)rz,Failed to parse `{0}` into a datetime object)r1r)rrrr[rr)rrrrrrZ__deserialize_datatimeds  z ApiClient.__deserialize_datatimecCs|}|js|Sxvt|jD]h\}}|dk r|j||krt|ttfr||j|}|dkrpt|trlgni}t|||j||qW|S)z Deserializes list or dict to model. :param data: dict, list. :param klass: class literal. :return: model object. N)rTrrErPrRr(setattrr\)rrZrminstancerFZ attr_typerrrrZ__deserialize_model{szApiClient.__deserialize_model) NNNNNNNNNNNTN) NNNNNNNNNNNTN)NNNNTN)NN)__name__ __module__ __qualname____doc__r rpropertyrsetterrrpr'r0r\rur.r)r,rrr-rWrhrirjrkrlrrrrr(sB  J,. = G r)r __future__rrXrrrdrrqrrsixrrrrZsix.moves.urllib.parser r r r restrrrarrrrrs