{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Budgets.Types.Budget
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Budgets.Types.Budget where

import Amazonka.Budgets.Types.BudgetType
import Amazonka.Budgets.Types.CalculatedSpend
import Amazonka.Budgets.Types.CostTypes
import Amazonka.Budgets.Types.Spend
import Amazonka.Budgets.Types.TimePeriod
import Amazonka.Budgets.Types.TimeUnit
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the output of the @CreateBudget@ operation. The content
-- consists of the detailed metadata and data file information, and the
-- current status of the @budget@ object.
--
-- This is the ARN pattern for a budget:
--
-- @arn:aws:budgets::AccountId:budget\/budgetName@
--
-- /See:/ 'newBudget' smart constructor.
data Budget = Budget'
  { -- | The actual and forecasted cost or usage that the budget tracks.
    Budget -> Maybe CalculatedSpend
calculatedSpend :: Prelude.Maybe CalculatedSpend,
    -- | A map containing multiple @BudgetLimit@, including current or future
    -- limits.
    --
    -- @PlannedBudgetLimits@ is available for cost or usage budget and supports
    -- monthly and quarterly @TimeUnit@.
    --
    -- For monthly budgets, provide 12 months of @PlannedBudgetLimits@ values.
    -- This must start from the current month and include the next 11 months.
    -- The @key@ is the start of the month, @UTC@ in epoch seconds.
    --
    -- For quarterly budgets, provide 4 quarters of @PlannedBudgetLimits@ value
    -- entries in standard calendar quarter increments. This must start from
    -- the current quarter and include the next 3 quarters. The @key@ is the
    -- start of the quarter, @UTC@ in epoch seconds.
    --
    -- If the planned budget expires before 12 months for monthly or 4 quarters
    -- for quarterly, provide the @PlannedBudgetLimits@ values only for the
    -- remaining periods.
    --
    -- If the budget begins at a date in the future, provide
    -- @PlannedBudgetLimits@ values from the start date of the budget.
    --
    -- After all of the @BudgetLimit@ values in @PlannedBudgetLimits@ are used,
    -- the budget continues to use the last limit as the @BudgetLimit@. At that
    -- point, the planned budget provides the same experience as a fixed
    -- budget.
    --
    -- @DescribeBudget@ and @DescribeBudgets@ response along with
    -- @PlannedBudgetLimits@ will also contain @BudgetLimit@ representing the
    -- current month or quarter limit present in @PlannedBudgetLimits@. This
    -- only applies to budgets created with @PlannedBudgetLimits@. Budgets
    -- created without @PlannedBudgetLimits@ will only contain @BudgetLimit@,
    -- and no @PlannedBudgetLimits@.
    Budget -> Maybe (HashMap Text Spend)
plannedBudgetLimits :: Prelude.Maybe (Prelude.HashMap Prelude.Text Spend),
    -- | The last time that you updated this budget.
    Budget -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Core.POSIX,
    -- | The total amount of cost, usage, RI utilization, RI coverage, Savings
    -- Plans utilization, or Savings Plans coverage that you want to track with
    -- your budget.
    --
    -- @BudgetLimit@ is required for cost or usage budgets, but optional for RI
    -- or Savings Plans utilization or coverage budgets. RI and Savings Plans
    -- utilization or coverage budgets default to @100@, which is the only
    -- valid value for RI or Savings Plans utilization or coverage budgets. You
    -- can\'t use @BudgetLimit@ with @PlannedBudgetLimits@ for @CreateBudget@
    -- and @UpdateBudget@ actions.
    Budget -> Maybe Spend
budgetLimit :: Prelude.Maybe Spend,
    -- | The period of time that is covered by a budget. The period has a start
    -- date and an end date. The start date must come before the end date. The
    -- end date must come before @06\/15\/87 00:00 UTC@.
    --
    -- If you create your budget and don\'t specify a start date, AWS defaults
    -- to the start of your chosen time period (DAILY, MONTHLY, QUARTERLY, or
    -- ANNUALLY). For example, if you created your budget on January 24, 2018,
    -- chose @DAILY@, and didn\'t set a start date, AWS set your start date to
    -- @01\/24\/18 00:00 UTC@. If you chose @MONTHLY@, AWS set your start date
    -- to @01\/01\/18 00:00 UTC@. If you didn\'t specify an end date, AWS set
    -- your end date to @06\/15\/87 00:00 UTC@. The defaults are the same for
    -- the AWS Billing and Cost Management console and the API.
    --
    -- You can change either date with the @UpdateBudget@ operation.
    --
    -- After the end date, AWS deletes the budget and all associated
    -- notifications and subscribers.
    Budget -> Maybe TimePeriod
timePeriod :: Prelude.Maybe TimePeriod,
    -- | The types of costs that are included in this @COST@ budget.
    --
    -- @USAGE@, @RI_UTILIZATION@, @RI_COVERAGE@, @SAVINGS_PLANS_UTILIZATION@,
    -- and @SAVINGS_PLANS_COVERAGE@ budgets do not have @CostTypes@.
    Budget -> Maybe CostTypes
costTypes :: Prelude.Maybe CostTypes,
    -- | The cost filters, such as service or tag, that are applied to a budget.
    --
    -- AWS Budgets supports the following services as a filter for RI budgets:
    --
    -- -   Amazon Elastic Compute Cloud - Compute
    --
    -- -   Amazon Redshift
    --
    -- -   Amazon Relational Database Service
    --
    -- -   Amazon ElastiCache
    --
    -- -   Amazon Elasticsearch Service
    Budget -> Maybe (HashMap Text [Text])
costFilters :: Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]),
    -- | The name of a budget. The name must be unique within an account. The @:@
    -- and @\\@ characters aren\'t allowed in @BudgetName@.
    Budget -> Text
