3 D\@s<dZddlmZddlmZddlmZGdddeZdS)a Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. )CloudFormationLintRule) RuleMatch)RESOURCE_SPECSc@sReZdZdZdZdZdZdZdddgZdd Z d d Z d d Z ddZ ddZ dS) AllowedValuez&Check if properties have a valid valueZE3030z=Check if properties have a valid value in case of an enumatorzqhttps://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedvalue resourcespropertyz allowed valuecCs\x*tj|jdjdD]}|jj|qWx*tj|jdjdD]}|jj|qDWdS)zInitialize the ruler ResourceTypes PropertyTypesN)rgetregionsZresource_property_typesappendZresource_sub_property_types)selfcfnZresource_type_specZproperty_type_specr/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/properties/AllowedValue.py initializeszAllowedValue.initializecKsVg}|jdijdi}|rRdt|krRt||krRd}|jt||j||||S)z Check Value value_specsZ AllowedValuesz {{resolve:zBYou must specify a valid value for {0} ({1}). Valid values are {2})r strr rformat)r valuepath property_namekwargsmatchesZallowed_value_specsmessagerrr check_value&s  zAllowedValue.check_valuec Cst}x|j|ddD]\}}x|D]} | |kr(|j| jdi} | r(| jdd} |jdj| jd} |j|j|| ||jtj|jdjdj| i|| | d q(WqW|S) z Check itselfNValueZ ValueType PropertiesTyperZ ValueTypes)rrr property_typer)listZ items_safer extendrrr ) r r propertiesrproperty_specsrrZp_valuep_pathproprZ value_typer rrrcheck8s  zAllowedValue.checkcCsdt}tj|jdjdj|ijdi}tj|jdjdj|}|j|j||||||S)zMatch for sub propertiesrr r)r!rr r r"r')r r#r rrrspecsr$rrrmatch_resource_sub_propertiesMs &z*AllowedValue.match_resource_sub_propertiescCsdt}tj|jdjdj|ijdi}tj|jdjdj|}|j|j||||||S)zCheck CloudFormation Propertiesrrr)r!rr r r"r')r r#Z resource_typerrrr(Zresource_specsrrrmatch_resource_propertiesWs &z&AllowedValue.match_resource_propertiesN)__name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrrr'r)r*rrrrrs  rN)r.ZcfnlintrrZcfnlint.helpersrrrrrrs