{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetTimelineEvent
-- 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)
--
-- Retrieves a timeline event based on its ID and incident record.
module Amazonka.SSMIncidents.GetTimelineEvent
  ( -- * Creating a Request
    GetTimelineEvent (..),
    newGetTimelineEvent,

    -- * Request Lenses
    getTimelineEvent_eventId,
    getTimelineEvent_incidentRecordArn,

    -- * Destructuring the Response
    GetTimelineEventResponse (..),
    newGetTimelineEventResponse,

    -- * Response Lenses
    getTimelineEventResponse_httpStatus,
    getTimelineEventResponse_event,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSMIncidents.Types

-- | /See:/ 'newGetTimelineEvent' smart constructor.
data GetTimelineEvent = GetTimelineEvent'
  { -- | The ID of the event. You can get an event\'s ID when you create it or by
    -- using @ListTimelineEvents@.
    GetTimelineEvent -> Text
eventId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the incident that the timeline event
    -- is part of.
    GetTimelineEvent -> Text
incidentRecordArn :: Prelude.Text
  }
  deriving (GetTimelineEvent -> GetTimelineEvent -> Bool
(GetTimelineEvent -> GetTimelineEvent -> Bool)
-> (GetTimelineEvent -> GetTimelineEvent -> Bool)
-> Eq GetTimelineEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTimelineEvent -> GetTimelineEvent -> Bool
$c/= :: GetTimelineEvent -> GetTimelineEvent -> Bool
== :: GetTimelineEvent -> GetTimelineEvent -> Bool
$c== :: GetTimelineEvent -> GetTimelineEvent -> Bool
Prelude.Eq, ReadPrec [GetTimelineEvent]
ReadPrec GetTimelineEvent
Int -> ReadS GetTimelineEvent
ReadS [GetTimelineEvent]
(Int -> ReadS GetTimelineEvent)
-> ReadS [GetTimelineEvent]
-> ReadPrec GetTimelineEvent
-> ReadPrec [GetTimelineEvent]
-> Read GetTimelineEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTimelineEvent]
$creadListPrec :: ReadPrec [GetTimelineEvent]
readPrec :: ReadPrec GetTimelineEvent
$creadPrec :: ReadPrec GetTimelineEvent
readList :: ReadS [GetTimelineEvent]
$creadList :: ReadS [GetTimelineEvent]
readsPrec :: Int -> ReadS GetTimelineEvent
$creadsPrec :: Int -> ReadS GetTimelineEvent
Prelude.Read, Int -> GetTimelineEvent -> ShowS
[GetTimelineEvent] -> ShowS
GetTimelineEvent -> String
(Int -> GetTimelineEvent -> ShowS)
-> (GetTimelineEvent -> String)
-> ([GetTimelineEvent] -> ShowS)
-> Show GetTimelineEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTimelineEvent] -> ShowS
$cshowList :: [GetTimelineEvent] -> ShowS
show :: GetTimelineEvent -> String
$cshow :: GetTimelineEvent -> String
showsPrec :: Int -> GetTimelineEvent -> ShowS
$cshowsPrec :: Int -> GetTimelineEvent -> ShowS
Prelude.Show, (forall x. GetTimelineEvent -> Rep GetTimelineEvent x)
-> (forall x. Rep GetTimelineEvent x -> GetTimelineEvent)
-> Generic GetTimelineEvent
forall x. Rep GetTimelineEvent x -> GetTimelineEvent
forall x. GetTimelineEvent -> Rep GetTimelineEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTimelineEvent x -> GetTimelineEvent
$cfrom :: forall x. GetTimelineEvent -> Rep GetTimelineEvent x
Prelude.Generic)

-- |
-- Create a value of 'GetTimelineEvent' 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:
--
-- 'eventId', 'getTimelineEvent_eventId' - The ID of the event. You can get an event\'s ID when you create it or by
-- using @ListTimelineEvents@.
--
-- 'incidentRecordArn', 'getTimelineEvent_incidentRecordArn' - The Amazon Resource Name (ARN) of the incident that the timeline event
-- is part of.
newGetTimelineEvent ::
  -- | 'eventId'
  Prelude.Text ->
  -- | 'incidentRecordArn'
  Prelude.Text ->
  GetTimelineEvent
newGetTimelineEvent :: Text -> Text -> GetTimelineEvent
newGetTimelineEvent Text
pEventId_ Text
pIncidentRecordArn_ =
  GetTimelineEvent' :: Text -> Text -> GetTimelineEvent
GetTimelineEvent'
    { $sel:eventId:GetTimelineEvent' :: Text
eventId = Text
pEventId_,
      $sel:incidentRecordArn:GetTimelineEvent' :: Text
incidentRecordArn = Text
pIncidentRecordArn_
    }