budgetName :: Prelude.Text,
    -- | The length of time until a budget resets the actual and forecasted
    -- spend.
    Budget -> TimeUnit
timeUnit :: TimeUnit,
    -- | Whether this budget tracks costs, usage, RI utilization, RI coverage,
    -- Savings Plans utilization, or Savings Plans coverage.
    Budget -> BudgetType
budgetType :: BudgetType
  }
  deriving (Budget -> Budget -> Bool
(Budget -> Budget -> Bool)
-> (Budget -> Budget -> Bool) -> Eq Budget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Budget -> Budget -> Bool
$c/= :: Budget -> Budget -> Bool
== :: Budget -> Budget -> Bool
$c== :: Budget -> Budget -> Bool
Prelude.Eq, ReadPrec [Budget]
ReadPrec Budget
Int -> ReadS Budget
ReadS [Budget]
(Int -> ReadS Budget)
-> ReadS [Budget]
-> ReadPrec Budget
-> ReadPrec [Budget]
-> Read Budget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Budget]
$creadListPrec :: ReadPrec [Budget]
readPrec :: ReadPrec Budget
$creadPrec :: ReadPrec Budget
readList :: ReadS [Budget]
$creadList :: ReadS [Budget]
readsPrec :: Int -> ReadS Budget
$creadsPrec :: Int -> ReadS Budget
Prelude.Read, Int -> Budget -> ShowS
[Budget] -> ShowS
Budget -> String
(Int -> Budget -> ShowS)
-> (Budget -> String) -> ([Budget] -> ShowS) -> Show Budget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Budget] -> ShowS
$cshowList :: [Budget] -> ShowS
show :: Budget -> String
$cshow :: Budget -> String
showsPrec :: Int -> Budget -> ShowS
$cshowsPrec :: Int -> Budget -> ShowS
Prelude.Show, (forall x. Budget -> Rep Budget x)
-> (forall x. Rep Budget x -> Budget) -> Generic Budget
forall x. Rep Budget x -> Budget
forall x. Budget -> Rep Budget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Budget x -> Budget
$cfrom :: forall x. Budget -> Rep Budget x
Prelude.Generic)

