3 D\ @s0dZddlmZddlmZGdddeZdS)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) RuleMatchcsLeZdZdZdZdZdZdZddgZdZ fd d Z d d Z d dZ Z S)RuleTargetsLimitzCheck State Machine DefinitionZE3021z5Check Events Rule Targets are less than or equal to 5z7CloudWatch Events Rule can only support up to 5 targetszUhttps://docs.aws.amazon.com/AmazonCloudWatch/latest/events/cloudwatch_limits_cwe.html resourceseventscs tt|jdg|_i|_dS)ZInitzAWS::Events::RuleN)superr__init__Zresource_property_typeslimits)self) __class__/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/cfn-lint/cfnlint/rules/resources/events/RuleTargetsLimit.pyr szRuleTargetsLimit.__init__cCsp|d}t|dkr4|ddkr4d|d|df}||jkrVd|dd d|j|<|j|d d7<gS) zCount them up zFn::Ifz%s.%srrN)countpathr)lenr )r valuer resource_namer r r check_value%s   zRuleTargetsLimit.check_valuecCspg}|j|j|d|dd|jdxD|jjD]6\}}|d|jkr2d}|jt|d|j|jq2W|S)zCheck CloudFormation PropertiesZTargetsN)objkeyrrrz)An Events Rule can have up to {0} Targetsr)extendrr items max_countappendrformat)r Z properties_rZcfnmatcheslimitmessager r rmatch_resource_properties6s   z*RuleTargetsLimit.match_resource_properties)__name__ __module__ __qualname____doc__idZ shortdesc descriptionZ source_urltagsrr rr# __classcell__r r )r rrs rN)r'Zcfnlintrrrr r r rs