-- | The ID of the event. You can get an event\'s ID when you create it or by
-- using @ListTimelineEvents@.
getTimelineEvent_eventId :: Lens.Lens' GetTimelineEvent Prelude.Text
getTimelineEvent_eventId :: (Text -> f Text) -> GetTimelineEvent -> f GetTimelineEvent
getTimelineEvent_eventId = (GetTimelineEvent -> Text)
-> (GetTimelineEvent -> Text -> GetTimelineEvent)
-> Lens GetTimelineEvent GetTimelineEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTimelineEvent' {Text
eventId :: Text
$sel:eventId:GetTimelineEvent' :: GetTimelineEvent -> Text
eventId} -> Text
eventId) (\s :: GetTimelineEvent
s@GetTimelineEvent' {} Text
a -> GetTimelineEvent
s {$sel:eventId:GetTimelineEvent' :: Text
eventId = Text
a} :: GetTimelineEvent)

-- | The Amazon Resource Name (ARN) of the incident that the timeline event
-- is part of.
getTimelineEvent_incidentRecordArn :: Lens.Lens' GetTimelineEvent Prelude.Text
getTimelineEvent_incidentRecordArn :: (Text -> f Text) -> GetTimelineEvent -> f GetTimelineEvent
getTimelineEvent_incidentRecordArn = (GetTimelineEvent -> Text)
-> (GetTimelineEvent -> Text -> GetTimelineEvent)
-> Lens GetTimelineEvent GetTimelineEvent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTimelineEvent' {Text
incidentRecordArn :: Text
$sel:incidentRecordArn:GetTimelineEvent' :: GetTimelineEvent -> Text
incidentRecordArn} -> Text
incidentRecordArn) (\s :: GetTimelineEvent
s@GetTimelineEvent' {} Text
a -> GetTimelineEvent
s {$sel:incidentRecordArn:GetTimelineEvent' :: Text
incidentRecordArn = Text
a} :: GetTimelineEvent)

instance Core.AWSRequest GetTimelineEvent where
  type
    AWSResponse GetTimelineEvent =
      GetTimelineEventResponse
  request :: GetTimelineEvent -> Request GetTimelineEvent
request = Service -> GetTimelineEvent -> Request GetTimelineEvent
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetTimelineEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetTimelineEvent)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetTimelineEvent))
-> Logger
-> Service
-> Proxy GetTimelineEvent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetTimelineEvent)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> TimelineEvent -> GetTimelineEventResponse
GetTimelineEventResponse'
            (Int -> TimelineEvent -> GetTimelineEventResponse)
-> Either String Int
-> Either String (TimelineEvent -> GetTimelineEventResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (TimelineEvent -> GetTimelineEventResponse)
-> Either String TimelineEvent
-> Either String GetTimelineEventResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String TimelineEvent
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"event")
      )

instance Prelude.Hashable GetTimelineEvent

instance Prelude.NFData GetTimelineEvent

instance Core.ToHeaders GetTimelineEvent where
  toHeaders :: GetTimelineEvent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTimelineEvent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath GetTimelineEvent where
  toPath :: GetTimelineEvent -> ByteString
toPath = ByteString -> GetTimelineEvent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/getTimelineEvent"

instance Core.ToQuery GetTimelineEvent where
  toQuery :: GetTimelineEvent -> QueryString
toQuery GetTimelineEvent' {Text
incidentRecordArn :: Text
eventId :: Text
$sel:incidentRecordArn:GetTimelineEvent' :: GetTimelineEvent -> Text
$sel:eventId:GetTimelineEvent' :: GetTimelineEvent -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"eventId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
eventId,
        ByteString
"incidentRecordArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
incidentRecordArn
      ]

