{-# 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.IncidentTemplate
-- 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.IncidentTemplate 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.NotificationTargetItem

-- | Basic details used in creating a response plan. The response plan is
-- then used to create an incident record.
--
-- /See:/ 'newIncidentTemplate' smart constructor.
data IncidentTemplate = IncidentTemplate'
  { -- | Used to stop Incident Manager from creating multiple incident records
    -- for the same incident.
    IncidentTemplate -> Maybe Text
dedupeString :: Prelude.Maybe Prelude.Text,
    -- | Tags to assign to the template. When the @StartIncident@ API action is
    -- called, Incident Manager assigns the tags specified in the template to
    -- the incident.
    IncidentTemplate -> Maybe (HashMap Text Text)
incidentTags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The Amazon SNS targets that are notified when updates are made to an
    -- incident.
    IncidentTemplate -> Maybe [NotificationTargetItem]
notificationTargets :: Prelude.Maybe [NotificationTargetItem],
    -- | The summary of the incident. The summary is a brief synopsis of what
    -- occurred, what\'s currently happening, and context.
    IncidentTemplate -> Maybe Text
summary :: Prelude.Maybe Prelude.Text,
    -- | The impact of the incident on your customers and applications.
    IncidentTemplate -> Natural
impact :: Prelude.Natural,
    -- | The title of the incident.
    IncidentTemplate -> Text
title :: Prelude.Text
  }
  deriving (IncidentTemplate -> IncidentTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IncidentTemplate -> IncidentTemplate -> Bool
$c/= :: IncidentTemplate -> IncidentTemplate -> Bool
== :: IncidentTemplate -> IncidentTemplate -> Bool
$c== :: IncidentTemplate -> IncidentTemplate -> Bool
Prelude.Eq, ReadPrec [IncidentTemplate]
ReadPrec IncidentTemplate
Int -> ReadS IncidentTemplate
ReadS [IncidentTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IncidentTemplate]
$creadListPrec :: ReadPrec [IncidentTemplate]
readPrec :: ReadPrec IncidentTemplate
$creadPrec :: ReadPrec IncidentTemplate
readList :: ReadS [IncidentTemplate]
$creadList :: ReadS [IncidentTemplate]
readsPrec :: Int -> ReadS IncidentTemplate
$creadsPrec :: Int -> ReadS IncidentTemplate
Prelude.Read, Int -> IncidentTemplate -> ShowS
[IncidentTemplate] -> ShowS
IncidentTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IncidentTemplate] -> ShowS
$cshowList :: [IncidentTemplate] -> ShowS
show :: IncidentTemplate -> String
$cshow :: IncidentTemplate -> String
showsPrec :: Int -> IncidentTemplate -> ShowS
$cshowsPrec :: Int -> IncidentTemplate -> ShowS
Prelude.Show, forall x. Rep IncidentTemplate x -> IncidentTemplate
forall x. IncidentTemplate -> Rep IncidentTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IncidentTemplate x -> IncidentTemplate
$cfrom :: forall x. IncidentTemplate -> Rep IncidentTemplate x
Prelude.Generic)

-- |
-- Create a value of 'IncidentTemplate' 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:
--
-- 'dedupeString', 'incidentTemplate_dedupeString' - Used to stop Incident Manager from creating multiple incident records
-- for the same incident.
--
-- 'incidentTags', 'incidentTemplate_incidentTags' - Tags to assign to the template. When the @StartIncident@ API action is
-- called, Incident Manager assigns the tags specified in the template to
-- the incident.
--
-- 'notificationTargets', 'incidentTemplate_notificationTargets' - The Amazon SNS targets that are notified when updates are made to an
-- incident.
--
-- 'summary', 'incidentTemplate_summary' - The summary of the incident. The summary is a brief synopsis of what
-- occurred, what\'s currently happening, and context.
--
-- 'impact', 'incidentTemplate_impact' - The impact of the incident on your customers and applications.
--
-- 'title', 'incidentTemplate_title' - The title of the incident.
newIncidentTemplate ::
  -- | 'impact'
  Prelude.Natural ->
  -- | 'title'
  Prelude.Text ->
  IncidentTemplate
newIncidentTemplate :: Natural -> Text -> IncidentTemplate
newIncidentTemplate Natural
pImpact_ Text
pTitle_ =
  IncidentTemplate'
    { $sel:dedupeString:IncidentTemplate' :: Maybe Text
dedupeString = forall a. Maybe a
Prelude.Nothing,
      $sel:incidentTags:IncidentTemplate' :: Maybe (HashMap Text Text)
incidentTags = forall a. Maybe a
Prelude.Nothing,
      $sel:notificationTargets:IncidentTemplate' :: Maybe [NotificationTargetItem]
notificationTargets = forall a. Maybe a
Prelude.Nothing,
      $sel:summary:IncidentTemplate' :: Maybe Text
summary = forall a. Maybe a
Prelude.Nothing,
      $sel:impact:IncidentTemplate' :: Natural
impact = Natural
pImpact_,
      $sel:title:IncidentTemplate' :: Text
title = Text
pTitle_
    }

