packages feed

stratosphere-0.15.2: library-gen/Stratosphere/Resources/WAFRegionalIPSet.hs

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafregional-ipset.html

module Stratosphere.Resources.WAFRegionalIPSet where

import Stratosphere.ResourceImports
import Stratosphere.ResourceProperties.WAFRegionalIPSetIPSetDescriptor

-- | Full data type definition for WAFRegionalIPSet. See 'wafRegionalIPSet'
-- for a more convenient constructor.
data WAFRegionalIPSet =
  WAFRegionalIPSet
  { _wAFRegionalIPSetIPSetDescriptors :: Maybe [WAFRegionalIPSetIPSetDescriptor]
  , _wAFRegionalIPSetName :: Val Text
  } deriving (Show, Eq)

instance ToJSON WAFRegionalIPSet where
  toJSON WAFRegionalIPSet{..} =
    object $
    catMaybes
    [ fmap (("IPSetDescriptors",) . toJSON) _wAFRegionalIPSetIPSetDescriptors
    , (Just . ("Name",) . toJSON) _wAFRegionalIPSetName
    ]

instance FromJSON WAFRegionalIPSet where
  parseJSON (Object obj) =
    WAFRegionalIPSet <$>
      (obj .:? "IPSetDescriptors") <*>
      (obj .: "Name")
  parseJSON _ = mempty

-- | Constructor for 'WAFRegionalIPSet' containing required fields as
-- arguments.
wafRegionalIPSet
  :: Val Text -- ^ 'wafripsName'
  -> WAFRegionalIPSet
wafRegionalIPSet namearg =
  WAFRegionalIPSet
  { _wAFRegionalIPSetIPSetDescriptors = Nothing
  , _wAFRegionalIPSetName = namearg
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafregional-ipset.html#cfn-wafregional-ipset-ipsetdescriptors
wafripsIPSetDescriptors :: Lens' WAFRegionalIPSet (Maybe [WAFRegionalIPSetIPSetDescriptor])
wafripsIPSetDescriptors = lens _wAFRegionalIPSetIPSetDescriptors (\s a -> s { _wAFRegionalIPSetIPSetDescriptors = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafregional-ipset.html#cfn-wafregional-ipset-name
wafripsName :: Lens' WAFRegionalIPSet (Val Text)
wafripsName = lens _wAFRegionalIPSetName (\s a -> s { _wAFRegionalIPSetName = a })