{-# 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.SSMContacts.Types.Engagement
-- 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.SSMContacts.Types.Engagement 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

-- | Incident Manager reaching out to a contact or escalation plan to engage
-- contact during an incident.
--
-- /See:/ 'newEngagement' smart constructor.
data Engagement = Engagement'
  { -- | The ARN of the incident that\'s engaging the contact.
    Engagement -> Maybe Text
incidentId :: Prelude.Maybe Prelude.Text,
    -- | The time that the engagement began.
    Engagement -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX,
    -- | The time that the engagement ended.
    Engagement -> Maybe POSIX
stopTime :: Prelude.Maybe Data.POSIX,
    -- | The Amazon Resource Name (ARN) of the engagement.
    Engagement -> Text
engagementArn :: Prelude.Text,
    -- | The ARN of the escalation plan or contact that Incident Manager is
    -- engaging.
    Engagement -> Text
contactArn :: Prelude.Text,
    -- | The user that started the engagement.
    Engagement -> Text
sender :: Prelude.Text
  }
  deriving (Engagement -> Engagement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Engagement -> Engagement -> Bool
$c/= :: Engagement -> Engagement -> Bool
== :: Engagement -> Engagement -> Bool
$c== :: Engagement -> Engagement -> Bool
Prelude.Eq, ReadPrec [Engagement]
ReadPrec Engagement
Int -> ReadS Engagement
ReadS [Engagement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Engagement]
$creadListPrec :: ReadPrec [Engagement]
readPrec :: ReadPrec Engagement
$creadPrec :: ReadPrec Engagement
readList :: ReadS [Engagement]
$creadList :: ReadS [Engagement]
readsPrec :: Int -> ReadS Engagement
$creadsPrec :: Int -> ReadS Engagement
Prelude.Read, Int -> Engagement -> ShowS
[Engagement] -> ShowS
Engagement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Engagement] -> ShowS
$cshowList :: [Engagement] -> ShowS
show :: Engagement -> String
$cshow :: Engagement -> String
showsPrec :: Int -> Engagement -> ShowS
$cshowsPrec :: Int -> Engagement -> ShowS
Prelude.Show, forall x. Rep Engagement x -> Engagement
forall x. Engagement -> Rep Engagement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Engagement x -> Engagement
$cfrom :: forall x. Engagement -> Rep Engagement x
Prelude.Generic)

-- |
-- Create a value of 'Engagement' 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:
--
-- 'incidentId', 'engagement_incidentId' - The ARN of the incident that\'s engaging the contact.
--
-- 'startTime', 'engagement_startTime' - The time that the engagement began.
--
-- 'stopTime', 'engagement_stopTime' - The time that the engagement ended.
--
-- 'engagementArn', 'engagement_engagementArn' - The Amazon Resource Name (ARN) of the engagement.
--
-- 'contactArn', 'engagement_contactArn' - The ARN of the escalation plan or contact that Incident Manager is
-- engaging.
--
-- 'sender', 'engagement_sender' - The user that started the engagement.
newEngagement ::
  -- | 'engagementArn'
  Prelude.Text ->
  -- | 'contactArn'
  Prelude.Text ->
  -- | 'sender'
  Prelude.Text ->
  Engagement
newEngagement :: Text -> Text -> Text -> Engagement
newEngagement Text
pEngagementArn_ Text
pContactArn_ Text
pSender_ =
  Engagement'
    { $sel:incidentId:Engagement' :: Maybe Text
incidentId = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:Engagement' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:stopTime:Engagement' :: Maybe POSIX
stopTime = forall a. Maybe a
Prelude.Nothing,
      $sel:engagementArn:Engagement' :: Text
engagementArn = Text
pEngagementArn_,
      $sel:contactArn:Engagement' :: Text
contactArn = Text
pContactArn_,
      $sel:sender:Engagement' :: Text
sender = Text
pSender_
    }

-- | The ARN of the incident that\'s engaging the contact.
engagement_incidentId :: Lens.Lens' Engagement (Prelude.Maybe Prelude.Text)
engagement_incidentId :: Lens' Engagement (Maybe Text)
engagement_incidentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Maybe Text
incidentId :: Maybe Text
$sel:incidentId:Engagement' :: Engagement -> Maybe Text
incidentId} -> Maybe Text
incidentId) (\s :: Engagement
s@Engagement' {} Maybe Text
a -> Engagement
s {$sel:incidentId:Engagement' :: Maybe Text
incidentId = Maybe Text
a} :: Engagement)

