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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 time that the engagement began.
    Engagement -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The time that the engagement ended.
    Engagement -> Maybe POSIX
stopTime :: Prelude.Maybe Core.POSIX,
    -- | The ARN of the incident that\'s engaging the contact.
    Engagement -> Maybe Text
incidentId :: Prelude.Maybe Prelude.Text,
    -- | 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
(Engagement -> Engagement -> Bool)
-> (Engagement -> Engagement -> Bool) -> Eq Engagement
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]
(Int -> ReadS Engagement)
-> ReadS [Engagement]
-> ReadPrec Engagement
-> ReadPrec [Engagement]
-> Read 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
(Int -> Engagement -> ShowS)
-> (Engagement -> String)
-> ([Engagement] -> ShowS)
-> Show Engagement
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. Engagement -> Rep Engagement x)
-> (forall x. Rep Engagement x -> Engagement) -> Generic Engagement
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:
--
-- 'startTime', 'engagement_startTime' - The time that the engagement began.
--
-- 'stopTime', 'engagement_stopTime' - The time that the engagement ended.
--
-- 'incidentId', 'engagement_incidentId' - The ARN of the incident that\'s engaging the contact.
--
-- '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' :: Maybe POSIX
-> Maybe POSIX -> Maybe Text -> Text -> Text -> Text -> Engagement
Engagement'
    { $sel:startTime:Engagement' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:stopTime:Engagement' :: Maybe POSIX
stopTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:incidentId:Engagement' :: Maybe Text
incidentId = Maybe Text
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 time that the engagement began.
engagement_startTime :: Lens.Lens' Engagement (Prelude.Maybe Prelude.UTCTime)
engagement_startTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Engagement -> f Engagement
engagement_startTime = (Engagement -> Maybe POSIX)
-> (Engagement -> Maybe POSIX -> Engagement)
-> Lens Engagement Engagement (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Engagement -> f Engagement)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Engagement
-> f Engagement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The time that the engagement ended.
engagement_stopTime :: Lens.Lens' Engagement (Prelude.Maybe Prelude.UTCTime)
engagement_stopTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Engagement -> f Engagement
engagement_stopTime = (Engagement -> Maybe POSIX)
-> (Engagement -> Maybe POSIX -> Engagement)
-> Lens Engagement Engagement (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> Engagement -> f Engagement)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Engagement
-> f Engagement
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ARN of the incident that\'s engaging the contact.
engagement_incidentId :: Lens.Lens' Engagement (Prelude.Maybe Prelude.Text)
engagement_incidentId :: (Maybe Text -> f (Maybe Text)) -> Engagement -> f Engagement
engagement_incidentId = (Engagement -> Maybe Text)
-> (Engagement -> Maybe Text -> Engagement)
-> Lens Engagement Engagement (Maybe Text) (Maybe Text)
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 Amazon Resource Name (ARN) of the engagement.
engagement_engagementArn :: Lens.Lens' Engagement Prelude.Text
engagement_engagementArn :: (Text -> f Text) -> Engagement -> f Engagement
engagement_engagementArn = (Engagement -> Text)
-> (Engagement -> Text -> Engagement)
-> Lens Engagement Engagement Text Text
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 :: (Text -> f Text) -> Engagement -> f Engagement
engagement_contactArn = (Engagement -> Text)
-> (Engagement -> Text -> Engagement)
-> Lens Engagement Engagement Text Text
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 :: (Text -> f Text) -> Engagement -> f Engagement
engagement_sender = (Engagement -> Text)
-> (Engagement -> Text -> Engagement)
-> Lens Engagement Engagement Text Text
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 Core.FromJSON Engagement where
  parseJSON :: Value -> Parser Engagement
parseJSON =
    String
-> (Object -> Parser Engagement) -> Value -> Parser Engagement
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Engagement"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX -> Maybe Text -> Text -> Text -> Text -> Engagement
Engagement'
            (Maybe POSIX
 -> Maybe POSIX -> Maybe Text -> Text -> Text -> Text -> Engagement)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX -> Maybe Text -> Text -> Text -> Text -> Engagement)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTime")
            Parser
  (Maybe POSIX -> Maybe Text -> Text -> Text -> Text -> Engagement)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Text -> Text -> Text -> Engagement)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StopTime")
            Parser (Maybe Text -> Text -> Text -> Text -> Engagement)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> Text -> Engagement)
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
"IncidentId")
            Parser (Text -> Text -> Text -> Engagement)
-> Parser Text -> Parser (Text -> Text -> Engagement)
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
"EngagementArn")
            Parser (Text -> Text -> Engagement)
-> Parser Text -> Parser (Text -> Engagement)
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
"ContactArn")
            Parser (Text -> Engagement) -> Parser Text -> Parser Engagement
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
"Sender")
      )

instance Prelude.Hashable Engagement

instance Prelude.NFData Engagement