-- |
-- Create a value of 'Budget' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'calculatedSpend', 'budget_calculatedSpend' - The actual and forecasted cost or usage that the budget tracks.
--
-- 'plannedBudgetLimits', 'budget_plannedBudgetLimits' - A map containing multiple @BudgetLimit@, including current or future
-- limits.
--
-- @PlannedBudgetLimits@ is available for cost or usage budget and supports
-- monthly and quarterly @TimeUnit@.
--
-- For monthly budgets, provide 12 months of @PlannedBudgetLimits@ values.
-- This must start from the current month and include the next 11 months.
-- The @key@ is the start of the month, @UTC@ in epoch seconds.
--
-- For quarterly budgets, provide 4 quarters of @PlannedBudgetLimits@ value
-- entries in standard calendar quarter increments. This must start from
-- the current quarter and include the next 3 quarters. The @key@ is the
-- start of the quarter, @UTC@ in epoch seconds.
--
-- If the planned budget expires before 12 months for monthly or 4 quarters
-- for quarterly, provide the @PlannedBudgetLimits@ values only for the
-- remaining periods.
--
-- If the budget begins at a date in the future, provide
-- @PlannedBudgetLimits@ values from the start date of the budget.
--
-- After all of the @BudgetLimit@ values in @PlannedBudgetLimits@ are used,
-- the budget continues to use the last limit as the @BudgetLimit@. At that
-- point, the planned budget provides the same experience as a fixed
-- budget.
--
-- @DescribeBudget@ and @DescribeBudgets@ response along with
-- @PlannedBudgetLimits@ will also contain @BudgetLimit@ representing the
-- current month or quarter limit present in @PlannedBudgetLimits@. This
-- only applies to budgets created with @PlannedBudgetLimits@. Budgets
-- created without @PlannedBudgetLimits@ will only contain @BudgetLimit@,
-- and no @PlannedBudgetLimits@.
--
-- 'lastUpdatedTime', 'budget_lastUpdatedTime' - The last time that you updated this budget.
--
-- 'budgetLimit', 'budget_budgetLimit' - The total amount of cost, usage, RI utilization, RI coverage, Savings
-- Plans utilization, or Savings Plans coverage that you want to track with
-- your budget.
--
-- @BudgetLimit@ is required for cost or usage budgets, but optional for RI
-- or Savings Plans utilization or coverage budgets. RI and Savings Plans
-- utilization or coverage budgets default to @100@, which is the only
-- valid value for RI or Savings Plans utilization or coverage budgets. You
-- can\'t use @BudgetLimit@ with @PlannedBudgetLimits@ for @CreateBudget@
-- and @UpdateBudget@ actions.
--
-- 'timePeriod', 'budget_timePeriod' - The period of time that is covered by a budget. The period has a start
-- date and an end date. The start date must come before the end date. The
-- end date must come before @06\/15\/87 00:00 UTC@.
--
-- If you create your budget and don\'t specify a start date, AWS defaults
-- to the start of your chosen time period (DAILY, MONTHLY, QUARTERLY, or
-- ANNUALLY). For example, if you created your budget on January 24, 2018,
-- chose @DAILY@, and didn\'t set a start date, AWS set your start date to
-- @01\/24\/18 00:00 UTC@. If you chose @MONTHLY@, AWS set your start date
-- to @01\/01\/18 00:00 UTC@. If you didn\'t specify an end date, AWS set
-- your end date to @06\/15\/87 00:00 UTC@. The defaults are the same for
-- the AWS Billing and Cost Management console and the API.
--
-- You can change either date with the @UpdateBudget@ operation.
--
-- After the end date, AWS deletes the budget and all associated
-- notifications and subscribers.
--
-- 'costTypes', 'budget_costTypes' - The types of costs that are included in this @COST@ budget.
--
-- @USAGE@, @RI_UTILIZATION@, @RI_COVERAGE@, @SAVINGS_PLANS_UTILIZATION@,
-- and @SAVINGS_PLANS_COVERAGE@ budgets do not have @CostTypes@.
--
-- 'costFilters', 'budget_costFilters' - The cost filters, such as service or tag, that are applied to a budget.
--
-- AWS Budgets supports the following services as a filter for RI budgets:
--
-- -   Amazon Elastic Compute Cloud - Compute
--
-- -   Amazon Redshift
--
-- -   Amazon Relational Database Service
--
-- -   Amazon ElastiCache
--
-- -   Amazon Elasticsearch Service
--
-- 'budgetName', 'budget_budgetName' - The name of a budget. The name must be unique within an account. The @:@
-- and @\\@ characters aren\'t allowed in @BudgetName@.
--
-- 'timeUnit', 'budget_timeUnit' - The length of time until a budget resets the actual and forecasted
-- spend.
--
-- 'budgetType', 'budget_budgetType' - Whether this budget tracks costs, usage, RI utilization, RI coverage,
-- Savings Plans utilization, or Savings Plans coverage.
newBudget ::
  -- | 'budgetName'
  Prelude.Text ->
  -- | 'timeUnit'
  TimeUnit ->
  -- | 'budgetType'
  BudgetType ->
  Budget
newBudget :: Text -> TimeUnit -> BudgetType -> Budget
newBudget Text
pBudgetName_ TimeUnit
pTimeUnit_ BudgetType
pBudgetType_ =
  Budget' :: Maybe CalculatedSpend
