{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RDS.Types.Range where

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

-- | A range of integer values.
--
-- /See:/ 'newRange' smart constructor.
data Range = Range'
  { -- | 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,
    -- | The maximum value in the range.
    Range -> Maybe Int
to :: Prelude.Maybe Prelude.Int
  }
  deriving (Range -> Range -> Bool
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]
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
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. 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:
--
-- '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...
--
-- 'to', 'range_to' - The maximum value in the range.
newRange ::
  Range
newRange :: Range
newRange =
  Range'
    { $sel:from:Range' :: Maybe Int
from = forall a. Maybe a
Prelude.Nothing,
      $sel:step:Range' :: Maybe Int
step = forall a. Maybe a
Prelude.Nothing,
      $sel:to:Range' :: Maybe Int
to = forall a. Maybe a
Prelude.Nothing
    }

-- | The minimum value in the range.
range_from :: Lens.Lens' Range (Prelude.Maybe Prelude.Int)
range_from :: Lens' Range (Maybe Int)
range_from = 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 :: Lens' Range (Maybe Int)
range_step = 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)

-- | The maximum value in the range.
range_to :: Lens.Lens' Range (Prelude.Maybe Prelude.Int)
range_to :: Lens' Range (Maybe Int)
range_to = 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)

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

instance Prelude.Hashable Range where
  hashWithSalt :: Int -> Range -> Int
hashWithSalt Int
_salt Range' {Maybe Int
to :: Maybe Int
step :: Maybe Int
from :: Maybe Int
$sel:to:Range' :: Range -> Maybe Int
$sel:step:Range' :: Range -> Maybe Int
$sel:from:Range' :: Range -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
from
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
step
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
to

instance Prelude.NFData Range where
  rnf :: Range -> ()
rnf Range' {Maybe Int
to :: Maybe Int
step :: Maybe Int
from :: Maybe Int
$sel:to:Range' :: Range -> Maybe Int
$sel:step:Range' :: Range -> Maybe Int
$sel:from:Range' :: Range -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
from
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
step
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
to