packages feed

stratosphere-0.11.0: library-gen/Stratosphere/ResourceProperties/SSMPatchBaselineRuleGroup.hs

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

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ssm-patchbaseline-rulegroup.html

module Stratosphere.ResourceProperties.SSMPatchBaselineRuleGroup where

import Control.Lens hiding ((.=))
import Data.Aeson
import Data.Maybe (catMaybes)
import Data.Monoid (mempty)
import Data.Text

import Stratosphere.Values
import Stratosphere.ResourceProperties.SSMPatchBaselineRule

-- | Full data type definition for SSMPatchBaselineRuleGroup. See
-- 'ssmPatchBaselineRuleGroup' for a more convenient constructor.
data SSMPatchBaselineRuleGroup =
  SSMPatchBaselineRuleGroup
  { _sSMPatchBaselineRuleGroupPatchRules :: Maybe [SSMPatchBaselineRule]
  } deriving (Show, Eq)

instance ToJSON SSMPatchBaselineRuleGroup where
  toJSON SSMPatchBaselineRuleGroup{..} =
    object $
    catMaybes
    [ fmap (("PatchRules",) . toJSON) _sSMPatchBaselineRuleGroupPatchRules
    ]

instance FromJSON SSMPatchBaselineRuleGroup where
  parseJSON (Object obj) =
    SSMPatchBaselineRuleGroup <$>
      (obj .:? "PatchRules")
  parseJSON _ = mempty

-- | Constructor for 'SSMPatchBaselineRuleGroup' containing required fields as
-- arguments.
ssmPatchBaselineRuleGroup
  :: SSMPatchBaselineRuleGroup
ssmPatchBaselineRuleGroup  =
  SSMPatchBaselineRuleGroup
  { _sSMPatchBaselineRuleGroupPatchRules = Nothing
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ssm-patchbaseline-rulegroup.html#cfn-ssm-patchbaseline-rulegroup-patchrules
ssmpbrgPatchRules :: Lens' SSMPatchBaselineRuleGroup (Maybe [SSMPatchBaselineRule])
ssmpbrgPatchRules = lens _sSMPatchBaselineRuleGroupPatchRules (\s a -> s { _sSMPatchBaselineRuleGroupPatchRules = a })