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

-- | Details about what created the incident record and when it was created.
--
-- /See:/ 'newIncidentRecordSource' smart constructor.
data IncidentRecordSource = IncidentRecordSource'
  { -- | The service principal that assumed the role specified in @createdBy@. If
    -- no service principal assumed the role this will be left blank.
    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 Amazon CloudWatch
    -- alarm, or Amazon EventBridge event.
    IncidentRecordSource -> Text
source :: Prelude.Text
  }
  deriving (IncidentRecordSource -> IncidentRecordSource -> Bool
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]
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
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. 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 service principal that assumed the role specified in @createdBy@. If
-- no service principal assumed the role this will be left blank.
--
-- '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 Amazon CloudWatch
-- alarm, or Amazon EventBridge event.
newIncidentRecordSource ::
  -- | 'createdBy'
  Prelude.Text ->
  -- | 'source'
  Prelude.Text ->
  IncidentRecordSource
newIncidentRecordSource :: Text -> Text -> IncidentRecordSource
newIncidentRecordSource Text
pCreatedBy_ Text
pSource_ =
  IncidentRecordSource'
    { $sel:invokedBy:IncidentRecordSource' :: Maybe Text
invokedBy = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:IncidentRecordSource' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:IncidentRecordSource' :: Text
createdBy = Text
pCreatedBy_,
      $sel:source:IncidentRecordSource' :: Text
source = Text
pSource_
    }

-- | The service principal that assumed the role specified in @createdBy@. If
-- no service principal assumed the role this will be left blank.
incidentRecordSource_invokedBy :: Lens.Lens' IncidentRecordSource (Prelude.Maybe Prelude.Text)
incidentRecordSource_invokedBy :: Lens' IncidentRecordSource (Maybe Text)
incidentRecordSource_invokedBy = 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 :: Lens' IncidentRecordSource (Maybe Text)
incidentRecordSource_resourceArn = 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 :: Lens' IncidentRecordSource Text
incidentRecordSource_createdBy = 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 Amazon CloudWatch
-- alarm, or Amazon EventBridge event.
incidentRecordSource_source :: Lens.Lens' IncidentRecordSource Prelude.Text
incidentRecordSource_source :: Lens' IncidentRecordSource Text
incidentRecordSource_source = 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 Data.FromJSON IncidentRecordSource where
  parseJSON :: Value -> Parser IncidentRecordSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IncidentRecordSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Text -> IncidentRecordSource
IncidentRecordSource'
            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
"invokedBy")
            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
"resourceArn")
            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
"createdBy")
            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
"source")
      )

instance Prelude.Hashable IncidentRecordSource where
  hashWithSalt :: Int -> IncidentRecordSource -> Int
hashWithSalt Int
_salt IncidentRecordSource' {Maybe Text
Text
source :: Text
createdBy :: Text
resourceArn :: Maybe Text
invokedBy :: Maybe Text
$sel:source:IncidentRecordSource' :: IncidentRecordSource -> Text
$sel:createdBy:IncidentRecordSource' :: IncidentRecordSource -> Text
$sel:resourceArn:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
$sel:invokedBy:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
invokedBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
createdBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
source

instance Prelude.NFData IncidentRecordSource where
  rnf :: IncidentRecordSource -> ()
rnf IncidentRecordSource' {Maybe Text
Text
source :: Text
createdBy :: Text
resourceArn :: Maybe Text
invokedBy :: Maybe Text
$sel:source:IncidentRecordSource' :: IncidentRecordSource -> Text
$sel:createdBy:IncidentRecordSource' :: IncidentRecordSource -> Text
$sel:resourceArn:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
$sel:invokedBy:IncidentRecordSource' :: IncidentRecordSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
invokedBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
createdBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
source