{-# 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-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.ItemValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | 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 URL, if the related item is a non-AWS resource.
    ItemValue -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The metric definition, if the related item is a metric in CloudWatch.
    ItemValue -> Maybe Text
metricDefinition :: Prelude.Maybe Prelude.Text
  }
  deriving (ItemValue -> ItemValue -> Bool
(ItemValue -> ItemValue -> Bool)
-> (ItemValue -> ItemValue -> Bool) -> Eq ItemValue
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]
(Int -> ReadS ItemValue)
-> ReadS [ItemValue]
-> ReadPrec ItemValue
-> ReadPrec [ItemValue]
-> Read 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
(Int -> ItemValue -> ShowS)
-> (ItemValue -> String)
-> ([ItemValue] -> ShowS)
-> Show ItemValue
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. ItemValue -> Rep ItemValue x)
-> (forall x. Rep ItemValue x -> ItemValue) -> Generic ItemValue
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.
--
-- 'url', 'itemValue_url' - The URL, if the related item is a non-AWS resource.
--
-- 'metricDefinition', 'itemValue_metricDefinition' - The metric definition, if the related item is a metric in CloudWatch.
newItemValue ::
  ItemValue
newItemValue :: ItemValue
newItemValue =
  ItemValue' :: Maybe Text -> Maybe Text -> Maybe Text -> ItemValue
ItemValue'
    { $sel:arn:ItemValue' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:ItemValue' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricDefinition:ItemValue' :: Maybe Text
metricDefinition = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> ItemValue -> f ItemValue
itemValue_arn = (ItemValue -> Maybe Text)
-> (ItemValue -> Maybe Text -> ItemValue)
-> Lens ItemValue ItemValue (Maybe Text) (Maybe Text)
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 URL, if the related item is a non-AWS resource.
itemValue_url :: Lens.Lens' ItemValue (Prelude.Maybe Prelude.Text)
itemValue_url :: (Maybe Text -> f (Maybe Text)) -> ItemValue -> f ItemValue
itemValue_url = (ItemValue -> Maybe Text)
-> (ItemValue -> Maybe Text -> ItemValue)
-> Lens ItemValue ItemValue (Maybe Text) (Maybe Text)
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)

-- | The metric definition, if the related item is a metric in CloudWatch.
itemValue_metricDefinition :: Lens.Lens' ItemValue (Prelude.Maybe Prelude.Text)
itemValue_metricDefinition :: (Maybe Text -> f (Maybe Text)) -> ItemValue -> f ItemValue
itemValue_metricDefinition = (ItemValue -> Maybe Text)
-> (ItemValue -> Maybe Text -> ItemValue)
-> Lens ItemValue ItemValue (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable ItemValue

instance Prelude.NFData ItemValue

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