{-# 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.OpsWorksCM.Types.EngineAttribute
-- 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.OpsWorksCM.Types.EngineAttribute where

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

-- | A name and value pair that is specific to the engine of the server.
--
-- /See:/ 'newEngineAttribute' smart constructor.
data EngineAttribute = EngineAttribute'
  { -- | The value of the engine attribute.
    EngineAttribute -> Maybe (Sensitive Text)
value :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The name of the engine attribute.
    EngineAttribute -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (EngineAttribute -> EngineAttribute -> Bool
(EngineAttribute -> EngineAttribute -> Bool)
-> (EngineAttribute -> EngineAttribute -> Bool)
-> Eq EngineAttribute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EngineAttribute -> EngineAttribute -> Bool
$c/= :: EngineAttribute -> EngineAttribute -> Bool
== :: EngineAttribute -> EngineAttribute -> Bool
$c== :: EngineAttribute -> EngineAttribute -> Bool
Prelude.Eq, Int -> EngineAttribute -> ShowS
[EngineAttribute] -> ShowS
EngineAttribute -> String
(Int -> EngineAttribute -> ShowS)
-> (EngineAttribute -> String)
-> ([EngineAttribute] -> ShowS)
-> Show EngineAttribute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EngineAttribute] -> ShowS
$cshowList :: [EngineAttribute] -> ShowS
show :: EngineAttribute -> String
$cshow :: EngineAttribute -> String
showsPrec :: Int -> EngineAttribute -> ShowS
$cshowsPrec :: Int -> EngineAttribute -> ShowS
Prelude.Show, (forall x. EngineAttribute -> Rep EngineAttribute x)
-> (forall x. Rep EngineAttribute x -> EngineAttribute)
-> Generic EngineAttribute
forall x. Rep EngineAttribute x -> EngineAttribute
forall x. EngineAttribute -> Rep EngineAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EngineAttribute x -> EngineAttribute
$cfrom :: forall x. EngineAttribute -> Rep EngineAttribute x
Prelude.Generic)

-- |
-- Create a value of 'EngineAttribute' 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:
--
-- 'value', 'engineAttribute_value' - The value of the engine attribute.
--
-- 'name', 'engineAttribute_name' - The name of the engine attribute.
newEngineAttribute ::
  EngineAttribute
newEngineAttribute :: EngineAttribute
newEngineAttribute =
  EngineAttribute' :: Maybe (Sensitive Text) -> Maybe Text -> EngineAttribute
EngineAttribute'
    { $sel:value:EngineAttribute' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EngineAttribute' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the engine attribute.
engineAttribute_value :: Lens.Lens' EngineAttribute (Prelude.Maybe Prelude.Text)
engineAttribute_value :: (Maybe Text -> f (Maybe Text))
-> EngineAttribute -> f EngineAttribute
engineAttribute_value = (EngineAttribute -> Maybe (Sensitive Text))
-> (EngineAttribute -> Maybe (Sensitive Text) -> EngineAttribute)
-> Lens
     EngineAttribute
     EngineAttribute
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EngineAttribute' {Maybe (Sensitive Text)
value :: Maybe (Sensitive Text)
$sel:value:EngineAttribute' :: EngineAttribute -> Maybe (Sensitive Text)
value} -> Maybe (Sensitive Text)
value) (\s :: EngineAttribute
s@EngineAttribute' {} Maybe (Sensitive Text)
a -> EngineAttribute
s {$sel:value:EngineAttribute' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
a} :: EngineAttribute) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> EngineAttribute -> f EngineAttribute)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> EngineAttribute
-> f EngineAttribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The name of the engine attribute.
engineAttribute_name :: Lens.Lens' EngineAttribute (Prelude.Maybe Prelude.Text)
engineAttribute_name :: (Maybe Text -> f (Maybe Text))
-> EngineAttribute -> f EngineAttribute
engineAttribute_name = (EngineAttribute -> Maybe Text)
-> (EngineAttribute -> Maybe Text -> EngineAttribute)
-> Lens EngineAttribute EngineAttribute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EngineAttribute' {Maybe Text
name :: Maybe Text
$sel:name:EngineAttribute' :: EngineAttribute -> Maybe Text
name} -> Maybe Text
name) (\s :: EngineAttribute
s@EngineAttribute' {} Maybe Text
a -> EngineAttribute
s {$sel:name:EngineAttribute' :: Maybe Text
name = Maybe Text
a} :: EngineAttribute)

instance Core.FromJSON EngineAttribute where
  parseJSON :: Value -> Parser EngineAttribute
parseJSON =
    String
-> (Object -> Parser EngineAttribute)
-> Value
-> Parser EngineAttribute
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EngineAttribute"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Maybe Text -> EngineAttribute
EngineAttribute'
            (Maybe (Sensitive Text) -> Maybe Text -> EngineAttribute)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> EngineAttribute)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value") Parser (Maybe Text -> EngineAttribute)
-> Parser (Maybe Text) -> Parser EngineAttribute
forall (f :: * -> *) a b. Applicative f => 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
"Name")
      )

instance Prelude.Hashable EngineAttribute

instance Prelude.NFData EngineAttribute

instance Core.ToJSON EngineAttribute where
  toJSON :: EngineAttribute -> Value
toJSON EngineAttribute' {Maybe Text
Maybe (Sensitive Text)
name :: Maybe Text
value :: Maybe (Sensitive Text)
$sel:name:EngineAttribute' :: EngineAttribute -> Maybe Text
$sel:value:EngineAttribute' :: EngineAttribute -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Value" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
value,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name
          ]
      )