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

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

-- | Details about how the incident record was created and when.
--
-- /See:/ 'newIncidentRecordSource' smart constructor.
data IncidentRecordSource = IncidentRecordSource'
  { -- | The principal the assumed the role specified of the @createdBy@.
    IncidentRecordSource -> Maybe Text
invokedBy :: Prelude.Maybe Prelude.Text,
    -- | The resource that caused the incident to be created.
    IncidentRecordSource -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The principal that started the incident.
    IncidentRecordSource -> Text
createdBy :: Prelude.Text,
    -- | The service that started the incident. This can be manually created from
    -- Incident Manager, automatically created using an AWS CloudWatch alarm,
    -- or Amazon EventBridge event.
    IncidentRecordSource -> Text
source :: Prelude.Text
  }
  deriving (IncidentRecordSource -> IncidentRecordSource -> Bool
(IncidentRecordSource -> IncidentRecordSource -> Bool)
-> (IncidentRecordSource -> IncidentRecordSource -> Bool)
-> Eq IncidentRecordSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IncidentRecordSource -> IncidentRecordSource -> Bool
$c/= :: IncidentRecordSource -> IncidentRecordSource -> Bool
== :: IncidentRecordSource -> IncidentRecordSource -> Bool
$c== :: IncidentRecordSource -> IncidentRecordSource -> Bool
Prelude.Eq, ReadPrec [IncidentRecordSource]
ReadPrec IncidentRecordSource
Int -> ReadS IncidentRecordSource
ReadS [IncidentRecordSource]
(Int -> ReadS IncidentRecordSource)
-> ReadS [IncidentRecordSource]
-> ReadPrec IncidentRecordSource
-> ReadPrec [IncidentRecordSource]
-> Read IncidentRecordSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IncidentRecordSource]
$creadListPrec :: ReadPrec [IncidentRecordSource]
readPrec :: ReadPrec IncidentRecordSource
$creadPrec :: ReadPrec IncidentRecordSource
readList :: ReadS [IncidentRecordSource]
$creadList :: ReadS [IncidentRecordSource]
readsPrec :: Int -> ReadS IncidentRecordSource
$creadsPrec :: Int -> ReadS IncidentRecordSource
Prelude.Read, Int -> IncidentRecordSource -> ShowS
[IncidentRecordSource] -> ShowS
IncidentRecordSource -> String
(Int -> IncidentRecordSource -> ShowS)
-> (IncidentRecordSource -> String)
-> ([IncidentRecordSource] -> ShowS)
-> Show IncidentRecordSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IncidentRecordSource] -> ShowS
$cshowList :: [IncidentRecordSource] -> ShowS
show :: IncidentRecordSource -> String
$cshow :: IncidentRecordSource -> String
showsPrec :: Int -> IncidentRecordSource -> ShowS
$cshowsPrec :: Int -> IncidentRecordSource -> ShowS
Prelude.Show, (forall x. IncidentRecordSource -> Rep IncidentRecordSource x)
-> (forall x. Rep IncidentRecordSource x -> IncidentRecordSource)
-> Generic IncidentRecordSource
forall x. Rep IncidentRecordSource x -> IncidentRecordSource
forall x. IncidentRecordSource -> Rep IncidentRecordSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IncidentRecordSource x -> IncidentRecordSource
$cfrom :: forall x. IncidentRecordSource -> Rep IncidentRecordSource x
Prelude.Generic)

-- |
-- Create a value of 'IncidentRecordSource' 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:
--
-- 'invokedBy', 'incidentRecordSource_invokedBy' - The principal the assumed the role specified of the @createdBy@.
--
-- 'resourceArn', 'incidentRecordSource_resourceArn' - The resource that caused the incident to be created.
--
-- 'createdBy', 'incidentRecordSource_createdBy' - The principal that started the incident.
--
-- 'source', 'incidentRecordSource_source' - The service that started the incident. This can be manually created from
-- Incident Manager, automatically created using an AWS CloudWatch alarm,
-- or Amazon EventBridge event.
newIncidentRecordSource ::
  -- | 'createdBy'
  Prelude.Text ->
  -- | 'source'
  Prelude.Text ->
  IncidentRecordSource
newIncidentRecordSource :: Text -> Text -> IncidentRecordSource
newIncidentRecordSource Text
pCreatedBy_ Text
pSource_ =
  IncidentRecordSource' :: Maybe Text -> Maybe Text -> Text -> Text -> IncidentRecordSource
IncidentRecordSource'
    { $sel:invokedBy:IncidentRecordSource' :: Maybe Text
invokedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:IncidentRecordSource' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:IncidentRecordSource' :: Text
createdBy = Text
pCreatedBy_,
      $sel:source:IncidentRecordSource' :: Text
source = Text
pSource_
    }