-- | Used to stop Incident Manager from creating multiple incident records
-- for the same incident.
incidentTemplate_dedupeString :: Lens.Lens' IncidentTemplate (Prelude.Maybe Prelude.Text)
incidentTemplate_dedupeString :: Lens' IncidentTemplate (Maybe Text)
incidentTemplate_dedupeString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Maybe Text
dedupeString :: Maybe Text
$sel:dedupeString:IncidentTemplate' :: IncidentTemplate -> Maybe Text
dedupeString} -> Maybe Text
dedupeString) (\s :: IncidentTemplate
s@IncidentTemplate' {} Maybe Text
a -> IncidentTemplate
s {$sel:dedupeString:IncidentTemplate' :: Maybe Text
dedupeString = Maybe Text
a} :: IncidentTemplate)

-- | Tags to assign to the template. When the @StartIncident@ API action is
-- called, Incident Manager assigns the tags specified in the template to
-- the incident.
incidentTemplate_incidentTags :: Lens.Lens' IncidentTemplate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
incidentTemplate_incidentTags :: Lens' IncidentTemplate (Maybe (HashMap Text Text))
incidentTemplate_incidentTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Maybe (HashMap Text Text)
incidentTags :: Maybe (HashMap Text Text)
$sel:incidentTags:IncidentTemplate' :: IncidentTemplate -> Maybe (HashMap Text Text)
incidentTags} -> Maybe (HashMap Text Text)
incidentTags) (\s :: IncidentTemplate
s@IncidentTemplate' {} Maybe (HashMap Text Text)
a -> IncidentTemplate
s {$sel:incidentTags:IncidentTemplate' :: Maybe (HashMap Text Text)
incidentTags = Maybe (HashMap Text Text)
a} :: IncidentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon SNS targets that are notified when updates are made to an
-- incident.
incidentTemplate_notificationTargets :: Lens.Lens' IncidentTemplate (Prelude.Maybe [NotificationTargetItem])
incidentTemplate_notificationTargets :: Lens' IncidentTemplate (Maybe [NotificationTargetItem])
incidentTemplate_notificationTargets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Maybe [NotificationTargetItem]
notificationTargets :: Maybe [NotificationTargetItem]
$sel:notificationTargets:IncidentTemplate' :: IncidentTemplate -> Maybe [NotificationTargetItem]
notificationTargets} -> Maybe [NotificationTargetItem]
notificationTargets) (\s :: IncidentTemplate
s@IncidentTemplate' {} Maybe [NotificationTargetItem]
a -> IncidentTemplate
s {$sel:notificationTargets:IncidentTemplate' :: Maybe [NotificationTargetItem]
notificationTargets = Maybe [NotificationTargetItem]
a} :: IncidentTemplate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The summary of the incident. The summary is a brief synopsis of what
-- occurred, what\'s currently happening, and context.
incidentTemplate_summary :: Lens.Lens' IncidentTemplate (Prelude.Maybe Prelude.Text)
incidentTemplate_summary :: Lens' IncidentTemplate (Maybe Text)
incidentTemplate_summary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Maybe Text
summary :: Maybe Text
$sel:summary:IncidentTemplate' :: IncidentTemplate -> Maybe Text
summary} -> Maybe Text
summary) (\s :: IncidentTemplate
s@IncidentTemplate' {} Maybe Text
a -> IncidentTemplate
s {$sel:summary:IncidentTemplate' :: Maybe Text
summary = Maybe Text
a} :: IncidentTemplate)

-- | The impact of the incident on your customers and applications.
incidentTemplate_impact :: Lens.Lens' IncidentTemplate Prelude.Natural
incidentTemplate_impact :: Lens' IncidentTemplate Natural
incidentTemplate_impact = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Natural
impact :: Natural
$sel:impact:IncidentTemplate' :: IncidentTemplate -> Natural
impact} -> Natural
impact) (\s :: IncidentTemplate
s@IncidentTemplate' {} Natural
a -> IncidentTemplate
s {$sel:impact:IncidentTemplate' :: Natural
impact = Natural
a} :: IncidentTemplate)

