ó U!¶\c@sÏdZddlmZddlZddlZddlmZddlmZddlmZddl m Z d„Z d „Z d „Z d efd „ƒYZd efd„ƒYZdefd„ƒYZdS(sQUser input parameter validation. This module handles user input parameter validation against a provided input model. Note that the objects in this module do *not* mutate any arguments. No type version happens here. It is up to another layer to properly convert arguments to any required types. Validation Errors ----------------- iÿÿÿÿ(tsixN(tdatetime(tparse_to_aware_datetime(tis_json_value_header(tParamValidationErrorcCsCtƒ}|j||ƒ}|jƒr?td|jƒƒ‚ndS(svValidates input parameters against a schema. This is a convenience function that validates parameters against a schema. You can also instantiate and use the ParamValidator class directly if you want more control. If there are any validation errors then a ParamValidationError will be raised. If there are no validation errors than no exception is raised and a value of None is returned. :param params: The user provided input parameters. :type shape: botocore.model.Shape :param shape: The schema which the input parameters should adhere to. :raise: ParamValidationError treportN(tParamValidatortvalidatet has_errorsRtgenerate_report(tparamstshapet validatorR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pytvalidate_parameterss  cs‡fd†}|S(Ncs%‡‡fd†}‡fd†‰|S(Ncs,ˆ|||ƒr(ˆ|||||ƒSdS(N((tselftparamR terrorstname(t _type_checktfunc(s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_on_passes_type_check6scsUt|ˆƒsQgˆD]}tj|ƒ^q}|j|dd|d|ƒtStS(Ns invalid typeRt valid_types(t isinstanceRt text_typeRtFalsetTrue(RRRtttvalid_type_names(R(s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR:s "((RR(R(RRs5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_create_type_check_guard5s((RR((Rs5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt type_check4scCsÃt}tdƒ}tdƒ}d|jkrR|jd}||kr”t}q”nBt|dƒr”|jjdƒr”d}||kr‘t}q‘q”n|r¿|j||d|d||gƒndS( Ns-inftinftmint serializationt hostLabeliRt valid_range(RtfloattmetadataRthasattrR tgetR(RtvalueR t error_typeRtfailedt min_allowedt max_allowed((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt range_checkFs      tValidationErrorscBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs g|_dS(N(t_errors(R((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt__init__ZscCs|jr tStS(N(R.RR(R((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR]s cCs=g}x'|jD]}|j|j|ƒƒqWdj|ƒS(Ns (R.tappendt _format_errortjoin(Rterror_messagesterror((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR bscCsM|\}}}|j|ƒ}|dkr<d||dfS|dkrjd||ddj|dƒfS|d kr«d ||d tt|d ƒƒdj|d ƒfS|d krë|dd}|dd}d||d ||fS|dkr+|dd}|dd}d||d ||fS|dkrId||dfSdS(Nsmissing required fields&Missing required parameter in %s: "%s"t required_names unknown fields1Unknown parameter in %s: "%s", must be one of: %st unknown_params, t valid_namess invalid typesCInvalid type for parameter %s, value: %s, type: %s, valid types: %sRRs invalid rangeR"iis=Invalid range for parameter %s, value: %s, valid range: %s-%ssinvalid lengths>Invalid length for parameter %s, value: %s, valid range: %s-%ssunable to encode to jsons2Invalid parameter %s must be json serializable: %st type_error(t _get_nameR2tstrttype(RR4R(Rt additionalR*R+((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR1hs:            cCs)|s dS|jdƒr!|dS|SdS(Ntinputt.i(t startswith(RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR9‡s cKs|jj|||fƒdS(N(R.R0(RRtreasontkwargs((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyRs(t__name__t __module__R/RR R1R9R(((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR-Ys      RcBs;eZdZd„Zd„Zd„Zd„Zedefƒd„ƒZ ede j ƒd„ƒZ ede efƒd„ƒZedefƒd „ƒZede jƒd „ƒZd „Zedefƒd „ƒZedeejfe jƒd „ƒZeZede jƒd„ƒZd„Zd„ZRS(s+Validates parameters against a shape model.cCs&tƒ}|j|||ddƒ|S(sÞValidate parameters against a shape model. This method will validate the parameters against a provided shape model. All errors will be collected before returning to the caller. This means that this method will not stop at the first error, it will return all possible errors. :param params: User provided dict of parameters :param shape: A shape model describing the expected input. :return: A list of errors. Rt(R-t _validate(RR R R((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR–s cCst|ƒr|jSdS(N(Rt_validate_jsonvalue_string(RR ((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_check_special_validation_cases¨s cCsR|j|ƒ}|r+|||||ƒn#t|d|jƒ||||ƒdS(Ns _validate_%s(RGtgetattrt type_name(RR R RRtspecial_validator((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyRE¬s cCsGytj|ƒWn/ttfk rB}|j|dd|ƒnXdS(Nsunable to encode to jsonR8(tjsontdumpst ValueErrort TypeErrorR(RR R RRte((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyRF´sRc CséxH|jjdgƒD]1}||kr|j|dd|d|ƒqqW|j}g}xL|D]D}||kr˜|j|dd|dt|ƒƒqa|j|ƒqaWx9|D]1}|j|||j||d||fƒq°WdS( Ntrequiredsmissing required fieldR5t user_paramss unknown fieldR6R7s%s.%s(R$R&RtmemberstlistR0RE( RR R RRtrequired_memberRRt known_paramsR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_structure¼s     cCs t|t|ƒ|d|ƒdS(Nsinvalid length(R,tlen(RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_stringÑs cCsf|j}t|t|ƒ|d|ƒx:t|ƒD],\}}|j|||d||fƒq2WdS(Nsinvalid lengths%s[%s](tmemberR,RWt enumerateRE(RRR RRt member_shapetititem((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_listÝs c Css|j}|j}xZ|jƒD]L\}}|j|||d||fƒ|j|||d||fƒqWdS(Ns %s (key: %s)s%s.%s(tkeyR'titemsRE( RRR RRt key_shapet value_shapeR_R'((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt _validate_mapäs   cCst|||d|ƒdS(Ns invalid range(R,(RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_integerísc Csgt|tttjfƒrdSt|dƒr2dS|j|dd|dttƒttƒdgƒdS(Ntreads invalid typeRRsfile-like object(Rtbytest bytearrayRRR%RR:(RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_blobñscCsdS(N((RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_booleanüscCst|||d|ƒdS(Ns invalid range(R,(RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_doublescCst|||d|ƒdS(Ns invalid range(R,(RRR RR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_longscCsM|j|ƒ}|sItjtƒdg}|j|dd|d|ƒndS(Nstimestamp-strings invalid typeRR(t_type_check_datetimeRRRR(RRR RRt is_valid_typeR((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyt_validate_timestamp s cCs4yt|ƒtSWntttfk r/tSXdS(N(RRRNRMtAttributeErrorR(RR'((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyRls  (RBRCt__doc__RRGRERFRtdictRVRt string_typesRXRSttupleR^Rct integer_typesRdRhtboolRiR#tdecimaltDecimalRjt_validate_floatRkRnRl(((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR“s"       ( tParamValidationDecoratorcBseZd„Zd„ZRS(cCs||_||_dS(N(t_param_validatort _serializer(Rtparam_validatort serializer((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR/s cCsg|j}|dk rT|jj||jƒ}|jƒrTtd|jƒƒ‚qTn|jj||ƒS(NR( t input_shapetNoneRzRRRR R{tserialize_to_request(Rt parameterstoperation_modelR~R((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyR€#s      (RBRCR/R€(((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyRys (Rptbotocore.compatRRvRKRtbotocore.utilsRRtbotocore.exceptionsRR RR,tobjectR-RRy(((s5/tmp/pip-install-usGedi/botocore/botocore/validate.pyts     :‹