-> Maybe (HashMap Text Spend)
-> Maybe POSIX
-> Maybe Spend
-> Maybe TimePeriod
-> Maybe CostTypes
-> Maybe (HashMap Text [Text])
-> Text
-> TimeUnit
-> BudgetType
-> Budget
Budget'
    { $sel:calculatedSpend:Budget' :: Maybe CalculatedSpend
calculatedSpend = Maybe CalculatedSpend
forall a. Maybe a
Prelude.Nothing,
      $sel:plannedBudgetLimits:Budget' :: Maybe (HashMap Text Spend)
plannedBudgetLimits = Maybe (HashMap Text Spend)
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTime:Budget' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:budgetLimit:Budget' :: Maybe Spend
budgetLimit = Maybe Spend
forall a. Maybe a
Prelude.Nothing,
      $sel:timePeriod:Budget' :: Maybe TimePeriod
timePeriod = Maybe TimePeriod
forall a. Maybe a
Prelude.Nothing,
      $sel:costTypes:Budget' :: Maybe CostTypes
costTypes = Maybe CostTypes
forall a. Maybe a
Prelude.Nothing,
      $sel:costFilters:Budget' :: Maybe (HashMap Text [Text])
costFilters = Maybe (HashMap Text [Text])
forall a. Maybe a
Prelude.Nothing,
      $sel:budgetName:Budget' :: Text
budgetName = Text
pBudgetName_,
      $sel:timeUnit:Budget' :: TimeUnit
timeUnit = TimeUnit
pTimeUnit_,
      $sel:budgetType:Budget' :: BudgetType
budgetType = BudgetType
pBudgetType_
    }

-- | The actual and forecasted cost or usage that the budget tracks.
budget_calculatedSpend :: Lens.Lens' Budget (Prelude.Maybe CalculatedSpend)
budget_calculatedSpend :: (Maybe CalculatedSpend -> f (Maybe CalculatedSpend))
-> Budget -> f Budget
budget_calculatedSpend = (Budget -> Maybe CalculatedSpend)
-> (Budget -> Maybe CalculatedSpend -> Budget)
-> Lens
     Budget Budget (Maybe CalculatedSpend) (Maybe CalculatedSpend)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe CalculatedSpend
calculatedSpend :: Maybe CalculatedSpend
$sel:calculatedSpend:Budget' :: Budget -> Maybe CalculatedSpend
calculatedSpend} -> Maybe CalculatedSpend
calculatedSpend) (\s :: Budget
s@Budget' {} Maybe CalculatedSpend
a -> Budget
s {$sel:calculatedSpend:Budget' :: Maybe CalculatedSpend
calculatedSpend = Maybe CalculatedSpend
a} :: Budget)

-- | A map containing multiple @BudgetLimit@, including current or future
-- limits.
--
-- @PlannedBudgetLimits@ is available for cost or usage budget and supports
-- monthly and quarterly @TimeUnit@.
--
-- For monthly budgets, provide 12 months of @PlannedBudgetLimits@ values.
-- This must start from the current month and include the next 11 months.
-- The @key@ is the start of the month, @UTC@ in epoch seconds.
--
-- For quarterly budgets, provide 4 quarters of @PlannedBudgetLimits@ value
-- entries in standard calendar quarter increments. This must start from
-- the current quarter and include the next 3 quarters. The @key@ is the
-- start of the quarter, @UTC@ in epoch seconds.
--
-- If the planned budget expires before 12 months for monthly or 4 quarters
-- for quarterly, provide the @PlannedBudgetLimits@ values only for the
-- remaining periods.
--
-- If the budget begins at a date in the future, provide
-- @PlannedBudgetLimits@ values from the start date of the budget.
--
-- After all of the @BudgetLimit@ values in @PlannedBudgetLimits@ are used,
-- the budget continues to use the last limit as the @BudgetLimit@. At that
-- point, the planned budget provides the same experience as a fixed
-- budget.
--
-- @DescribeBudget@ and @DescribeBudgets@ response along with
-- @PlannedBudgetLimits@ will also contain @BudgetLimit@ representing the
-- current month or quarter limit present in @PlannedBudgetLimits@. This
-- only applies to budgets created with @PlannedBudgetLimits@. Budgets
-- created without @PlannedBudgetLimits@ will only contain @BudgetLimit@,
-- and no @PlannedBudgetLimits@.
budget_plannedBudgetLimits :: Lens.Lens' Budget (Prelude.Maybe (Prelude.HashMap Prelude.Text Spend))
budget_plannedBudgetLimits :: (Maybe (HashMap Text Spend) -> f (Maybe (HashMap Text Spend)))
-> Budget -> f Budget
budget_plannedBudgetLimits = (Budget -> Maybe (HashMap Text Spend))
-> (Budget -> Maybe (HashMap Text Spend) -> Budget)
-> Lens
     Budget
     Budget
     (Maybe (HashMap Text Spend))
     (Maybe (HashMap Text Spend))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe (HashMap Text Spend)