-- | The title of the incident.
incidentTemplate_title :: Lens.Lens' IncidentTemplate Prelude.Text
incidentTemplate_title :: Lens' IncidentTemplate Text
incidentTemplate_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentTemplate' {Text
title :: Text
$sel:title:IncidentTemplate' :: IncidentTemplate -> Text
title} -> Text
title) (\s :: IncidentTemplate
s@IncidentTemplate' {} Text
a -> IncidentTemplate
s {$sel:title:IncidentTemplate' :: Text
title = Text
a} :: IncidentTemplate)

instance Data.FromJSON IncidentTemplate where
  parseJSON :: Value -> Parser IncidentTemplate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IncidentTemplate"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe [NotificationTargetItem]
-> Maybe Text
-> Natural
-> Text
-> IncidentTemplate
IncidentTemplate'
            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
"dedupeString")
            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
"incidentTags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"notificationTargets"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"summary")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"impact")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"title")
      )

instance Prelude.Hashable IncidentTemplate where
  hashWithSalt :: Int -> IncidentTemplate -> Int
hashWithSalt Int
_salt IncidentTemplate' {Natural
Maybe [NotificationTargetItem]
Maybe Text
Maybe (HashMap Text Text)
Text
title :: Text
impact :: Natural
summary :: Maybe Text
notificationTargets :: Maybe [NotificationTargetItem]
incidentTags :: Maybe (HashMap Text Text)
dedupeString :: Maybe Text
$sel:title:IncidentTemplate' :: IncidentTemplate -> Text
$sel:impact:IncidentTemplate' :: IncidentTemplate -> Natural
$sel:summary:IncidentTemplate' :: IncidentTemplate -> Maybe Text
$sel:notificationTargets:IncidentTemplate' :: IncidentTemplate -> Maybe [NotificationTargetItem]
$sel:incidentTags:IncidentTemplate' :: IncidentTemplate -> Maybe (HashMap Text Text)
$sel:dedupeString:IncidentTemplate' :: IncidentTemplate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dedupeString
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
incidentTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NotificationTargetItem]
notificationTargets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
summary
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
impact
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
title

instance Prelude.NFData IncidentTemplate where
  rnf :: IncidentTemplate -> ()
rnf IncidentTemplate' {Natural
Maybe [NotificationTargetItem]
Maybe Text
Maybe (HashMap Text Text)
Text
title :: Text
impact :: Natural
summary :: Maybe Text
notificationTargets :: Maybe [NotificationTargetItem]
incidentTags :: Maybe (HashMap Text Text)
dedupeString :: Maybe Text
$sel:title:IncidentTemplate' :: IncidentTemplate -> Text
$sel:impact:IncidentTemplate' :: IncidentTemplate -> Natural
$sel:summary:IncidentTemplate' :: IncidentTemplate -> Maybe Text
$sel:notificationTargets:IncidentTemplate' :: IncidentTemplate -> Maybe [NotificationTargetItem]
$sel:incidentTags:IncidentTemplate' :: IncidentTemplate -> Maybe (HashMap Text Text)
$sel:dedupeString:IncidentTemplate' :: IncidentTemplate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dedupeString
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
incidentTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [NotificationTargetItem]
notificationTargets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
summary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
impact
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
title

instance Data.ToJSON IncidentTemplate where
  toJSON :: IncidentTemplate -> Value
toJSON IncidentTemplate' {Natural
Maybe [NotificationTargetItem]
Maybe Text
Maybe (HashMap Text Text)
Text
title :: Text
impact :: Natural
summary :: Maybe Text
notificationTargets :: Maybe [NotificationTargetItem]
incidentTags :: Maybe (HashMap Text Text)
dedupeString :: Maybe Text
$sel:title:IncidentTemplate' :: IncidentTemplate -> Text
$sel:impact:IncidentTemplate' :: IncidentTemplate -> Natural
$sel:summary:IncidentTemplate' :: IncidentTemplate -> Maybe Text
$sel:notificationTargets:IncidentTemplate' :: IncidentTemplate -> Maybe [NotificationTargetItem]
$sel:incidentTags:IncidentTemplate' :: IncidentTemplate -> Maybe (HashMap Text Text)
$sel:dedupeString:IncidentTemplate' :: IncidentTemplate -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"dedupeString" 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
dedupeString,
            (Key
"incidentTags" 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 (HashMap Text Text)
incidentTags,
            (Key
"notificationTargets" 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 [NotificationTargetItem]
notificationTargets,
            (Key
"summary" 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
summary,
            forall a. a -> Maybe a
Prelude.Just (Key
"impact" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
impact),
            forall a. a -> Maybe a
Prelude.Just (Key
"title" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
title)
          ]
      )