-- | The time that the engagement began.
engagement_startTime :: Lens.Lens' Engagement (Prelude.Maybe Prelude.UTCTime)
engagement_startTime :: Lens' Engagement (Maybe UTCTime)
engagement_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:Engagement' :: Engagement -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: Engagement
s@Engagement' {} Maybe POSIX
a -> Engagement
s {$sel:startTime:Engagement' :: Maybe POSIX
startTime = Maybe POSIX
a} :: Engagement) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time that the engagement ended.
engagement_stopTime :: Lens.Lens' Engagement (Prelude.Maybe Prelude.UTCTime)
engagement_stopTime :: Lens' Engagement (Maybe UTCTime)
engagement_stopTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Maybe POSIX
stopTime :: Maybe POSIX
$sel:stopTime:Engagement' :: Engagement -> Maybe POSIX
stopTime} -> Maybe POSIX
stopTime) (\s :: Engagement
s@Engagement' {} Maybe POSIX
a -> Engagement
s {$sel:stopTime:Engagement' :: Maybe POSIX
stopTime = Maybe POSIX
a} :: Engagement) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The Amazon Resource Name (ARN) of the engagement.
engagement_engagementArn :: Lens.Lens' Engagement Prelude.Text
engagement_engagementArn :: Lens' Engagement Text
engagement_engagementArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Text
engagementArn :: Text
$sel:engagementArn:Engagement' :: Engagement -> Text
engagementArn} -> Text
engagementArn) (\s :: Engagement
s@Engagement' {} Text
a -> Engagement
s {$sel:engagementArn:Engagement' :: Text
engagementArn = Text
a} :: Engagement)

-- | The ARN of the escalation plan or contact that Incident Manager is
-- engaging.
engagement_contactArn :: Lens.Lens' Engagement Prelude.Text
engagement_contactArn :: Lens' Engagement Text
engagement_contactArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Text
contactArn :: Text
$sel:contactArn:Engagement' :: Engagement -> Text
contactArn} -> Text
contactArn) (\s :: Engagement
s@Engagement' {} Text
a -> Engagement
s {$sel:contactArn:Engagement' :: Text
contactArn = Text
a} :: Engagement)

-- | The user that started the engagement.
engagement_sender :: Lens.Lens' Engagement Prelude.Text
engagement_sender :: Lens' Engagement Text
engagement_sender = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Engagement' {Text
sender :: Text
$sel:sender:Engagement' :: Engagement -> Text
sender} -> Text
sender) (\s :: Engagement
s@Engagement' {} Text
a -> Engagement
s {$sel:sender:Engagement' :: Text
sender = Text
a} :: Engagement)

instance Data.FromJSON Engagement where
  parseJSON :: Value -> Parser Engagement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Engagement"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX -> Maybe POSIX -> Text -> Text -> Text -> Engagement
Engagement'
            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
"IncidentId")
            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
"StartTime")
            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
"StopTime")
            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
"EngagementArn")
            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
"ContactArn")
            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
"Sender")
      )

instance Prelude.Hashable Engagement where
  hashWithSalt :: Int -> Engagement -> Int
hashWithSalt Int
_salt Engagement' {Maybe Text
Maybe POSIX
Text
sender :: Text
contactArn :: Text
engagementArn :: Text
stopTime :: Maybe POSIX
startTime :: Maybe POSIX
incidentId :: Maybe Text
$sel:sender:Engagement' :: Engagement -> Text
$sel:contactArn:Engagement' :: Engagement -> Text
$sel:engagementArn:Engagement' :: Engagement -> Text
$sel:stopTime:Engagement' :: Engagement -> Maybe POSIX
$sel:startTime:Engagement' :: Engagement -> Maybe POSIX
$sel:incidentId:Engagement' :: Engagement -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
incidentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
stopTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
engagementArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sender

instance Prelude.NFData Engagement where
  rnf :: Engagement -> ()
rnf Engagement' {Maybe Text
Maybe POSIX
Text
sender :: Text
contactArn :: Text
engagementArn :: Text
stopTime :: Maybe POSIX
startTime :: Maybe POSIX
incidentId :: Maybe Text
$sel:sender:Engagement' :: Engagement -> Text
$sel:contactArn:Engagement' :: Engagement -> Text
$sel:engagementArn:Engagement' :: Engagement -> Text
$sel:stopTime:Engagement' :: Engagement -> Maybe POSIX
$sel:startTime:Engagement' :: Engagement -> Maybe POSIX
$sel:incidentId:Engagement' :: Engagement -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
incidentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
stopTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
engagementArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sender