plannedBudgetLimits :: Maybe (HashMap Text Spend)
$sel:plannedBudgetLimits:Budget' :: Budget -> Maybe (HashMap Text Spend)
plannedBudgetLimits} -> Maybe (HashMap Text Spend)
plannedBudgetLimits) (\s :: Budget
s@Budget' {} Maybe (HashMap Text Spend)
a -> Budget
s {$sel:plannedBudgetLimits:Budget' :: Maybe (HashMap Text Spend)
plannedBudgetLimits = Maybe (HashMap Text Spend)
a} :: Budget) ((Maybe (HashMap Text Spend) -> f (Maybe (HashMap Text Spend)))
 -> Budget -> f Budget)
-> ((Maybe (HashMap Text Spend) -> f (Maybe (HashMap Text Spend)))
    -> Maybe (HashMap Text Spend) -> f (Maybe (HashMap Text Spend)))
-> (Maybe (HashMap Text Spend) -> f (Maybe (HashMap Text Spend)))
-> Budget
-> f Budget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Spend)
  (HashMap Text Spend)
  (HashMap Text Spend)
  (HashMap Text Spend)
-> Iso
     (Maybe (HashMap Text Spend))
     (Maybe (HashMap Text Spend))
     (Maybe (HashMap Text Spend))
     (Maybe (HashMap Text Spend))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Spend)
  (HashMap Text Spend)
  (HashMap Text Spend)
  (HashMap Text Spend)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The last time that you updated this budget.
budget_lastUpdatedTime :: Lens.Lens' Budget (Prelude.Maybe Prelude.UTCTime)
budget_lastUpdatedTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Budget -> f Budget
budget_lastUpdatedTime = (Budget -> Maybe POSIX)
-> (Budget -> Maybe POSIX -> Budget)
-> Lens Budget Budget (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:Budget' :: Budget -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: Budget
s@Budget' {} Maybe POSIX
a -> Budget
s {$sel:lastUpdatedTime:Budget' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: Budget) ((Maybe POSIX -> f (Maybe POSIX)) -> Budget -> f Budget)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Budget
-> f Budget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The total amount of cost, usage, RI utilization, RI coverage, Savings
-- Plans utilization, or Savings Plans coverage that you want to track with
-- your budget.
--
-- @BudgetLimit@ is required for cost or usage budgets, but optional for RI
-- or Savings Plans utilization or coverage budgets. RI and Savings Plans
-- utilization or coverage budgets default to @100@, which is the only
-- valid value for RI or Savings Plans utilization or coverage budgets. You
-- can\'t use @BudgetLimit@ with @PlannedBudgetLimits@ for @CreateBudget@
-- and @UpdateBudget@ actions.
budget_budgetLimit :: Lens.Lens' Budget (Prelude.Maybe Spend)
budget_budgetLimit :: (Maybe Spend -> f (Maybe Spend)) -> Budget -> f Budget
budget_budgetLimit = (Budget -> Maybe Spend)
-> (Budget -> Maybe Spend -> Budget)
-> Lens Budget Budget (Maybe Spend) (Maybe Spend)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe Spend
budgetLimit :: Maybe Spend
$sel:budgetLimit:Budget' :: Budget -> Maybe Spend
budgetLimit} -> Maybe Spend
budgetLimit) (\s :: Budget
s@Budget' {} Maybe Spend
a -> Budget
s {$sel:budgetLimit:Budget' :: Maybe Spend
budgetLimit = Maybe Spend
a} :: Budget)

-- | The period of time that is covered by a budget. The period has a start
-- date and an end date. The start date must come before the end date. The
-- end date must come before @06\/15\/87 00:00 UTC@.
--
-- If you create your budget and don\'t specify a start date, AWS defaults
-- to the start of your chosen time period (DAILY, MONTHLY, QUARTERLY, or
-- ANNUALLY). For example, if you created your budget on January 24, 2018,
-- chose @DAILY@, and didn\'t set a start date, AWS set your start date to
-- @01\/24\/18 00:00 UTC@. If you chose @MONTHLY@, AWS set your start date
-- to @01\/01\/18 00:00 UTC@. If you didn\'t specify an end date, AWS set
-- your end date to @06\/15\/87 00:00 UTC@. The defaults are the same for
-- the AWS Billing and Cost Management console and the API.
--
-- You can change either date with the @UpdateBudget@ operation.
--
-- After the end date, AWS deletes the budget and all associated
-- notifications and subscribers.
budget_timePeriod :: Lens.Lens' Budget (Prelude.Maybe TimePeriod)
budget_timePeriod :: (Maybe TimePeriod -> f (Maybe TimePeriod)) -> Budget -> f Budget
budget_timePeriod = (Budget -> Maybe TimePeriod)
-> (Budget -> Maybe TimePeriod -> Budget)
-> Lens Budget Budget (Maybe TimePeriod) (Maybe TimePeriod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe TimePeriod
timePeriod :: Maybe TimePeriod
$sel:timePeriod:Budget' :: Budget -> Maybe TimePeriod
timePeriod} -> Maybe TimePeriod
timePeriod) (\s :: Budget
s@Budget' {} Maybe TimePeriod
a -> Budget
s {$sel:timePeriod:Budget' :: Maybe TimePeriod
timePeriod = Maybe TimePeriod
a} :: Budget)

