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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ReplaceableItem -> ReplaceableItem -> Bool)
-> (ReplaceableItem -> ReplaceableItem -> Bool)
-> Eq ReplaceableItem
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]
(Int -> ReadS ReplaceableItem)
-> ReadS [ReplaceableItem]
-> ReadPrec ReplaceableItem
-> ReadPrec [ReplaceableItem]
-> Read 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
(Int -> ReplaceableItem -> ShowS)
-> (ReplaceableItem -> String)
-> ([ReplaceableItem] -> ShowS)
-> Show ReplaceableItem
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. ReplaceableItem -> Rep ReplaceableItem x)
-> (forall x. Rep ReplaceableItem x -> ReplaceableItem)
-> Generic ReplaceableItem
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' :: Text -> [ReplaceableAttribute] -> ReplaceableItem
ReplaceableItem'
    { $sel:name:ReplaceableItem' :: Text
name = Text
pName_,
      $sel:attributes:ReplaceableItem' :: [ReplaceableAttribute]
attributes = [ReplaceableAttribute]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the replaceable item.
replaceableItem_name :: Lens.Lens' ReplaceableItem Prelude.Text
replaceableItem_name :: (Text -> f Text) -> ReplaceableItem -> f ReplaceableItem
replaceableItem_name = (ReplaceableItem -> Text)
-> (ReplaceableItem -> Text -> ReplaceableItem)
-> Lens ReplaceableItem ReplaceableItem Text Text
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 :: ([ReplaceableAttribute] -> f [ReplaceableAttribute])
-> ReplaceableItem -> f ReplaceableItem
replaceableItem_attributes = (ReplaceableItem -> [ReplaceableAttribute])
-> (ReplaceableItem -> [ReplaceableAttribute] -> ReplaceableItem)
-> Lens
     ReplaceableItem
     ReplaceableItem
     [ReplaceableAttribute]
     [ReplaceableAttribute]
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) (([ReplaceableAttribute] -> f [ReplaceableAttribute])
 -> ReplaceableItem -> f ReplaceableItem)
-> (([ReplaceableAttribute] -> f [ReplaceableAttribute])
    -> [ReplaceableAttribute] -> f [ReplaceableAttribute])
-> ([ReplaceableAttribute] -> f [ReplaceableAttribute])
-> ReplaceableItem
-> f ReplaceableItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ReplaceableAttribute] -> f [ReplaceableAttribute])
-> [ReplaceableAttribute] -> f [ReplaceableAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ReplaceableItem

instance Prelude.NFData ReplaceableItem

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