{-# 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.SDB.Types.ReplaceableAttribute
-- 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.SDB.Types.ReplaceableAttribute 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

-- |
--
-- /See:/ 'newReplaceableAttribute' smart constructor.
data ReplaceableAttribute = ReplaceableAttribute'
  { -- | A flag specifying whether or not to replace the attribute\/value pair or
    -- to add a new attribute\/value pair. The default setting is @false@.
    ReplaceableAttribute -> Maybe Bool
replace :: Prelude.Maybe Prelude.Bool,
    -- | The name of the replaceable attribute.
    ReplaceableAttribute -> Text
name :: Prelude.Text,
    -- | The value of the replaceable attribute.
    ReplaceableAttribute -> Text
value :: Prelude.Text
  }
  deriving (ReplaceableAttribute -> ReplaceableAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplaceableAttribute -> ReplaceableAttribute -> Bool
$c/= :: ReplaceableAttribute -> ReplaceableAttribute -> Bool
== :: ReplaceableAttribute -> ReplaceableAttribute -> Bool
$c== :: ReplaceableAttribute -> ReplaceableAttribute -> Bool
Prelude.Eq, ReadPrec [ReplaceableAttribute]
ReadPrec ReplaceableAttribute
Int -> ReadS ReplaceableAttribute
ReadS [ReplaceableAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplaceableAttribute]
$creadListPrec :: ReadPrec [ReplaceableAttribute]
readPrec :: ReadPrec ReplaceableAttribute
$creadPrec :: ReadPrec ReplaceableAttribute
readList :: ReadS [ReplaceableAttribute]
$creadList :: ReadS [ReplaceableAttribute]
readsPrec :: Int -> ReadS ReplaceableAttribute
$creadsPrec :: Int -> ReadS ReplaceableAttribute
Prelude.Read, Int -> ReplaceableAttribute -> ShowS
[ReplaceableAttribute] -> ShowS
ReplaceableAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplaceableAttribute] -> ShowS
$cshowList :: [ReplaceableAttribute] -> ShowS
show :: ReplaceableAttribute -> String
$cshow :: ReplaceableAttribute -> String
showsPrec :: Int -> ReplaceableAttribute -> ShowS
$cshowsPrec :: Int -> ReplaceableAttribute -> ShowS
Prelude.Show, forall x. Rep ReplaceableAttribute x -> ReplaceableAttribute
forall x. ReplaceableAttribute -> Rep ReplaceableAttribute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplaceableAttribute x -> ReplaceableAttribute
$cfrom :: forall x. ReplaceableAttribute -> Rep ReplaceableAttribute x
Prelude.Generic)

-- |
-- Create a value of 'ReplaceableAttribute' 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:
--
-- 'replace', 'replaceableAttribute_replace' - A flag specifying whether or not to replace the attribute\/value pair or
-- to add a new attribute\/value pair. The default setting is @false@.
--
-- 'name', 'replaceableAttribute_name' - The name of the replaceable attribute.
--
-- 'value', 'replaceableAttribute_value' - The value of the replaceable attribute.
newReplaceableAttribute ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  ReplaceableAttribute
newReplaceableAttribute :: Text -> Text -> ReplaceableAttribute
newReplaceableAttribute Text
pName_ Text
pValue_ =
  ReplaceableAttribute'
    { $sel:replace:ReplaceableAttribute' :: Maybe Bool
replace = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ReplaceableAttribute' :: Text
name = Text
pName_,
      $sel:value:ReplaceableAttribute' :: Text
value = Text
pValue_
    }

-- | A flag specifying whether or not to replace the attribute\/value pair or
-- to add a new attribute\/value pair. The default setting is @false@.
replaceableAttribute_replace :: Lens.Lens' ReplaceableAttribute (Prelude.Maybe Prelude.Bool)
replaceableAttribute_replace :: Lens' ReplaceableAttribute (Maybe Bool)
replaceableAttribute_replace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceableAttribute' {Maybe Bool
replace :: Maybe Bool
$sel:replace:ReplaceableAttribute' :: ReplaceableAttribute -> Maybe Bool
replace} -> Maybe Bool
replace) (\s :: ReplaceableAttribute
s@ReplaceableAttribute' {} Maybe Bool
a -> ReplaceableAttribute
s {$sel:replace:ReplaceableAttribute' :: Maybe Bool
replace = Maybe Bool
a} :: ReplaceableAttribute)

-- | The name of the replaceable attribute.
replaceableAttribute_name :: Lens.Lens' ReplaceableAttribute Prelude.Text
replaceableAttribute_name :: Lens' ReplaceableAttribute Text
replaceableAttribute_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceableAttribute' {Text
name :: Text
$sel:name:ReplaceableAttribute' :: ReplaceableAttribute -> Text
name} -> Text
name) (\s :: ReplaceableAttribute
s@ReplaceableAttribute' {} Text
a -> ReplaceableAttribute
s {$sel:name:ReplaceableAttribute' :: Text
name = Text
a} :: ReplaceableAttribute)

-- | The value of the replaceable attribute.
replaceableAttribute_value :: Lens.Lens' ReplaceableAttribute Prelude.Text
replaceableAttribute_value :: Lens' ReplaceableAttribute Text
replaceableAttribute_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceableAttribute' {Text
value :: Text
$sel:value:ReplaceableAttribute' :: ReplaceableAttribute -> Text
value} -> Text
value) (\s :: ReplaceableAttribute
s@ReplaceableAttribute' {} Text
a -> ReplaceableAttribute
s {$sel:value:ReplaceableAttribute' :: Text
value = Text
a} :: ReplaceableAttribute)

instance Prelude.Hashable ReplaceableAttribute where
  hashWithSalt :: Int -> ReplaceableAttribute -> Int
hashWithSalt Int
_salt ReplaceableAttribute' {Maybe Bool
Text
value :: Text
name :: Text
replace :: Maybe Bool
$sel:value:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:name:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:replace:ReplaceableAttribute' :: ReplaceableAttribute -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
replace
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData ReplaceableAttribute where
  rnf :: ReplaceableAttribute -> ()
rnf ReplaceableAttribute' {Maybe Bool
Text
value :: Text
name :: Text
replace :: Maybe Bool
$sel:value:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:name:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:replace:ReplaceableAttribute' :: ReplaceableAttribute -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
replace
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToQuery ReplaceableAttribute where
  toQuery :: ReplaceableAttribute -> QueryString
toQuery ReplaceableAttribute' {Maybe Bool
Text
value :: Text
name :: Text
replace :: Maybe Bool
$sel:value:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:name:ReplaceableAttribute' :: ReplaceableAttribute -> Text
$sel:replace:ReplaceableAttribute' :: ReplaceableAttribute -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Replace" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
replace,
        ByteString
"Name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
name,
        ByteString
"Value" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
value
      ]