-- | The types of costs that are included in this @COST@ budget.
--
-- @USAGE@, @RI_UTILIZATION@, @RI_COVERAGE@, @SAVINGS_PLANS_UTILIZATION@,
-- and @SAVINGS_PLANS_COVERAGE@ budgets do not have @CostTypes@.
budget_costTypes :: Lens.Lens' Budget (Prelude.Maybe CostTypes)
budget_costTypes :: (Maybe CostTypes -> f (Maybe CostTypes)) -> Budget -> f Budget
budget_costTypes = (Budget -> Maybe CostTypes)
-> (Budget -> Maybe CostTypes -> Budget)
-> Lens Budget Budget (Maybe CostTypes) (Maybe CostTypes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe CostTypes
costTypes :: Maybe CostTypes
$sel:costTypes:Budget' :: Budget -> Maybe CostTypes
costTypes} -> Maybe CostTypes
costTypes) (\s :: Budget
s@Budget' {} Maybe CostTypes
a -> Budget
s {$sel:costTypes:Budget' :: Maybe CostTypes
costTypes = Maybe CostTypes
a} :: Budget)

-- | The cost filters, such as service or tag, that are applied to a budget.
--
-- AWS Budgets supports the following services as a filter for RI budgets:
--
-- -   Amazon Elastic Compute Cloud - Compute
--
-- -   Amazon Redshift
--
-- -   Amazon Relational Database Service
--
-- -   Amazon ElastiCache
--
-- -   Amazon Elasticsearch Service
budget_costFilters :: Lens.Lens' Budget (Prelude.Maybe (Prelude.HashMap Prelude.Text [Prelude.Text]))
budget_costFilters :: (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> Budget -> f Budget
budget_costFilters = (Budget -> Maybe (HashMap Text [Text]))
-> (Budget -> Maybe (HashMap Text [Text]) -> Budget)
-> Lens
     Budget
     Budget
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Maybe (HashMap Text [Text])
costFilters :: Maybe (HashMap Text [Text])
$sel:costFilters:Budget' :: Budget -> Maybe (HashMap Text [Text])
costFilters} -> Maybe (HashMap Text [Text])
costFilters) (\s :: Budget
s@Budget' {} Maybe (HashMap Text [Text])
a -> Budget
s {$sel:costFilters:Budget' :: Maybe (HashMap Text [Text])
costFilters = Maybe (HashMap Text [Text])
a} :: Budget) ((Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
 -> Budget -> f Budget)
-> ((Maybe (HashMap Text [Text])
     -> f (Maybe (HashMap Text [Text])))
    -> Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> (Maybe (HashMap Text [Text]) -> f (Maybe (HashMap Text [Text])))
-> Budget
-> f Budget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
-> Iso
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
     (Maybe (HashMap Text [Text]))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
  (HashMap Text [Text])
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of a budget. The name must be unique within an account. The @:@
-- and @\\@ characters aren\'t allowed in @BudgetName@.
budget_budgetName :: Lens.Lens' Budget Prelude.Text
budget_budgetName :: (Text -> f Text) -> Budget -> f Budget
budget_budgetName = (Budget -> Text)
-> (Budget -> Text -> Budget) -> Lens Budget Budget Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {Text
budgetName :: Text
$sel:budgetName:Budget' :: Budget -> Text
budgetName} -> Text
budgetName) (\s :: Budget
s@Budget' {} Text
a -> Budget
s {$sel:budgetName:Budget' :: Text
budgetName = Text
a} :: Budget)

-- | The length of time until a budget resets the actual and forecasted
-- spend.
budget_timeUnit :: Lens.Lens' Budget TimeUnit
budget_timeUnit :: (TimeUnit -> f TimeUnit) -> Budget -> f Budget
budget_timeUnit = (Budget -> TimeUnit)
-> (Budget -> TimeUnit -> Budget)
-> Lens Budget Budget TimeUnit TimeUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {TimeUnit
timeUnit :: TimeUnit
$sel:timeUnit:Budget' :: Budget -> TimeUnit
timeUnit} -> TimeUnit
timeUnit) (\s :: Budget
s@Budget' {} TimeUnit
a -> Budget
s {$sel:timeUnit:Budget' :: TimeUnit
timeUnit = TimeUnit
a} :: Budget)

