{-# 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.ElasticSearch.Types.RecurringCharge
-- 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.ElasticSearch.Types.RecurringCharge where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the specific price and frequency of a recurring charges for a
-- reserved Elasticsearch instance, or for a reserved Elasticsearch
-- instance offering.
--
-- /See:/ 'newRecurringCharge' smart constructor.
data RecurringCharge = RecurringCharge'
  { -- | The frequency of the recurring charge.
    RecurringCharge -> Maybe Text
recurringChargeFrequency :: Prelude.Maybe Prelude.Text,
    -- | The monetary amount of the recurring charge.
    RecurringCharge -> Maybe Double
recurringChargeAmount :: Prelude.Maybe Prelude.Double
  }
  deriving (RecurringCharge -> RecurringCharge -> Bool
(RecurringCharge -> RecurringCharge -> Bool)
-> (RecurringCharge -> RecurringCharge -> Bool)
-> Eq RecurringCharge
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecurringCharge -> RecurringCharge -> Bool
$c/= :: RecurringCharge -> RecurringCharge -> Bool
== :: RecurringCharge -> RecurringCharge -> Bool
$c== :: RecurringCharge -> RecurringCharge -> Bool
Prelude.Eq, ReadPrec [RecurringCharge]
ReadPrec RecurringCharge
Int -> ReadS RecurringCharge
ReadS [RecurringCharge]
(Int -> ReadS RecurringCharge)
-> ReadS [RecurringCharge]
-> ReadPrec RecurringCharge
-> ReadPrec [RecurringCharge]
-> Read RecurringCharge
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecurringCharge]
$creadListPrec :: ReadPrec [RecurringCharge]
readPrec :: ReadPrec RecurringCharge
$creadPrec :: ReadPrec RecurringCharge
readList :: ReadS [RecurringCharge]
$creadList :: ReadS [RecurringCharge]
readsPrec :: Int -> ReadS RecurringCharge
$creadsPrec :: Int -> ReadS RecurringCharge
Prelude.Read, Int -> RecurringCharge -> ShowS
[RecurringCharge] -> ShowS
RecurringCharge -> String
(Int -> RecurringCharge -> ShowS)
-> (RecurringCharge -> String)
-> ([RecurringCharge] -> ShowS)
-> Show RecurringCharge
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecurringCharge] -> ShowS
$cshowList :: [RecurringCharge] -> ShowS
show :: RecurringCharge -> String
$cshow :: RecurringCharge -> String
showsPrec :: Int -> RecurringCharge -> ShowS
$cshowsPrec :: Int -> RecurringCharge -> ShowS
Prelude.Show, (forall x. RecurringCharge -> Rep RecurringCharge x)
-> (forall x. Rep RecurringCharge x -> RecurringCharge)
-> Generic RecurringCharge
forall x. Rep RecurringCharge x -> RecurringCharge
forall x. RecurringCharge -> Rep RecurringCharge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecurringCharge x -> RecurringCharge
$cfrom :: forall x. RecurringCharge -> Rep RecurringCharge x
Prelude.Generic)

-- |
-- Create a value of 'RecurringCharge' 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:
--
-- 'recurringChargeFrequency', 'recurringCharge_recurringChargeFrequency' - The frequency of the recurring charge.
--
-- 'recurringChargeAmount', 'recurringCharge_recurringChargeAmount' - The monetary amount of the recurring charge.
newRecurringCharge ::
  RecurringCharge
newRecurringCharge :: RecurringCharge
newRecurringCharge =
  RecurringCharge' :: Maybe Text -> Maybe Double -> RecurringCharge
RecurringCharge'
    { $sel:recurringChargeFrequency:RecurringCharge' :: Maybe Text
recurringChargeFrequency =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recurringChargeAmount:RecurringCharge' :: Maybe Double
recurringChargeAmount = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The frequency of the recurring charge.
recurringCharge_recurringChargeFrequency :: Lens.Lens' RecurringCharge (Prelude.Maybe Prelude.Text)
recurringCharge_recurringChargeFrequency :: (Maybe Text -> f (Maybe Text))
-> RecurringCharge -> f RecurringCharge
recurringCharge_recurringChargeFrequency = (RecurringCharge -> Maybe Text)
-> (RecurringCharge -> Maybe Text -> RecurringCharge)
-> Lens RecurringCharge RecurringCharge (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecurringCharge' {Maybe Text
recurringChargeFrequency :: Maybe Text
$sel:recurringChargeFrequency:RecurringCharge' :: RecurringCharge -> Maybe Text
recurringChargeFrequency} -> Maybe Text
recurringChargeFrequency) (\s :: RecurringCharge
s@RecurringCharge' {} Maybe Text
a -> RecurringCharge
s {$sel:recurringChargeFrequency:RecurringCharge' :: Maybe Text
recurringChargeFrequency = Maybe Text
a} :: RecurringCharge)

-- | The monetary amount of the recurring charge.
recurringCharge_recurringChargeAmount :: Lens.Lens' RecurringCharge (Prelude.Maybe Prelude.Double)
recurringCharge_recurringChargeAmount :: (Maybe Double -> f (Maybe Double))
-> RecurringCharge -> f RecurringCharge
recurringCharge_recurringChargeAmount = (RecurringCharge -> Maybe Double)
-> (RecurringCharge -> Maybe Double -> RecurringCharge)
-> Lens
     RecurringCharge RecurringCharge (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecurringCharge' {Maybe Double
recurringChargeAmount :: Maybe Double
$sel:recurringChargeAmount:RecurringCharge' :: RecurringCharge -> Maybe Double
recurringChargeAmount} -> Maybe Double
recurringChargeAmount) (\s :: RecurringCharge
s@RecurringCharge' {} Maybe Double
a -> RecurringCharge
s {$sel:recurringChargeAmount:RecurringCharge' :: Maybe Double
recurringChargeAmount = Maybe Double
a} :: RecurringCharge)

instance Core.FromJSON RecurringCharge where
  parseJSON :: Value -> Parser RecurringCharge
parseJSON =
    String
-> (Object -> Parser RecurringCharge)
-> Value
-> Parser RecurringCharge
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RecurringCharge"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> RecurringCharge
RecurringCharge'
            (Maybe Text -> Maybe Double -> RecurringCharge)
-> Parser (Maybe Text) -> Parser (Maybe Double -> RecurringCharge)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecurringChargeFrequency")
            Parser (Maybe Double -> RecurringCharge)
-> Parser (Maybe Double) -> Parser RecurringCharge
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecurringChargeAmount")
      )

instance Prelude.Hashable RecurringCharge

instance Prelude.NFData RecurringCharge