packages feed

stratosphere-0.23.0: library-gen/Stratosphere/ResourceProperties/BudgetsBudgetTimePeriod.hs

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

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-budgets-budget-timeperiod.html

module Stratosphere.ResourceProperties.BudgetsBudgetTimePeriod where

import Stratosphere.ResourceImports


-- | Full data type definition for BudgetsBudgetTimePeriod. See
-- 'budgetsBudgetTimePeriod' for a more convenient constructor.
data BudgetsBudgetTimePeriod =
  BudgetsBudgetTimePeriod
  { _budgetsBudgetTimePeriodEnd :: Maybe (Val Text)
  , _budgetsBudgetTimePeriodStart :: Maybe (Val Text)
  } deriving (Show, Eq)

instance ToJSON BudgetsBudgetTimePeriod where
  toJSON BudgetsBudgetTimePeriod{..} =
    object $
    catMaybes
    [ fmap (("End",) . toJSON) _budgetsBudgetTimePeriodEnd
    , fmap (("Start",) . toJSON) _budgetsBudgetTimePeriodStart
    ]

instance FromJSON BudgetsBudgetTimePeriod where
  parseJSON (Object obj) =
    BudgetsBudgetTimePeriod <$>
      (obj .:? "End") <*>
      (obj .:? "Start")
  parseJSON _ = mempty

-- | Constructor for 'BudgetsBudgetTimePeriod' containing required fields as
-- arguments.
budgetsBudgetTimePeriod
  :: BudgetsBudgetTimePeriod
budgetsBudgetTimePeriod  =
  BudgetsBudgetTimePeriod
  { _budgetsBudgetTimePeriodEnd = Nothing
  , _budgetsBudgetTimePeriodStart = Nothing
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-budgets-budget-timeperiod.html#cfn-budgets-budget-timeperiod-end
bbtpEnd :: Lens' BudgetsBudgetTimePeriod (Maybe (Val Text))
bbtpEnd = lens _budgetsBudgetTimePeriodEnd (\s a -> s { _budgetsBudgetTimePeriodEnd = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-budgets-budget-timeperiod.html#cfn-budgets-budget-timeperiod-start
bbtpStart :: Lens' BudgetsBudgetTimePeriod (Maybe (Val Text))
bbtpStart = lens _budgetsBudgetTimePeriodStart (\s a -> s { _budgetsBudgetTimePeriodStart = a })