-- | /See:/ 'newGetTimelineEventResponse' smart constructor.
data GetTimelineEventResponse = GetTimelineEventResponse'
  { -- | The response's http status code.
    GetTimelineEventResponse -> Int
httpStatus :: Prelude.Int,
    -- | Details about the timeline event.
    GetTimelineEventResponse -> TimelineEvent
event :: TimelineEvent
  }
  deriving (GetTimelineEventResponse -> GetTimelineEventResponse -> Bool
(GetTimelineEventResponse -> GetTimelineEventResponse -> Bool)
-> (GetTimelineEventResponse -> GetTimelineEventResponse -> Bool)
-> Eq GetTimelineEventResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTimelineEventResponse -> GetTimelineEventResponse -> Bool
$c/= :: GetTimelineEventResponse -> GetTimelineEventResponse -> Bool
== :: GetTimelineEventResponse -> GetTimelineEventResponse -> Bool
$c== :: GetTimelineEventResponse -> GetTimelineEventResponse -> Bool
Prelude.Eq, ReadPrec [GetTimelineEventResponse]
ReadPrec GetTimelineEventResponse
Int -> ReadS GetTimelineEventResponse
ReadS [GetTimelineEventResponse]
(Int -> ReadS GetTimelineEventResponse)
-> ReadS [GetTimelineEventResponse]
-> ReadPrec GetTimelineEventResponse
-> ReadPrec [GetTimelineEventResponse]
-> Read GetTimelineEventResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTimelineEventResponse]
$creadListPrec :: ReadPrec [GetTimelineEventResponse]
readPrec :: ReadPrec GetTimelineEventResponse
$creadPrec :: ReadPrec GetTimelineEventResponse
readList :: ReadS [GetTimelineEventResponse]
$creadList :: ReadS [GetTimelineEventResponse]
readsPrec :: Int -> ReadS GetTimelineEventResponse
$creadsPrec :: Int -> ReadS GetTimelineEventResponse
Prelude.Read, Int -> GetTimelineEventResponse -> ShowS
[GetTimelineEventResponse] -> ShowS
GetTimelineEventResponse -> String
(Int -> GetTimelineEventResponse -> ShowS)
-> (GetTimelineEventResponse -> String)
-> ([GetTimelineEventResponse] -> ShowS)
-> Show GetTimelineEventResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTimelineEventResponse] -> ShowS
$cshowList :: [GetTimelineEventResponse] -> ShowS
show :: GetTimelineEventResponse -> String
$cshow :: GetTimelineEventResponse -> String
showsPrec :: Int -> GetTimelineEventResponse -> ShowS
$cshowsPrec :: Int -> GetTimelineEventResponse -> ShowS
Prelude.Show, (forall x.
 GetTimelineEventResponse -> Rep GetTimelineEventResponse x)
-> (forall x.
    Rep GetTimelineEventResponse x -> GetTimelineEventResponse)
-> Generic GetTimelineEventResponse
forall x.
Rep GetTimelineEventResponse x -> GetTimelineEventResponse
forall x.
GetTimelineEventResponse -> Rep GetTimelineEventResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetTimelineEventResponse x -> GetTimelineEventResponse
$cfrom :: forall x.
GetTimelineEventResponse -> Rep GetTimelineEventResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTimelineEventResponse' 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:
--
-- 'httpStatus', 'getTimelineEventResponse_httpStatus' - The response's http status code.
--
-- 'event', 'getTimelineEventResponse_event' - Details about the timeline event.
newGetTimelineEventResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'event'
  TimelineEvent ->
  GetTimelineEventResponse
newGetTimelineEventResponse :: Int -> TimelineEvent -> GetTimelineEventResponse
newGetTimelineEventResponse Int
pHttpStatus_ TimelineEvent
pEvent_ =
  GetTimelineEventResponse' :: Int -> TimelineEvent -> GetTimelineEventResponse
GetTimelineEventResponse'
    { $sel:httpStatus:GetTimelineEventResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:event:GetTimelineEventResponse' :: TimelineEvent
event = TimelineEvent
pEvent_
    }

-- | The response's http status code.
getTimelineEventResponse_httpStatus :: Lens.Lens' GetTimelineEventResponse Prelude.Int
getTimelineEventResponse_httpStatus :: (Int -> f Int)
-> GetTimelineEventResponse -> f GetTimelineEventResponse
getTimelineEventResponse_httpStatus = (GetTimelineEventResponse -> Int)
-> (GetTimelineEventResponse -> Int -> GetTimelineEventResponse)
-> Lens GetTimelineEventResponse GetTimelineEventResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTimelineEventResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetTimelineEventResponse' :: GetTimelineEventResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetTimelineEventResponse
s@GetTimelineEventResponse' {} Int
a -> GetTimelineEventResponse
s {$sel:httpStatus:GetTimelineEventResponse' :: Int
httpStatus = Int
a} :: GetTimelineEventResponse)

-- | Details about the timeline event.
getTimelineEventResponse_event :: Lens.Lens' GetTimelineEventResponse TimelineEvent
getTimelineEventResponse_event :: (TimelineEvent -> f TimelineEvent)
-> GetTimelineEventResponse -> f GetTimelineEventResponse
getTimelineEventResponse_event = (GetTimelineEventResponse -> TimelineEvent)
-> (GetTimelineEventResponse
    -> TimelineEvent -> GetTimelineEventResponse)
-> Lens
     GetTimelineEventResponse
     GetTimelineEventResponse
     TimelineEvent
     TimelineEvent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTimelineEventResponse' {TimelineEvent
event :: TimelineEvent
$sel:event:GetTimelineEventResponse' :: GetTimelineEventResponse -> TimelineEvent
event} -> TimelineEvent
event) (\s :: GetTimelineEventResponse
s@GetTimelineEventResponse' {} TimelineEvent
a -> GetTimelineEventResponse
s {$sel:event:GetTimelineEventResponse' :: TimelineEvent
event = TimelineEvent
a} :: GetTimelineEventResponse)

instance Prelude.NFData GetTimelineEventResponse