3 D\@s8dZddlmZddlmZddlZGdddeZdS)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) RuleMatchNcsNeZdZdZdZdZdZdZdgZfdd Z d d Z d d Z ddZ Z S) Inclusivez'Check Properties Resource ConfigurationZE2521z+Check Properties that are required togetherz-Make sure CloudFormation resource properties z#are included together when requiredz5https://github.com/aws-cloudformation/cfn-python-lint resourcescsjtt|jtjjd}|d|_|d|_x|jD]}|jj |q6Wx|jD]}|j j |qRWdS)ZInitz#data/AdditionalSpecs/Inclusive.jsonZ ResourceTypesZ PropertyTypesN) superr__init__cfnlintZhelpersZload_resourcesresource_types_specsproperty_types_specsZresource_property_typesappendZresource_sub_property_types)selfZ inclusivespecZresource_type_specZproperty_type_spec) __class__/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/properties/Inclusive.pyrs     zInclusive.__init__c Csg}|s |S|j|}x|D]}x|dD]}||kr*x||D]} | |dkr@|ddkrd} |jt|| j| |djtt|q@djdd|djD} d } |jt|| j| || djtt|q@Wq*WqW|S) z Check itselfZObjectZScenarioNz*Property {0} should exist with {1} for {2}/z and cSsg|]\}}d||fqS)zwhen condition "%s" is %sr).0kvrrr =sz#Inclusive.check..z.Property {0} should exist with {1} {2} for {3})Zget_object_without_conditionsr rformatjoinmapstritems) r properties inclusionspathcfnmatchesZ property_setsZ property_setpropZ incl_propertymessageZ scenario_textrrrcheck*s(     ,zInclusive.checkcCs,g}|jj|i}|j|j|||||S)zMatch for sub properties)r getextendr!)r rZ property_typerrrrrrrmatch_resource_sub_propertiesFsz'Inclusive.match_resource_sub_propertiescCs,g}|jj|i}|j|j|||||S)zCheck CloudFormation Properties)r r"r#r!)r rZ resource_typerrrrrrrmatch_resource_propertiesOsz#Inclusive.match_resource_propertieszPMake sure CloudFormation resource properties are included together when required)__name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrr!r$r% __classcell__rr)r rrs  r)r)rrrZcfnlint.helpersrrrrrs