ó 9(Zc@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((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pytvalidate_parameterss  cs‡fd†}|S(Ncs%‡‡fd†}‡fd†‰|S(Ncs,ˆ|||ƒr(ˆ|||||ƒSdS(N((tselftparamR terrorstname(t _type_checktfunc(s3/tmp/pip-build-wDUJoH/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(s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR:s "((RR(R(RRs3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_create_type_check_guard5s((RR((Rs3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt type_check4scCst}tdƒ}tdƒ}d|jkrR|jd}||krRt}qRn|r}|j||d|d||gƒndS(Ns-inftinftminRt valid_range(RtfloattmetadataRR(RtvalueR t error_typeRtfailedt min_allowedt max_allowed((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt range_checkFs     tValidationErrorscBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs g|_dS(N(t_errors(R((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt__init__TscCs|jr tStS(N(R*RR(R((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRWs cCs=g}x'|jD]}|j|j|ƒƒqWdj|ƒS(Ns (R*tappendt _format_errortjoin(Rterror_messagesterror((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR \scCsM|\}}}|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_nameR.tstrttype(RR0R$Rt additionalR&R'((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR-bs:            cCs)|s dS|jdƒr!|dS|SdS(Ntinputt.i(t startswith(RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR5s cKs|jj|||fƒdS(N(R*R,(RRtreasontkwargs((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR‰s(t__name__t __module__R+RR R-R5R(((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR)Ss      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((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRs cCst|ƒr|jSdS(N(Rt_validate_jsonvalue_string(RR ((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_check_special_validation_cases¢s cCsR|j|ƒ}|r+|||||ƒn#t|d|jƒ||||ƒdS(Ns _validate_%s(RCtgetattrt type_name(RR R RRtspecial_validator((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRA¦s cCsGytj|ƒWn/ttfk rB}|j|dd|ƒnXdS(Nsunable to encode to jsonR4(tjsontdumpst ValueErrort TypeErrorR(RR R RRte((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRB®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 fieldR1t user_paramss unknown fieldR2R3s%s.%s(R"tgetRtmemberstlistR,RA( RR R RRtrequired_memberROt known_paramsR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_structure¶s     cCs t|t|ƒ|d|ƒdS(Nsinvalid length(R(tlen(RRR RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_stringËs cCsf|j}t|t|ƒ|d|ƒx:t|ƒD],\}}|j|||d||fƒq2WdS(Nsinvalid lengths%s[%s](tmemberR(RTt enumerateRA(RRR RRt member_shapetititem((s3/tmp/pip-build-wDUJoH/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#titemsRA( RRR RRt key_shapet value_shapeR\R#((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt _validate_mapÞs   cCst|||d|ƒdS(Ns invalid range(R((RRR RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_integerçsc Csgt|tttjfƒrdSt|dƒr2dS|j|dd|dttƒttƒdgƒdS(Ntreads invalid typeRRsfile-like object(Rtbytest bytearrayRRthasattrRR6(RRR RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_blobëscCsdS(N((RRR RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_booleanöscCst|||d|ƒdS(Ns invalid range(R((RRR RR((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_doubleúscCst|||d|ƒdS(Ns invalid range(R((RRR RR((s3/tmp/pip-build-wDUJoH/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((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyt_validate_timestamps cCs4yt|ƒtSWntttfk r/tSXdS(N(RRRJRItAttributeErrorR(RR#((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRjs  (R>R?t__doc__RRCRARBRtdictRSRt string_typesRURPttupleR[R`t integer_typesRaRftboolRgR!tdecimaltDecimalRht_validate_floatRiRlRj(((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRs"       ( tParamValidationDecoratorcBseZd„Zd„ZRS(cCs||_||_dS(N(t_param_validatort _serializer(Rtparam_validatort serializer((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR+s cCsg|j}|dk rT|jj||jƒ}|jƒrTtd|jƒƒ‚qTn|jj||ƒS(NR( t input_shapetNoneRxRRRR Rytserialize_to_request(Rt parameterstoperation_modelR|R((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyR~s      (R>R?R+R~(((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyRws (Rntbotocore.compatRRtRGRtbotocore.utilsRRtbotocore.exceptionsRR RR(tobjectR)RRw(((s3/tmp/pip-build-wDUJoH/botocore/botocore/validate.pyts     :‹