-- | Whether this budget tracks costs, usage, RI utilization, RI coverage,
-- Savings Plans utilization, or Savings Plans coverage.
budget_budgetType :: Lens.Lens' Budget BudgetType
budget_budgetType :: (BudgetType -> f BudgetType) -> Budget -> f Budget
budget_budgetType = (Budget -> BudgetType)
-> (Budget -> BudgetType -> Budget)
-> Lens Budget Budget BudgetType BudgetType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Budget' {BudgetType
budgetType :: BudgetType
$sel:budgetType:Budget' :: Budget -> BudgetType
budgetType} -> BudgetType
budgetType) (\s :: Budget
s@Budget' {} BudgetType
a -> Budget
s {$sel:budgetType:Budget' :: BudgetType
budgetType = BudgetType
a} :: Budget)

instance Core.FromJSON Budget where
  parseJSON :: Value -> Parser Budget
parseJSON =
    String -> (Object -> Parser Budget) -> Value -> Parser Budget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Budget"
      ( \Object
x ->
          Maybe CalculatedSpend
-> Maybe (HashMap Text Spend)
-> Maybe POSIX
-> Maybe Spend
-> Maybe TimePeriod
-> Maybe CostTypes
-> Maybe (HashMap Text [Text])
-> Text
-> TimeUnit
-> BudgetType
-> Budget
Budget'
            (Maybe CalculatedSpend
 -> Maybe (HashMap Text Spend)
 -> Maybe POSIX
 -> Maybe Spend
 -> Maybe TimePeriod
 -> Maybe CostTypes
 -> Maybe (HashMap Text [Text])
 -> Text
 -> TimeUnit
 -> BudgetType
 -> Budget)
-> Parser (Maybe CalculatedSpend)
-> Parser
     (Maybe (HashMap Text Spend)
      -> Maybe POSIX
      -> Maybe Spend
      -> Maybe TimePeriod
      -> Maybe CostTypes
      -> Maybe (HashMap Text [Text])
      -> Text
      -> TimeUnit
      -> BudgetType
      -> Budget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CalculatedSpend)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CalculatedSpend")
            Parser
  (Maybe (HashMap Text Spend)
   -> Maybe POSIX
   -> Maybe Spend
   -> Maybe TimePeriod
   -> Maybe CostTypes
   -> Maybe (HashMap Text [Text])
   -> Text
   -> TimeUnit
   -> BudgetType
   -> Budget)
-> Parser (Maybe (HashMap Text Spend))
-> Parser
     (Maybe POSIX
      -> Maybe Spend
      -> Maybe TimePeriod
      -> Maybe CostTypes
      -> Maybe (HashMap Text [Text])
      -> Text
      -> TimeUnit
      -> BudgetType
      -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Spend)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PlannedBudgetLimits"
                            Parser (Maybe (Maybe (HashMap Text Spend)))
-> Maybe (HashMap Text Spend)
-> Parser (Maybe (HashMap Text Spend))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Spend)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe POSIX
   -> Maybe Spend
   -> Maybe TimePeriod
   -> Maybe CostTypes
   -> Maybe (HashMap Text [Text])
   -> Text
   -> TimeUnit
   -> BudgetType
   -> Budget)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Spend
      -> Maybe TimePeriod
      -> Maybe CostTypes
      -> Maybe (HashMap Text [Text])
      -> Text
      -> TimeUnit
      -> BudgetType
      -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastUpdatedTime")
            Parser
  (Maybe Spend
   -> Maybe TimePeriod
   -> Maybe CostTypes
   -> Maybe (HashMap Text [Text])
   -> Text
   -> TimeUnit
   -> BudgetType
   -> Budget)
-> Parser (Maybe Spend)
-> Parser
     (Maybe TimePeriod
      -> Maybe CostTypes
      -> Maybe (HashMap Text [Text])
      -> Text
      -> TimeUnit
      -> BudgetType
      -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Spend)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BudgetLimit")
            Parser
  (Maybe TimePeriod
   -> Maybe CostTypes
   -> Maybe (HashMap Text [Text])
   -> Text
   -> TimeUnit
   -> BudgetType
   -> Budget)
