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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 SNS targets that are notified when updates are made to an incident.
    IncidentTemplate -> Maybe [NotificationTargetItem]
notificationTargets :: Prelude.Maybe [NotificationTargetItem],
    -- | Used to stop Incident Manager from creating multiple incident records
    -- for the same incident.
    IncidentTemplate -> Maybe Text
dedupeString :: 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
(IncidentTemplate -> IncidentTemplate -> Bool)
-> (IncidentTemplate -> IncidentTemplate -> Bool)
-> Eq IncidentTemplate
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]
(Int -> ReadS IncidentTemplate)
-> ReadS [IncidentTemplate]
-> ReadPrec IncidentTemplate
-> ReadPrec [IncidentTemplate]
-> Read 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
(Int -> IncidentTemplate -> ShowS)
-> (IncidentTemplate -> String)
-> ([IncidentTemplate] -> ShowS)
-> Show IncidentTemplate
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. IncidentTemplate -> Rep IncidentTemplate x)
-> (forall x. Rep IncidentTemplate x -> IncidentTemplate)
-> Generic IncidentTemplate
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:
--
-- 'summary', 'incidentTemplate_summary' - The summary of the incident. The summary is a brief synopsis of what
-- occurred, what\'s currently happening, and context.
--
-- 'notificationTargets', 'incidentTemplate_notificationTargets' - The SNS targets that are notified when updates are made to an incident.
--
-- 'dedupeString', 'incidentTemplate_dedupeString' - Used to stop Incident Manager from creating multiple incident records
-- for the same incident.
--
-- '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' :: Maybe Text
-> Maybe [NotificationTargetItem]
-> Maybe Text
-> Natural
-> Text
-> IncidentTemplate
IncidentTemplate'
    { $sel:summary:IncidentTemplate' :: Maybe Text
summary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:notificationTargets:IncidentTemplate' :: Maybe [NotificationTargetItem]
notificationTargets = Maybe [NotificationTargetItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:dedupeString:IncidentTemplate' :: Maybe Text
dedupeString = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:impact:IncidentTemplate' :: Natural
impact = Natural
pImpact_,
      $sel:title:IncidentTemplate' :: Text
title = Text
pTitle_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> IncidentTemplate -> f IncidentTemplate
incidentTemplate_summary = (IncidentTemplate -> Maybe Text)
-> (IncidentTemplate -> Maybe Text -> IncidentTemplate)
-> Lens IncidentTemplate IncidentTemplate (Maybe Text) (Maybe Text)
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 SNS targets that are notified when updates are made to an incident.
incidentTemplate_notificationTargets :: Lens.Lens' IncidentTemplate (Prelude.Maybe [NotificationTargetItem])
incidentTemplate_notificationTargets :: (Maybe [NotificationTargetItem]
 -> f (Maybe [NotificationTargetItem]))
-> IncidentTemplate -> f IncidentTemplate
incidentTemplate_notificationTargets = (IncidentTemplate -> Maybe [NotificationTargetItem])
-> (IncidentTemplate
    -> Maybe [NotificationTargetItem] -> IncidentTemplate)
-> Lens
     IncidentTemplate
     IncidentTemplate
     (Maybe [NotificationTargetItem])
     (Maybe [NotificationTargetItem])
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) ((Maybe [NotificationTargetItem]
  -> f (Maybe [NotificationTargetItem]))
 -> IncidentTemplate -> f IncidentTemplate)
-> ((Maybe [NotificationTargetItem]
     -> f (Maybe [NotificationTargetItem]))
    -> Maybe [NotificationTargetItem]
    -> f (Maybe [NotificationTargetItem]))
-> (Maybe [NotificationTargetItem]
    -> f (Maybe [NotificationTargetItem]))
-> IncidentTemplate
-> f IncidentTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [NotificationTargetItem]
  [NotificationTargetItem]
  [NotificationTargetItem]
  [NotificationTargetItem]
-> Iso
     (Maybe [NotificationTargetItem])
     (Maybe [NotificationTargetItem])
     (Maybe [NotificationTargetItem])
     (Maybe [NotificationTargetItem])
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 AnIso
  [NotificationTargetItem]
  [NotificationTargetItem]
  [NotificationTargetItem]
  [NotificationTargetItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> IncidentTemplate -> f IncidentTemplate
incidentTemplate_dedupeString = (IncidentTemplate -> Maybe Text)
-> (IncidentTemplate -> Maybe Text -> IncidentTemplate)
-> Lens IncidentTemplate IncidentTemplate (Maybe Text) (Maybe Text)
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)

-- | The impact of the incident on your customers and applications.
incidentTemplate_impact :: Lens.Lens' IncidentTemplate Prelude.Natural
incidentTemplate_impact :: (Natural -> f Natural) -> IncidentTemplate -> f IncidentTemplate
incidentTemplate_impact = (IncidentTemplate -> Natural)
-> (IncidentTemplate -> Natural -> IncidentTemplate)
-> Lens IncidentTemplate IncidentTemplate Natural Natural
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 :: (Text -> f Text) -> IncidentTemplate -> f IncidentTemplate
incidentTemplate_title = (IncidentTemplate -> Text)
-> (IncidentTemplate -> Text -> IncidentTemplate)
-> Lens IncidentTemplate IncidentTemplate Text Text
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 Core.FromJSON IncidentTemplate where
  parseJSON :: Value -> Parser IncidentTemplate
parseJSON =
    String
-> (Object -> Parser IncidentTemplate)
-> Value
-> Parser IncidentTemplate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IncidentTemplate"
      ( \Object
x ->
          Maybe Text
-> Maybe [NotificationTargetItem]
-> Maybe Text
-> Natural
-> Text
-> IncidentTemplate
IncidentTemplate'
            (Maybe Text
 -> Maybe [NotificationTargetItem]
 -> Maybe Text
 -> Natural
 -> Text
 -> IncidentTemplate)
-> Parser (Maybe Text)
-> Parser
     (Maybe [NotificationTargetItem]
      -> Maybe Text -> Natural -> Text -> IncidentTemplate)
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
"summary")
            Parser
  (Maybe [NotificationTargetItem]
   -> Maybe Text -> Natural -> Text -> IncidentTemplate)
-> Parser (Maybe [NotificationTargetItem])
-> Parser (Maybe Text -> Natural -> Text -> IncidentTemplate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [NotificationTargetItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"notificationTargets"
                            Parser (Maybe (Maybe [NotificationTargetItem]))
-> Maybe [NotificationTargetItem]
-> Parser (Maybe [NotificationTargetItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [NotificationTargetItem]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Natural -> Text -> IncidentTemplate)
-> Parser (Maybe Text)
-> Parser (Natural -> Text -> IncidentTemplate)
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
"dedupeString")
            Parser (Natural -> Text -> IncidentTemplate)
-> Parser Natural -> Parser (Text -> IncidentTemplate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"impact")
            Parser (Text -> IncidentTemplate)
-> Parser Text -> Parser IncidentTemplate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"title")
      )

instance Prelude.Hashable IncidentTemplate

instance Prelude.NFData IncidentTemplate

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