a _b$@sddlmZddlZddlZddlmZmZddlmZddlm Z m Z m Z m Z m Z mZmZdddgd fZd d Zd d ZddZdZddZddZddZGdddeZGdddeZdS))unicode_literalsN)datedatetimewraps)PY2quote string_typesto_bytesto_strunquoteurlparsecCs|durigSt|tr|g}g}|D]}t|trd|vrDd|}t|}d|ji}|jrf|j|d<|jdkr|jpxd|d<d|d <|js|jrd t|jt|jf|d <|j r|j d kr|j |d <| |q&| |q&|S)zr Helper function to transform hosts argument to :class:`~opensearchpy.OpenSearch` to a list of dicts. Nz://z//%shostporthttpsiTZuse_sslz%s:%s http_auth/Z url_prefix) isinstancer rhostnamerschemeusernamepasswordr pathappend)hostsoutr parsed_urlhrr@/tmp/pip-target-4jja1joz/lib/python/opensearchpy/client/utils.py_normalize_hosts(s4          r#cCst|ttfrd|}n>t|ttfr2|}n&t|trJt| }nt|t rX|St|t rt rzt|t rz|dSt st|tr|dSt|S)z Escape a single value of a URL string or a query parameter. If it is a list or tuple, turn it into a comma-separated string first. ,zutf-8)rlisttuplejoinrr isoformatboolstrlowerbytesr runicodeencode)valuerrr"_escapeUs       r0cGsdddd|DS)z Create a URL string from parts, omit all `None` values and empty strings. Convert lists and tuples to comma separated values. rcss$|]}|tvrtt|dVqdS)s,*N) SKIP_IN_PATHr r0).0prrr" {sz_make_path..)r')partsrrr" _make_pathus r6)prettyZhumanZ error_traceformatZ filter_pathcsfdd}|S)zt Decorator that pops all accepted parameters from method's kwargs and puts them in the params argument. cstfdd}|S)Ncs|ddpi}dd|ddp(iD}d|vrL|d|d<|dd}|dd}|dur~|dur~td n6|durd t|f|d <n|durd t|f|d <tD]*}||vr||}|durt|||<qd D]}||vr||||<q|||d|S)NparamscSsi|]\}}||qSr)r+)r2kvrrr" szDquery_params.._wrapper.._wrapped..headersZ opaque_idz x-opaque-idrapi_keyz=Only one of 'http_auth' and 'api_key' may be passed at a timezBasic %s authorizationz ApiKey %s)ignorerequest_timeout)r9r=)popcopyitems ValueError_base64_auth_header GLOBAL_PARAMSr0)argskwargsr9r=rr>r3r;)funcopensearch_query_paramsrr"_wrappeds6     z0query_params.._wrapper.._wrappedr)rJrLrK)rJr"_wrappers$zquery_params.._wrapperr)rKrNrrMr" query_paramss (rOcCsZt|tsdt|j|}t|tr:|dsV|d7}nt|trV|dsV|d7}|S)N  )rr r'mapdumpsr,endswith) serializerbodyrrr" _bulk_bodys    rWcCs*t|ttfr"ttd|}t|S)zTakes either a 2-tuple or a base64-encoded string and returns a base64-encoded string to be used as an HTTP authorization header. :)rr%r&base64 b64encoder r'r )Z auth_valuerrr"rFsrFc@s eZdZddZeddZdS)NamespacedClientcCs ||_dSN)client)selfr]rrr"__init__szNamespacedClient.__init__cCs|jjSr\)r] transport)r^rrr"r`szNamespacedClient.transportN)__name__ __module__ __qualname__r_propertyr`rrrr"r[sr[c@seZdZeddZdS) AddonClientcCs |t|}t||j||Sr\)weakrefproxysetattr namespace)clsr]Zaddonrrr" infect_clientszAddonClient.infect_clientN)rarbrc classmethodrkrrrr"resre) __future__rrYrfrr functoolsrcompatrr r r r r rr1r#r0r6rGrOrWrFobjectr[rerrrr"s  $- 1