{-# 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.OptionVersion
-- 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.OptionVersion where

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

-- | The version for an option. Option group option versions are returned by
-- the @DescribeOptionGroupOptions@ action.
--
-- /See:/ 'newOptionVersion' smart constructor.
data OptionVersion = OptionVersion'
  { -- | The version of the option.
    OptionVersion -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | True if the version is the default version of the option, and otherwise
    -- false.
    OptionVersion -> Maybe Bool
isDefault :: Prelude.Maybe Prelude.Bool
  }
  deriving (OptionVersion -> OptionVersion -> Bool
(OptionVersion -> OptionVersion -> Bool)
-> (OptionVersion -> OptionVersion -> Bool) -> Eq OptionVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptionVersion -> OptionVersion -> Bool
$c/= :: OptionVersion -> OptionVersion -> Bool
== :: OptionVersion -> OptionVersion -> Bool
$c== :: OptionVersion -> OptionVersion -> Bool
Prelude.Eq, ReadPrec [OptionVersion]
ReadPrec OptionVersion
Int -> ReadS OptionVersion
ReadS [OptionVersion]
(Int -> ReadS OptionVersion)
-> ReadS [OptionVersion]
-> ReadPrec OptionVersion
-> ReadPrec [OptionVersion]
-> Read OptionVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptionVersion]
$creadListPrec :: ReadPrec [OptionVersion]
readPrec :: ReadPrec OptionVersion
$creadPrec :: ReadPrec OptionVersion
readList :: ReadS [OptionVersion]
$creadList :: ReadS [OptionVersion]
readsPrec :: Int -> ReadS OptionVersion
$creadsPrec :: Int -> ReadS OptionVersion
Prelude.Read, Int -> OptionVersion -> ShowS
[OptionVersion] -> ShowS
OptionVersion -> String
(Int -> OptionVersion -> ShowS)
-> (OptionVersion -> String)
-> ([OptionVersion] -> ShowS)
-> Show OptionVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptionVersion] -> ShowS
$cshowList :: [OptionVersion] -> ShowS
show :: OptionVersion -> String
$cshow :: OptionVersion -> String
showsPrec :: Int -> OptionVersion -> ShowS
$cshowsPrec :: Int -> OptionVersion -> ShowS
Prelude.Show, (forall x. OptionVersion -> Rep OptionVersion x)
-> (forall x. Rep OptionVersion x -> OptionVersion)
-> Generic OptionVersion
forall x. Rep OptionVersion x -> OptionVersion
forall x. OptionVersion -> Rep OptionVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptionVersion x -> OptionVersion
$cfrom :: forall x. OptionVersion -> Rep OptionVersion x
Prelude.Generic)

-- |
-- Create a value of 'OptionVersion' 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:
--
-- 'version', 'optionVersion_version' - The version of the option.
--
-- 'isDefault', 'optionVersion_isDefault' - True if the version is the default version of the option, and otherwise
-- false.
newOptionVersion ::
  OptionVersion
newOptionVersion :: OptionVersion
newOptionVersion =
  OptionVersion' :: Maybe Text -> Maybe Bool -> OptionVersion
OptionVersion'
    { $sel:version:OptionVersion' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isDefault:OptionVersion' :: Maybe Bool
isDefault = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The version of the option.
optionVersion_version :: Lens.Lens' OptionVersion (Prelude.Maybe Prelude.Text)
optionVersion_version :: (Maybe Text -> f (Maybe Text)) -> OptionVersion -> f OptionVersion
optionVersion_version = (OptionVersion -> Maybe Text)
-> (OptionVersion -> Maybe Text -> OptionVersion)
-> Lens OptionVersion OptionVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptionVersion' {Maybe Text
version :: Maybe Text
$sel:version:OptionVersion' :: OptionVersion -> Maybe Text
version} -> Maybe Text
version) (\s :: OptionVersion
s@OptionVersion' {} Maybe Text
a -> OptionVersion
s {$sel:version:OptionVersion' :: Maybe Text
version = Maybe Text
a} :: OptionVersion)

-- | True if the version is the default version of the option, and otherwise
-- false.
optionVersion_isDefault :: Lens.Lens' OptionVersion (Prelude.Maybe Prelude.Bool)
optionVersion_isDefault :: (Maybe Bool -> f (Maybe Bool)) -> OptionVersion -> f OptionVersion
optionVersion_isDefault = (OptionVersion -> Maybe Bool)
-> (OptionVersion -> Maybe Bool -> OptionVersion)
-> Lens OptionVersion OptionVersion (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptionVersion' {Maybe Bool
isDefault :: Maybe Bool
$sel:isDefault:OptionVersion' :: OptionVersion -> Maybe Bool
isDefault} -> Maybe Bool
isDefault) (\s :: OptionVersion
s@OptionVersion' {} Maybe Bool
a -> OptionVersion
s {$sel:isDefault:OptionVersion' :: Maybe Bool
isDefault = Maybe Bool
a} :: OptionVersion)

instance Core.FromXML OptionVersion where
  parseXML :: [Node] -> Either String OptionVersion
parseXML [Node]
x =
    Maybe Text -> Maybe Bool -> OptionVersion
OptionVersion'
      (Maybe Text -> Maybe Bool -> OptionVersion)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> OptionVersion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Version")
      Either String (Maybe Bool -> OptionVersion)
-> Either String (Maybe Bool) -> Either String OptionVersion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IsDefault")

instance Prelude.Hashable OptionVersion

instance Prelude.NFData OptionVersion