9(Zc@sdZddlZddlZddlmZddlZddlmZddlmZm Z ddl m Z ddl m Z ddl m Z dd lmZd Zd Zd Zed ZdefdYZdefdYZdefdYZdefdYZdefdYZdeefdYZdefdYZied6ed6ed6ed6ed 6ZdS(!sProtocol input serializes. This module contains classes that implement input serialization for the various AWS protocol types. These classes essentially take user input, a model object that represents what the expected input should look like, and it returns a dictionary that contains the various parts of a request. A few high level design decisions: * Each protocol type maps to a separate class, all inherit from ``Serializer``. * The return value for ``serialize_to_request`` (the main entry point) returns a dictionary that represents a request. This will have keys like ``url_path``, ``query_string``, etc. This is done so that it's a) easy to test and b) not tied to a particular HTTP library. See the ``serialize_to_request`` docstring for more details. Unicode ------- The input to the serializers should be text (str/unicode), not bytes, with the exception of blob types. Those are assumed to be binary, and if a str/unicode type is passed in, it will be encoded as utf-8. iN(t ElementTree(tsix(tjsont formatdate(tparse_to_aware_datetime(tpercent_encode(tis_json_value_header(tvalidatetiso8601s%Y-%m-%dT%H:%M:%SZs%Y-%m-%dT%H:%M:%S.%fZcCs8t|}|r4tj}tj||}n|S(N(t SERIALIZERSRtParamValidatortParamValidationDecorator(t protocol_nametinclude_validationt serializert validator((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pytcreate_serializer=s   t SerializercBsbeZdZeZdZdZdZdZdZ dZ dZ dZ d Z RS( tPOSTsutf-8cCstddS(sSerialize parameters into an HTTP request. This method takes user provided parameters and a shape model and serializes the parameters to an HTTP request. More specifically, this method returns information about parts of the HTTP request, it does not enforce a particular interface or standard for an HTTP request. It instead returns a dictionary of: * 'url_path' * 'query_string' * 'headers' * 'body' * 'method' It is then up to consumers to decide how to map this to a Request object of their HTTP library of choice. Below is an example return value:: {'body': {'Action': 'OperationName', 'Bar': 'val2', 'Foo': 'val1', 'Version': '2014-01-01'}, 'headers': {}, 'method': 'POST', 'query_string': '', 'url_path': '/'} :param parameters: The dictionary input parameters for the operation (i.e the user input). :param operation_model: The OperationModel object that describes the operation. tserialize_to_requestN(tNotImplementedError(tselft parameterstoperation_model((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyROs"cCs0idd6dd6|jd6id6dd6}|S(Nt/turl_pathtt query_stringtmethodtheaderstbody(tDEFAULT_METHOD(Rt serialized((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_create_default_requestss  cCs+|jdkrt}nt}|j|S(Ni(t microsecondt ISO8601_MICROtISO8601tstrftime(Rtvaluettimestamp_format((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_timestamp_iso8601s cCsttj|jS(N(tinttcalendarttimegmt timetuple(RR&((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_timestamp_unixtimestampscCst|dtS(Ntusegmt(RtTrue(RR&((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_timestamp_rfc822scCs8t|}t|d|jj}||}|S(Ns _timestamp_%s(RtgetattrtTIMESTAMP_FORMATtlower(RR&t datetime_objt convertert final_value((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_convert_timestamp_to_strs   cCs|jjd|S(Ntname(t serializationtget(Rtshapet default_name((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt_get_serialized_namescCsFt|tjr'|j|j}ntj|jj|jS(N( t isinstanceRt text_typetencodetDEFAULT_ENCODINGtbase64t b64encodetstriptdecode(RR&((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyt _get_base64s(t__name__t __module__RtdicttMAP_TYPERARR!R(R-R0R7R=RF(((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyRFs $      tQuerySerializercBseZdZdZddZddZddZddZddZddZ dd Z dd Z d Z RS( RcCs|j}|j}|jjd|j|d|D]6}i}|j|||jd|j|dqWdS(Nt __current__(RSR_tappend(RR R&R;RZtlist_objt list_itemtwrapper((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyRjVs   cCs|||RR?R@RA(RR((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyRsc Cs7||}|jjd}|jjd|}|dkrN||d|RItupdatetbooltstrR3t_convert_header_valuet_do_serialize_header_map( RRRRRR_Rtkey_nameR;R&t header_prefix((s4/tmp/pip-build-wDUJoH/botocore/botocore/serialize.pyRs*        cCs5x.|jD] \}}||}|||'s6    _bG_