{-# 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.ItemValue
-- 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.SSMIncidents.Types.ItemValue 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.SSMIncidents.Types.PagerDutyIncidentDetail

-- | Describes a related item.
--
-- /See:/ 'newItemValue' smart constructor.
data ItemValue = ItemValue'
  { -- | The Amazon Resource Name (ARN) of the related item, if the related item
    -- is an Amazon resource.
    ItemValue -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The metric definition, if the related item is a metric in Amazon
    -- CloudWatch.
    ItemValue -> Maybe Text
metricDefinition :: Prelude.Maybe Prelude.Text,
    -- | Details about an incident that is associated with a PagerDuty incident.
    ItemValue -> Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail :: Prelude.Maybe PagerDutyIncidentDetail,
    -- | The URL, if the related item is a non-Amazon Web Services resource.
    ItemValue -> Maybe Text
url :: Prelude.Maybe Prelude.Text
  }
  deriving (ItemValue -> ItemValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemValue -> ItemValue -> Bool
$c/= :: ItemValue -> ItemValue -> Bool
== :: ItemValue -> ItemValue -> Bool
$c== :: ItemValue -> ItemValue -> Bool
Prelude.Eq, ReadPrec [ItemValue]
ReadPrec ItemValue
Int -> ReadS ItemValue
ReadS [ItemValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemValue]
$creadListPrec :: ReadPrec [ItemValue]
readPrec :: ReadPrec ItemValue
$creadPrec :: ReadPrec ItemValue
readList :: ReadS [ItemValue]
$creadList :: ReadS [ItemValue]
readsPrec :: Int -> ReadS ItemValue
$creadsPrec :: Int -> ReadS ItemValue
Prelude.Read, Int -> ItemValue -> ShowS
[ItemValue] -> ShowS
ItemValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemValue] -> ShowS
$cshowList :: [ItemValue] -> ShowS
show :: ItemValue -> String
$cshow :: ItemValue -> String
showsPrec :: Int -> ItemValue -> ShowS
$cshowsPrec :: Int -> ItemValue -> ShowS
Prelude.Show, forall x. Rep ItemValue x -> ItemValue
forall x. ItemValue -> Rep ItemValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemValue x -> ItemValue
$cfrom :: forall x. ItemValue -> Rep ItemValue x
Prelude.Generic)

-- |
-- Create a value of 'ItemValue' 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:
--
-- 'arn', 'itemValue_arn' - The Amazon Resource Name (ARN) of the related item, if the related item
-- is an Amazon resource.
--
-- 'metricDefinition', 'itemValue_metricDefinition' - The metric definition, if the related item is a metric in Amazon
-- CloudWatch.
--
-- 'pagerDutyIncidentDetail', 'itemValue_pagerDutyIncidentDetail' - Details about an incident that is associated with a PagerDuty incident.
--
-- 'url', 'itemValue_url' - The URL, if the related item is a non-Amazon Web Services resource.
newItemValue ::
  ItemValue
newItemValue :: ItemValue
newItemValue =
  ItemValue'
    { $sel:arn:ItemValue' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:metricDefinition:ItemValue' :: Maybe Text
metricDefinition = forall a. Maybe a
Prelude.Nothing,
      $sel:pagerDutyIncidentDetail:ItemValue' :: Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail = forall a. Maybe a
Prelude.Nothing,
      $sel:url:ItemValue' :: Maybe Text
url = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the related item, if the related item
-- is an Amazon resource.
itemValue_arn :: Lens.Lens' ItemValue (Prelude.Maybe Prelude.Text)
itemValue_arn :: Lens' ItemValue (Maybe Text)
itemValue_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemValue' {Maybe Text
arn :: Maybe Text
$sel:arn:ItemValue' :: ItemValue -> Maybe Text
arn} -> Maybe Text
arn) (\s :: ItemValue
s@ItemValue' {} Maybe Text
a -> ItemValue
s {$sel:arn:ItemValue' :: Maybe Text
arn = Maybe Text
a} :: ItemValue)

-- | The metric definition, if the related item is a metric in Amazon
-- CloudWatch.
itemValue_metricDefinition :: Lens.Lens' ItemValue (Prelude.Maybe Prelude.Text)
itemValue_metricDefinition :: Lens' ItemValue (Maybe Text)
itemValue_metricDefinition = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemValue' {Maybe Text
metricDefinition :: Maybe Text
$sel:metricDefinition:ItemValue' :: ItemValue -> Maybe Text
metricDefinition} -> Maybe Text
metricDefinition) (\s :: ItemValue
s@ItemValue' {} Maybe Text
a -> ItemValue
s {$sel:metricDefinition:ItemValue' :: Maybe Text
metricDefinition = Maybe Text
a} :: ItemValue)

