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

-- |
--
-- /See:/ 'newReplaceableItem' smart constructor.
data ReplaceableItem = ReplaceableItem'
  { -- | The name of the replaceable item.
    ReplaceableItem -> Text
name :: Prelude.Text,
    -- | The list of attributes for a replaceable item.
    ReplaceableItem -> [ReplaceableAttribute]
attributes :: [ReplaceableAttribute]
  }
  deriving (ReplaceableItem -> ReplaceableItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplaceableItem -> ReplaceableItem -> Bool
$c/= :: ReplaceableItem -> ReplaceableItem -> Bool
== :: ReplaceableItem -> ReplaceableItem -> Bool
$c== :: ReplaceableItem -> ReplaceableItem -> Bool
Prelude.Eq, ReadPrec [ReplaceableItem]
ReadPrec ReplaceableItem
Int -> ReadS ReplaceableItem
ReadS [ReplaceableItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplaceableItem]
$creadListPrec :: ReadPrec [ReplaceableItem]
readPrec :: ReadPrec ReplaceableItem
$creadPrec :: ReadPrec ReplaceableItem
readList :: ReadS [ReplaceableItem]
$creadList :: ReadS [ReplaceableItem]
readsPrec :: Int -> ReadS ReplaceableItem
$creadsPrec :: Int -> ReadS ReplaceableItem
Prelude.Read, Int -> ReplaceableItem -> ShowS
[ReplaceableItem] -> ShowS
ReplaceableItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplaceableItem] -> ShowS
$cshowList :: [ReplaceableItem] -> ShowS
show :: ReplaceableItem -> String
$cshow :: ReplaceableItem -> String
showsPrec :: Int -> ReplaceableItem -> ShowS
$cshowsPrec :: Int -> ReplaceableItem -> ShowS
Prelude.Show, forall x. Rep ReplaceableItem x -> ReplaceableItem
forall x. ReplaceableItem -> Rep ReplaceableItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplaceableItem x -> ReplaceableItem
$cfrom :: forall x. ReplaceableItem -> Rep ReplaceableItem x
Prelude.Generic)

-- |
-- Create a value of 'ReplaceableItem' 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:
--
-- 'name', 'replaceableItem_name' - The name of the replaceable item.
--
-- 'attributes', 'replaceableItem_attributes' - The list of attributes for a replaceable item.
newReplaceableItem ::
  -- | 'name'
  Prelude.Text ->
  ReplaceableItem
newReplaceableItem :: Text -> ReplaceableItem
newReplaceableItem Text
pName_ =
  ReplaceableItem'
    { $sel:name:ReplaceableItem' :: Text
name = Text
pName_,
      $sel:attributes:ReplaceableItem' :: [ReplaceableAttribute]
attributes = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The list of attributes for a replaceable item.
replaceableItem_attributes :: Lens.Lens' ReplaceableItem [ReplaceableAttribute]
replaceableItem_attributes :: Lens' ReplaceableItem [ReplaceableAttribute]
replaceableItem_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceableItem' {[ReplaceableAttribute]
attributes :: [ReplaceableAttribute]
$sel:attributes:ReplaceableItem' :: ReplaceableItem -> [ReplaceableAttribute]
attributes} -> [ReplaceableAttribute]
attributes) (\s :: ReplaceableItem
s@ReplaceableItem' {} [ReplaceableAttribute]
a -> ReplaceableItem
s {$sel:attributes:ReplaceableItem' :: [ReplaceableAttribute]
attributes = [ReplaceableAttribute]
a} :: ReplaceableItem) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ReplaceableItem where
  hashWithSalt :: Int -> ReplaceableItem -> Int
hashWithSalt Int
_salt ReplaceableItem' {[ReplaceableAttribute]
Text
attributes :: [ReplaceableAttribute]
name :: Text
$sel:attributes:ReplaceableItem' :: ReplaceableItem -> [ReplaceableAttribute]
$sel:name:ReplaceableItem' :: ReplaceableItem -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [ReplaceableAttribute]
attributes

instance Prelude.NFData ReplaceableItem where
  rnf :: ReplaceableItem -> ()
rnf ReplaceableItem' {[ReplaceableAttribute]
Text
attributes :: [ReplaceableAttribute]
name :: Text
$sel:attributes:ReplaceableItem' :: ReplaceableItem -> [ReplaceableAttribute]
$sel:name:ReplaceableItem' :: ReplaceableItem -> Text
..} =
    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 [ReplaceableAttribute]
attributes

instance Data.ToQuery ReplaceableItem where
  toQuery :: ReplaceableItem -> QueryString
toQuery ReplaceableItem' {[ReplaceableAttribute]
Text
attributes :: [ReplaceableAttribute]
name :: Text
$sel:attributes:ReplaceableItem' :: ReplaceableItem -> [ReplaceableAttribute]
$sel:name:ReplaceableItem' :: ReplaceableItem -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ItemName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
name,
        forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"Attribute" [ReplaceableAttribute]
attributes
      ]