{-# 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.SSMIncidents.Types.ItemIdentifier
-- 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.SSMIncidents.Types.ItemIdentifier where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSMIncidents.Types.ItemType
import Amazonka.SSMIncidents.Types.ItemValue

-- | Details and type of a related item.
--
-- /See:/ 'newItemIdentifier' smart constructor.
data ItemIdentifier = ItemIdentifier'
  { -- | The type of related item. Incident Manager supports the following types:
    --
    -- -   @ANALYSIS@
    --
    -- -   @INCIDENT@
    --
    -- -   @METRIC@
    --
    -- -   @PARENT@
    --
    -- -   @ATTACHMENT@
    --
    -- -   @OTHER@
    ItemIdentifier -> ItemType
type' :: ItemType,
    -- | Details about the related item.
    ItemIdentifier -> ItemValue
value :: ItemValue
  }
  deriving (ItemIdentifier -> ItemIdentifier -> Bool
(ItemIdentifier -> ItemIdentifier -> Bool)
-> (ItemIdentifier -> ItemIdentifier -> Bool) -> Eq ItemIdentifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemIdentifier -> ItemIdentifier -> Bool
$c/= :: ItemIdentifier -> ItemIdentifier -> Bool
== :: ItemIdentifier -> ItemIdentifier -> Bool
$c== :: ItemIdentifier -> ItemIdentifier -> Bool
Prelude.Eq, ReadPrec [ItemIdentifier]
ReadPrec ItemIdentifier
Int -> ReadS ItemIdentifier
ReadS [ItemIdentifier]
(Int -> ReadS ItemIdentifier)
-> ReadS [ItemIdentifier]
-> ReadPrec ItemIdentifier
-> ReadPrec [ItemIdentifier]
-> Read ItemIdentifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemIdentifier]
$creadListPrec :: ReadPrec [ItemIdentifier]
readPrec :: ReadPrec ItemIdentifier
$creadPrec :: ReadPrec ItemIdentifier
readList :: ReadS [ItemIdentifier]
$creadList :: ReadS [ItemIdentifier]
readsPrec :: Int -> ReadS ItemIdentifier
$creadsPrec :: Int -> ReadS ItemIdentifier
Prelude.Read, Int -> ItemIdentifier -> ShowS
[ItemIdentifier] -> ShowS
ItemIdentifier -> String
(Int -> ItemIdentifier -> ShowS)
-> (ItemIdentifier -> String)
-> ([ItemIdentifier] -> ShowS)
-> Show ItemIdentifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemIdentifier] -> ShowS
$cshowList :: [ItemIdentifier] -> ShowS
show :: ItemIdentifier -> String
$cshow :: ItemIdentifier -> String
showsPrec :: Int -> ItemIdentifier -> ShowS
$cshowsPrec :: Int -> ItemIdentifier -> ShowS
Prelude.Show, (forall x. ItemIdentifier -> Rep ItemIdentifier x)
-> (forall x. Rep ItemIdentifier x -> ItemIdentifier)
-> Generic ItemIdentifier
forall x. Rep ItemIdentifier x -> ItemIdentifier
forall x. ItemIdentifier -> Rep ItemIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemIdentifier x -> ItemIdentifier
$cfrom :: forall x. ItemIdentifier -> Rep ItemIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'ItemIdentifier' 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:
--
-- 'type'', 'itemIdentifier_type' - The type of related item. Incident Manager supports the following types:
--
-- -   @ANALYSIS@
--
-- -   @INCIDENT@
--
-- -   @METRIC@
--
-- -   @PARENT@
--
-- -   @ATTACHMENT@
--
-- -   @OTHER@
--
-- 'value', 'itemIdentifier_value' - Details about the related item.
newItemIdentifier ::
  -- | 'type''
  ItemType ->
  -- | 'value'
  ItemValue ->
  ItemIdentifier
newItemIdentifier :: ItemType -> ItemValue -> ItemIdentifier
newItemIdentifier ItemType
pType_ ItemValue
pValue_ =
  ItemIdentifier' :: ItemType -> ItemValue -> ItemIdentifier
ItemIdentifier' {$sel:type':ItemIdentifier' :: ItemType
type' = ItemType
pType_, $sel:value:ItemIdentifier' :: ItemValue
value = ItemValue
pValue_}

-- | The type of related item. Incident Manager supports the following types:
--
-- -   @ANALYSIS@
--
-- -   @INCIDENT@
--
-- -   @METRIC@
--
-- -   @PARENT@
--
-- -   @ATTACHMENT@
--
-- -   @OTHER@
itemIdentifier_type :: Lens.Lens' ItemIdentifier ItemType
itemIdentifier_type :: (ItemType -> f ItemType) -> ItemIdentifier -> f ItemIdentifier
itemIdentifier_type = (ItemIdentifier -> ItemType)
-> (ItemIdentifier -> ItemType -> ItemIdentifier)
-> Lens ItemIdentifier ItemIdentifier ItemType ItemType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemIdentifier' {ItemType
type' :: ItemType
$sel:type':ItemIdentifier' :: ItemIdentifier -> ItemType
type'} -> ItemType
type') (\s :: ItemIdentifier
s@ItemIdentifier' {} ItemType
a -> ItemIdentifier
s {$sel:type':ItemIdentifier' :: ItemType
type' = ItemType
a} :: ItemIdentifier)

-- | Details about the related item.
itemIdentifier_value :: Lens.Lens' ItemIdentifier ItemValue
itemIdentifier_value :: (ItemValue -> f ItemValue) -> ItemIdentifier -> f ItemIdentifier
itemIdentifier_value = (ItemIdentifier -> ItemValue)
-> (ItemIdentifier -> ItemValue -> ItemIdentifier)
-> Lens ItemIdentifier ItemIdentifier ItemValue ItemValue
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemIdentifier' {ItemValue
value :: ItemValue
$sel:value:ItemIdentifier' :: ItemIdentifier -> ItemValue
value} -> ItemValue
value) (\s :: ItemIdentifier
s@ItemIdentifier' {} ItemValue
a -> ItemIdentifier
s {$sel:value:ItemIdentifier' :: ItemValue
value = ItemValue
a} :: ItemIdentifier)

instance Core.FromJSON ItemIdentifier where
  parseJSON :: Value -> Parser ItemIdentifier
parseJSON =
    String
-> (Object -> Parser ItemIdentifier)
-> Value
-> Parser ItemIdentifier
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ItemIdentifier"
      ( \Object
x ->
          ItemType -> ItemValue -> ItemIdentifier
ItemIdentifier'
            (ItemType -> ItemValue -> ItemIdentifier)
-> Parser ItemType -> Parser (ItemValue -> ItemIdentifier)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ItemType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type") Parser (ItemValue -> ItemIdentifier)
-> Parser ItemValue -> Parser ItemIdentifier
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ItemValue
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"value")
      )

instance Prelude.Hashable ItemIdentifier

instance Prelude.NFData ItemIdentifier

instance Core.ToJSON ItemIdentifier where
  toJSON :: ItemIdentifier -> Value
toJSON ItemIdentifier' {ItemType
ItemValue
value :: ItemValue
type' :: ItemType
$sel:value:ItemIdentifier' :: ItemIdentifier -> ItemValue
$sel:type':ItemIdentifier' :: ItemIdentifier -> ItemType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> ItemType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ItemType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"value" Text -> ItemValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ItemValue
value)
          ]
      )