-- | Details about an incident that is associated with a PagerDuty incident.
itemValue_pagerDutyIncidentDetail :: Lens.Lens' ItemValue (Prelude.Maybe PagerDutyIncidentDetail)
itemValue_pagerDutyIncidentDetail :: Lens' ItemValue (Maybe PagerDutyIncidentDetail)
itemValue_pagerDutyIncidentDetail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemValue' {Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail :: Maybe PagerDutyIncidentDetail
$sel:pagerDutyIncidentDetail:ItemValue' :: ItemValue -> Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail} -> Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail) (\s :: ItemValue
s@ItemValue' {} Maybe PagerDutyIncidentDetail
a -> ItemValue
s {$sel:pagerDutyIncidentDetail:ItemValue' :: Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail = Maybe PagerDutyIncidentDetail
a} :: ItemValue)

-- | The URL, if the related item is a non-Amazon Web Services resource.
itemValue_url :: Lens.Lens' ItemValue (Prelude.Maybe Prelude.Text)
itemValue_url :: Lens' ItemValue (Maybe Text)
itemValue_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemValue' {Maybe Text
url :: Maybe Text
$sel:url:ItemValue' :: ItemValue -> Maybe Text
url} -> Maybe Text
url) (\s :: ItemValue
s@ItemValue' {} Maybe Text
a -> ItemValue
s {$sel:url:ItemValue' :: Maybe Text
url = Maybe Text
a} :: ItemValue)

instance Data.FromJSON ItemValue where
  parseJSON :: Value -> Parser ItemValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ItemValue"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe PagerDutyIncidentDetail
-> Maybe Text
-> ItemValue
ItemValue'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"metricDefinition")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"pagerDutyIncidentDetail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"url")
      )

instance Prelude.Hashable ItemValue where
  hashWithSalt :: Int -> ItemValue -> Int
hashWithSalt Int
_salt ItemValue' {Maybe Text
Maybe PagerDutyIncidentDetail
url :: Maybe Text
pagerDutyIncidentDetail :: Maybe PagerDutyIncidentDetail
metricDefinition :: Maybe Text
arn :: Maybe Text
$sel:url:ItemValue' :: ItemValue -> Maybe Text
$sel:pagerDutyIncidentDetail:ItemValue' :: ItemValue -> Maybe PagerDutyIncidentDetail
$sel:metricDefinition:ItemValue' :: ItemValue -> Maybe Text
$sel:arn:ItemValue' :: ItemValue -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
metricDefinition
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
url

instance Prelude.NFData ItemValue where
  rnf :: ItemValue -> ()
rnf ItemValue' {Maybe Text
Maybe PagerDutyIncidentDetail
url :: Maybe Text
pagerDutyIncidentDetail :: Maybe PagerDutyIncidentDetail
metricDefinition :: Maybe Text
arn :: Maybe Text
$sel:url:ItemValue' :: ItemValue -> Maybe Text
$sel:pagerDutyIncidentDetail:ItemValue' :: ItemValue -> Maybe PagerDutyIncidentDetail
$sel:metricDefinition:ItemValue' :: ItemValue -> Maybe Text
$sel:arn:ItemValue' :: ItemValue -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
metricDefinition
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
url

instance Data.ToJSON ItemValue where
  toJSON :: ItemValue -> Value
toJSON ItemValue' {Maybe Text
Maybe PagerDutyIncidentDetail
url :: Maybe Text
pagerDutyIncidentDetail :: Maybe PagerDutyIncidentDetail
metricDefinition :: Maybe Text
arn :: Maybe Text
$sel:url:ItemValue' :: ItemValue -> Maybe Text
$sel:pagerDutyIncidentDetail:ItemValue' :: ItemValue -> Maybe PagerDutyIncidentDetail
$sel:metricDefinition:ItemValue' :: ItemValue -> Maybe Text
$sel:arn:ItemValue' :: ItemValue -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
arn,
            (Key
"metricDefinition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricDefinition,
            (Key
"pagerDutyIncidentDetail" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PagerDutyIncidentDetail
pagerDutyIncidentDetail,
            (Key
"url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
url
          ]
      )