-> Parser (Maybe TimePeriod)
-> Parser
     (Maybe CostTypes
      -> Maybe (HashMap Text [Text])
      -> Text
      -> TimeUnit
      -> BudgetType
      -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TimePeriod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimePeriod")
            Parser
  (Maybe CostTypes
   -> Maybe (HashMap Text [Text])
   -> Text
   -> TimeUnit
   -> BudgetType
   -> Budget)
-> Parser (Maybe CostTypes)
-> Parser
     (Maybe (HashMap Text [Text])
      -> Text -> TimeUnit -> BudgetType -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CostTypes)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CostTypes")
            Parser
  (Maybe (HashMap Text [Text])
   -> Text -> TimeUnit -> BudgetType -> Budget)
-> Parser (Maybe (HashMap Text [Text]))
-> Parser (Text -> TimeUnit -> BudgetType -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text [Text])))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CostFilters" Parser (Maybe (Maybe (HashMap Text [Text])))
-> Maybe (HashMap Text [Text])
-> Parser (Maybe (HashMap Text [Text]))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text [Text])
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> TimeUnit -> BudgetType -> Budget)
-> Parser Text -> Parser (TimeUnit -> BudgetType -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BudgetName")
            Parser (TimeUnit -> BudgetType -> Budget)
-> Parser TimeUnit -> Parser (BudgetType -> Budget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TimeUnit
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TimeUnit")
            Parser (BudgetType -> Budget) -> Parser BudgetType -> Parser Budget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser BudgetType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BudgetType")
      )

instance Prelude.Hashable Budget

instance Prelude.NFData Budget

instance Core.ToJSON Budget where
  toJSON :: Budget -> Value
toJSON Budget' {Maybe (HashMap Text [Text])
Maybe (HashMap Text Spend)
Maybe POSIX
Maybe CostTypes
Maybe Spend
Maybe CalculatedSpend
Maybe TimePeriod
Text
BudgetType
TimeUnit
budgetType :: BudgetType
timeUnit :: TimeUnit
budgetName :: Text
costFilters :: Maybe (HashMap Text [Text])
costTypes :: Maybe CostTypes
timePeriod :: Maybe TimePeriod
budgetLimit :: Maybe Spend
lastUpdatedTime :: Maybe POSIX
plannedBudgetLimits :: Maybe (HashMap Text Spend)
calculatedSpend :: Maybe CalculatedSpend
$sel:budgetType:Budget' :: Budget -> BudgetType
$sel:timeUnit:Budget' :: Budget -> TimeUnit
$sel:budgetName:Budget' :: Budget -> Text
$sel:costFilters:Budget' :: Budget -> Maybe (HashMap Text [Text])
$sel:costTypes:Budget' :: Budget -> Maybe CostTypes
$sel:timePeriod:Budget' :: Budget -> Maybe TimePeriod
$sel:budgetLimit:Budget' :: Budget -> Maybe Spend
$sel:lastUpdatedTime:Budget' :: Budget -> Maybe POSIX
$sel:plannedBudgetLimits:Budget' :: Budget -> Maybe (HashMap Text Spend)
$sel:calculatedSpend:Budget' :: Budget -> Maybe CalculatedSpend
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CalculatedSpend" Text -> CalculatedSpend -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CalculatedSpend -> Pair) -> Maybe CalculatedSpend -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CalculatedSpend
calculatedSpend,
            (Text
"PlannedBudgetLimits" Text -> HashMap Text Spend -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Spend -> Pair)
-> Maybe (HashMap Text Spend) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Spend)
plannedBudgetLimits,
            (Text
"LastUpdatedTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
lastUpdatedTime,
            (Text
"BudgetLimit" Text -> Spend -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Spend -> Pair) -> Maybe Spend -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Spend
budgetLimit,
            (Text
"TimePeriod" Text -> TimePeriod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimePeriod -> Pair) -> Maybe TimePeriod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimePeriod
timePeriod,
            (Text
"CostTypes" Text -> CostTypes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CostTypes -> Pair) -> Maybe CostTypes -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CostTypes
costTypes,
            (Text
"CostFilters" Text -> HashMap Text [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text [Text] -> Pair)
-> Maybe (HashMap Text [Text]) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text [Text])
costFilters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BudgetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
budgetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TimeUnit" Text -> TimeUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TimeUnit
timeUnit),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BudgetType" Text -> BudgetType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= BudgetType
budgetType)
          ]
      )