{-# 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.RDS.Types.Range
-- 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.RDS.Types.Range where

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

-- | A range of integer values.
--
-- /See:/ 'newRange' smart constructor.
data Range = Range'
  { -- | The maximum value in the range.
    Range -> Maybe Int
to :: Prelude.Maybe Prelude.Int,
    -- | The minimum value in the range.
    Range -> Maybe Int
from :: Prelude.Maybe Prelude.Int,
    -- | The step value for the range. For example, if you have a range of 5,000
    -- to 10,000, with a step value of 1,000, the valid values start at 5,000
    -- and step up by 1,000. Even though 7,500 is within the range, it isn\'t a
    -- valid value for the range. The valid values are 5,000, 6,000, 7,000,
    -- 8,000...
    Range -> Maybe Int
step :: Prelude.Maybe Prelude.Int
  }
  deriving (Range -> Range -> Bool
(Range -> Range -> Bool) -> (Range -> Range -> Bool) -> Eq Range
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range -> Range -> Bool
$c/= :: Range -> Range -> Bool
== :: Range -> Range -> Bool
$c== :: Range -> Range -> Bool
Prelude.Eq, ReadPrec [Range]
ReadPrec Range
Int -> ReadS Range
ReadS [Range]
(Int -> ReadS Range)
-> ReadS [Range]
-> ReadPrec Range
-> ReadPrec [Range]
-> Read Range
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Range]
$creadListPrec :: ReadPrec [Range]
readPrec :: ReadPrec Range
$creadPrec :: ReadPrec Range
readList :: ReadS [Range]
$creadList :: ReadS [Range]
readsPrec :: Int -> ReadS Range
$creadsPrec :: Int -> ReadS Range
Prelude.Read, Int -> Range -> ShowS
[Range] -> ShowS
Range -> String
(Int -> Range -> ShowS)
-> (Range -> String) -> ([Range] -> ShowS) -> Show Range
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Range] -> ShowS
$cshowList :: [Range] -> ShowS
show :: Range -> String
$cshow :: Range -> String
showsPrec :: Int -> Range -> ShowS
$cshowsPrec :: Int -> Range -> ShowS
Prelude.Show, (forall x. Range -> Rep Range x)
-> (forall x. Rep Range x -> Range) -> Generic Range
forall x. Rep Range x -> Range
forall x. Range -> Rep Range x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Range x -> Range
$cfrom :: forall x. Range -> Rep Range x
Prelude.Generic)

-- |
-- Create a value of 'Range' 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:
--
-- 'to', 'range_to' - The maximum value in the range.
--
-- 'from', 'range_from' - The minimum value in the range.
--
-- 'step', 'range_step' - The step value for the range. For example, if you have a range of 5,000
-- to 10,000, with a step value of 1,000, the valid values start at 5,000
-- and step up by 1,000. Even though 7,500 is within the range, it isn\'t a
-- valid value for the range. The valid values are 5,000, 6,000, 7,000,
-- 8,000...
newRange ::
  Range
newRange :: Range
newRange =
  Range' :: Maybe Int -> Maybe Int -> Maybe Int -> Range
Range'
    { $sel:to:Range' :: Maybe Int
to = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:from:Range' :: Maybe Int
from = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:step:Range' :: Maybe Int
step = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum value in the range.
range_to :: Lens.Lens' Range (Prelude.Maybe Prelude.Int)
range_to :: (Maybe Int -> f (Maybe Int)) -> Range -> f Range
range_to = (Range -> Maybe Int)
-> (Range -> Maybe Int -> Range)
-> Lens Range Range (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Int
to :: Maybe Int
$sel:to:Range' :: Range -> Maybe Int
to} -> Maybe Int
to) (\s :: Range
s@Range' {} Maybe Int
a -> Range
s {$sel:to:Range' :: Maybe Int
to = Maybe Int
a} :: Range)

-- | The minimum value in the range.
range_from :: Lens.Lens' Range (Prelude.Maybe Prelude.Int)
range_from :: (Maybe Int -> f (Maybe Int)) -> Range -> f Range
range_from = (Range -> Maybe Int)
-> (Range -> Maybe Int -> Range)
-> Lens Range Range (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Int
from :: Maybe Int
$sel:from:Range' :: Range -> Maybe Int
from} -> Maybe Int
from) (\s :: Range
s@Range' {} Maybe Int
a -> Range
s {$sel:from:Range' :: Maybe Int
from = Maybe Int
a} :: Range)

-- | The step value for the range. For example, if you have a range of 5,000
-- to 10,000, with a step value of 1,000, the valid values start at 5,000
-- and step up by 1,000. Even though 7,500 is within the range, it isn\'t a
-- valid value for the range. The valid values are 5,000, 6,000, 7,000,
-- 8,000...
range_step :: Lens.Lens' Range (Prelude.Maybe Prelude.Int)
range_step :: (Maybe Int -> f (Maybe Int)) -> Range -> f Range
range_step = (Range -> Maybe Int)
-> (Range -> Maybe Int -> Range)
-> Lens Range Range (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Int
step :: Maybe Int
$sel:step:Range' :: Range -> Maybe Int
step} -> Maybe Int
step) (\s :: Range
s@Range' {} Maybe Int
a -> Range
s {$sel:step:Range' :: Maybe Int
step = Maybe Int
a} :: Range)

instance Core.FromXML Range where
  parseXML :: [Node] -> Either String Range
parseXML [Node]
x =
    Maybe Int -> Maybe Int -> Maybe Int -> Range
Range'
      (Maybe Int -> Maybe Int -> Maybe Int -> Range)
-> Either String (Maybe Int)
-> Either String (Maybe Int -> Maybe Int -> Range)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"To")
      Either String (Maybe Int -> Maybe Int -> Range)
-> Either String (Maybe Int) -> Either String (Maybe Int -> Range)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"From")
      Either String (Maybe Int -> Range)
-> Either String (Maybe Int) -> Either String Range
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Step")

instance Prelude.Hashable Range

instance Prelude.NFData Range