-- | The principal the assumed the role specified of the @createdBy@.
incidentRecordSource_invokedBy :: Lens.Lens' IncidentRecordSource (Prelude.Maybe Prelude.Text)
incidentRecordSource_invokedBy :: (Maybe Text -> f (Maybe Text))
-> IncidentRecordSource -> f IncidentRecordSource
incidentRecordSource_invokedBy = (IncidentRecordSource -> Maybe Text)
-> (IncidentRecordSource -> Maybe Text -> IncidentRecordSource)
-> Lens
     IncidentRecordSource IncidentRecordSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentRecordSource' {Maybe Text
invokedBy :: Maybe Text
$sel:invokedBy:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
invokedBy} -> Maybe Text
invokedBy) (\s :: IncidentRecordSource
s@IncidentRecordSource' {} Maybe Text
a -> IncidentRecordSource
s {$sel:invokedBy:IncidentRecordSource' :: Maybe Text
invokedBy = Maybe Text
a} :: IncidentRecordSource)

-- | The resource that caused the incident to be created.
incidentRecordSource_resourceArn :: Lens.Lens' IncidentRecordSource (Prelude.Maybe Prelude.Text)
incidentRecordSource_resourceArn :: (Maybe Text -> f (Maybe Text))
-> IncidentRecordSource -> f IncidentRecordSource
incidentRecordSource_resourceArn = (IncidentRecordSource -> Maybe Text)
-> (IncidentRecordSource -> Maybe Text -> IncidentRecordSource)
-> Lens
     IncidentRecordSource IncidentRecordSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentRecordSource' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: IncidentRecordSource
s@IncidentRecordSource' {} Maybe Text
a -> IncidentRecordSource
s {$sel:resourceArn:IncidentRecordSource' :: Maybe Text
resourceArn = Maybe Text
a} :: IncidentRecordSource)

-- | The principal that started the incident.
incidentRecordSource_createdBy :: Lens.Lens' IncidentRecordSource Prelude.Text
incidentRecordSource_createdBy :: (Text -> f Text) -> IncidentRecordSource -> f IncidentRecordSource
incidentRecordSource_createdBy = (IncidentRecordSource -> Text)
-> (IncidentRecordSource -> Text -> IncidentRecordSource)
-> Lens IncidentRecordSource IncidentRecordSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentRecordSource' {Text
createdBy :: Text
$sel:createdBy:IncidentRecordSource' :: IncidentRecordSource -> Text
createdBy} -> Text
createdBy) (\s :: IncidentRecordSource
s@IncidentRecordSource' {} Text
a -> IncidentRecordSource
s {$sel:createdBy:IncidentRecordSource' :: Text
createdBy = Text
a} :: IncidentRecordSource)

-- | The service that started the incident. This can be manually created from
-- Incident Manager, automatically created using an AWS CloudWatch alarm,
-- or Amazon EventBridge event.
incidentRecordSource_source :: Lens.Lens' IncidentRecordSource Prelude.Text
incidentRecordSource_source :: (Text -> f Text) -> IncidentRecordSource -> f IncidentRecordSource
incidentRecordSource_source = (IncidentRecordSource -> Text)
-> (IncidentRecordSource -> Text -> IncidentRecordSource)
-> Lens IncidentRecordSource IncidentRecordSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IncidentRecordSource' {Text
source :: Text
$sel:source:IncidentRecordSource' :: IncidentRecordSource -> Text
source} -> Text
source) (\s :: IncidentRecordSource
s@IncidentRecordSource' {} Text
a -> IncidentRecordSource
s {$sel:source:IncidentRecordSource' :: Text
source = Text
a} :: IncidentRecordSource)

instance Core.FromJSON IncidentRecordSource where
  parseJSON :: Value -> Parser IncidentRecordSource
parseJSON =
    String
-> (Object -> Parser IncidentRecordSource)
-> Value
-> Parser IncidentRecordSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IncidentRecordSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Text -> IncidentRecordSource
IncidentRecordSource'
            (Maybe Text -> Maybe Text -> Text -> Text -> IncidentRecordSource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> Text -> IncidentRecordSource)
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
"invokedBy")
            Parser (Maybe Text -> Text -> Text -> IncidentRecordSource)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> IncidentRecordSource)
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
"resourceArn")
            Parser (Text -> Text -> IncidentRecordSource)
-> Parser Text -> Parser (Text -> IncidentRecordSource)
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
"createdBy")
            Parser (Text -> IncidentRecordSource)
-> Parser Text -> Parser IncidentRecordSource
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
"source")
      )

instance Prelude.Hashable IncidentRecordSource

instance Prelude.NFData IncidentRecordSource