>ac@sdZddlmZddlZddlZddlmZddlmZddlmZddl m Z dZ d Z d Z d efd YZd efdYZdefdYZdS(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||}|jr?td|jndS(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((s2/usr/lib/fence-agents/bundled/botocore/validate.pytvalidate_parameterss  csfd}|S(Ncs%fd}fd|S(Ncs,|||r(|||||SdS(N((tselftparamR terrorstname(t _type_checktfunc(s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_on_passes_type_check6scsUt|sQgD]}tj|^q}|j|dd|d|tStS(Ns invalid typeRt valid_types(t isinstanceRt text_typeRtFalsetTrue(RRRtttvalid_type_names(R(s2/usr/lib/fence-agents/bundled/botocore/validate.pyR:s "((RR(R(RRs2/usr/lib/fence-agents/bundled/botocore/validate.pyt_create_type_check_guard5s((RR((Rs2/usr/lib/fence-agents/bundled/botocore/validate.pyt type_check4scCst}td}d|jkrF|jd}||krt}qnBt|dr|jjdrd}||krt}qqn|r|j||d|d|ndS(Ns-inftmint serializationt hostLabeliRt min_allowed(RtfloattmetadataRthasattrRtgetR(RtvalueR t error_typeRtfailedR!((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt range_checkFs     tValidationErrorscBs>eZdZdZdZdZdZdZRS(cCs g|_dS(N(t_errors(R((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt__init__XscCs|jr tStS(N(R+RR(R((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR[s cCs=g}x'|jD]}|j|j|qWdj|S(Ns (R+tappendt _format_errortjoin(Rterror_messagesterror((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR `scCs|\}}}|j|}|dkr<d||dfS|dkrjd||ddj|dfS|d krd ||d tt|d dj|d fS|d kr|d}d||d |fS|dkr|d}d||d |fS|dkrd||dfS|dkr`d||d tt|d dj|d fS|dkrd|dj|dfS|dkrd|dj|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!s>Invalid value for parameter %s, value: %s, valid min value: %ssinvalid lengths@Invalid length for parameter %s, value: %s, valid min length: %ssunable to encode to jsons2Invalid parameter %s must be json serializable: %st type_errorsinvalid type for documentsLInvalid type for document parameter %s, value: %s, type: %s, valid types: %ssmore than one inputskInvalid number of parameters set for tagged union structure %s. Can only set one of the following keys: %s.s. tmemberss empty inputsDMust set one of the following keys for tagged unionstructure %s: %s.(t _get_nameR/tstrttype(RR1R'Rt additionalR!((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR.fsJ             cCs)|s dS|jdr!|dS|SdS(Ntinputt.i(t startswith(RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR7s cKs|jj|||fdS(N(R+R-(RRtreasontkwargs((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRs(t__name__t __module__R,RR R.R7R(((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR*Ws     C RcBsDeZdZdZdZdZdZdZede fdZ ede j dZ edeefd Zede fd Zede jd Zd Zedefd Zedeejfe jdZeZede jdZdZdZRS(s+Validates parameters against a shape model.cCs&t}|j|||dd|S(sValidate 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((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRs cCs6t|r|jS|jdkr2|jr2|jSdS(Nt structure(Rt_validate_jsonvalue_stringt type_nametis_document_typet_validate_document(RR ((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_check_special_validation_casess cCsR|j|}|r+|||||n#t|d|j||||dS(Ns _validate_%s(RItgetattrRF(RR R RRtspecial_validator((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRCs cCsGytj|Wn/ttfk rB}|j|dd|nXdS(Nsunable to encode to jsonR5(tjsontdumpst ValueErrort TypeErrorR(RR R RRte((s2/usr/lib/fence-agents/bundled/botocore/validate.pyREsc Cs#|dkrdSt|trMx|D] }|j|||||q&Wnt|trxt|D],\}}|j|||d||fqiWnt|tjtt t fst tt t ttf}g|D]} tj | ^q} |j |dd|dt|d| ndS(Ns%s[%d]sinvalid type for documentRt param_typeR(tNoneRtdictRHtlistt enumerateRt string_typestinttboolR"R8RRR9( RR R RRtkeytindextentityRRR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRHs   !" Rc CsQ|jrht|dkr7|j|dd|jqht|dkrh|j|dd|jqhnxH|jjdgD]1}||kr~|j|dd|d |q~q~W|j}g}xL|D]D}||kr|j|d d |d t|q|j|qWx9|D]1}|j|||j||d ||fqWdS(Nis empty inputR6ismore than one inputtrequiredsmissing required fieldR2t user_paramss unknown fieldR3R4s%s.%s( tis_tagged_uniontlenRR6R#R%RTR-RC( RR R RRtrequired_memberR6t known_paramsR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_structures(      cCs t|t||d|dS(Nsinvalid length(R)R_(RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_strings cCsf|j}t|t||d|x:t|D],\}}|j|||d||fq2WdS(Nsinvalid lengths%s[%s](tmemberR)R_RURC(RRR RRt member_shapetititem((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_lists c Css|j}|j}xZ|jD]L\}}|j|||d||f|j|||d||fqWdS(Ns %s (key: %s)s%s.%s(RYR&titemsRC( RRR RRt key_shapet value_shapeRYR&((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt _validate_map#s   cCst|||d|dS(Ns invalid range(R)(RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_integer,sc Csgt|tttjfrdSt|dr2dS|j|dd|dttttdgdS(Ntreads invalid typeRRsfile-like object(Rtbytest bytearrayRRR$RR8(RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_blob0scCsdS(N((RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_boolean;scCst|||d|dS(Ns invalid range(R)(RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_double?scCst|||d|dS(Ns invalid range(R)(RRR RR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_longEscCsM|j|}|sItjtdg}|j|dd|d|ndS(Nstimestamp-strings invalid typeRR(t_type_check_datetimeRRRR(RRR RRt is_valid_typeR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyt_validate_timestampIs cCs4yt|tSWntttfk r/tSXdS(N(RRRORNtAttributeErrorR(RR&((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRuSs  (R@RAt__doc__RRIRCRERHRRSRbRRVRcRTttupleRhRlt integer_typesRmRqRXRrR"tdecimaltDecimalRst_validate_floatRtRwRu(((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRs$        ( tParamValidationDecoratorcBseZdZdZRS(cCs||_||_dS(N(t_param_validatort _serializer(Rtparam_validatort serializer((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR,^s cCsg|j}|dk rT|jj||j}|jrTtd|jqTn|jj||S(NR( t input_shapeRRRRRRR Rtserialize_to_request(Rt parameterstoperation_modelRR((s2/usr/lib/fence-agents/bundled/botocore/validate.pyRbs      (R@RAR,R(((s2/usr/lib/fence-agents/bundled/botocore/validate.pyR]s (Rytbotocore.compatRR|RLRtbotocore.utilsRRtbotocore.exceptionsRR RR)tobjectR*RR(((s2/usr/lib/fence-agents/bundled/botocore/validate.pyts     ^