{-# 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.GetIncidentRecord
-- 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)
--
-- Returns the details of the specified incident record.
module Amazonka.SSMIncidents.GetIncidentRecord
  ( -- * Creating a Request
    GetIncidentRecord (..),
    newGetIncidentRecord,

    -- * Request Lenses
    getIncidentRecord_arn,

    -- * Destructuring the Response
    GetIncidentRecordResponse (..),
    newGetIncidentRecordResponse,

    -- * Response Lenses
    getIncidentRecordResponse_httpStatus,
    getIncidentRecordResponse_incidentRecord,
  )
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:/ 'newGetIncidentRecord' smart constructor.
data GetIncidentRecord = GetIncidentRecord'
  { -- | The Amazon Resource Name (ARN) of the incident record.
    GetIncidentRecord -> Text
arn :: Prelude.Text
  }
  deriving (GetIncidentRecord -> GetIncidentRecord -> Bool
(GetIncidentRecord -> GetIncidentRecord -> Bool)
-> (GetIncidentRecord -> GetIncidentRecord -> Bool)
-> Eq GetIncidentRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIncidentRecord -> GetIncidentRecord -> Bool
$c/= :: GetIncidentRecord -> GetIncidentRecord -> Bool
== :: GetIncidentRecord -> GetIncidentRecord -> Bool
$c== :: GetIncidentRecord -> GetIncidentRecord -> Bool
Prelude.Eq, ReadPrec [GetIncidentRecord]
ReadPrec GetIncidentRecord
Int -> ReadS GetIncidentRecord
ReadS [GetIncidentRecord]
(Int -> ReadS GetIncidentRecord)
-> ReadS [GetIncidentRecord]
-> ReadPrec GetIncidentRecord
-> ReadPrec [GetIncidentRecord]
-> Read GetIncidentRecord
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetIncidentRecord]
$creadListPrec :: ReadPrec [GetIncidentRecord]
readPrec :: ReadPrec GetIncidentRecord
$creadPrec :: ReadPrec GetIncidentRecord
readList :: ReadS [GetIncidentRecord]
$creadList :: ReadS [GetIncidentRecord]
readsPrec :: Int -> ReadS GetIncidentRecord
$creadsPrec :: Int -> ReadS GetIncidentRecord
Prelude.Read, Int -> GetIncidentRecord -> ShowS
[GetIncidentRecord] -> ShowS
GetIncidentRecord -> String
(Int -> GetIncidentRecord -> ShowS)
-> (GetIncidentRecord -> String)
-> ([GetIncidentRecord] -> ShowS)
-> Show GetIncidentRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIncidentRecord] -> ShowS
$cshowList :: [GetIncidentRecord] -> ShowS
show :: GetIncidentRecord -> String
$cshow :: GetIncidentRecord -> String
showsPrec :: Int -> GetIncidentRecord -> ShowS
$cshowsPrec :: Int -> GetIncidentRecord -> ShowS
Prelude.Show, (forall x. GetIncidentRecord -> Rep GetIncidentRecord x)
-> (forall x. Rep GetIncidentRecord x -> GetIncidentRecord)
-> Generic GetIncidentRecord
forall x. Rep GetIncidentRecord x -> GetIncidentRecord
forall x. GetIncidentRecord -> Rep GetIncidentRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetIncidentRecord x -> GetIncidentRecord
$cfrom :: forall x. GetIncidentRecord -> Rep GetIncidentRecord x
Prelude.Generic)

-- |
-- Create a value of 'GetIncidentRecord' 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:
--
-- 'arn', 'getIncidentRecord_arn' - The Amazon Resource Name (ARN) of the incident record.
newGetIncidentRecord ::
  -- | 'arn'
  Prelude.Text ->
  GetIncidentRecord
newGetIncidentRecord :: Text -> GetIncidentRecord
newGetIncidentRecord Text
pArn_ =
  GetIncidentRecord' :: Text -> GetIncidentRecord
GetIncidentRecord' {$sel:arn:GetIncidentRecord' :: Text
arn = Text
pArn_}

-- | The Amazon Resource Name (ARN) of the incident record.
getIncidentRecord_arn :: Lens.Lens' GetIncidentRecord Prelude.Text
getIncidentRecord_arn :: (Text -> f Text) -> GetIncidentRecord -> f GetIncidentRecord
getIncidentRecord_arn = (GetIncidentRecord -> Text)
-> (GetIncidentRecord -> Text -> GetIncidentRecord)
-> Lens GetIncidentRecord GetIncidentRecord Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIncidentRecord' {Text
arn :: Text
$sel:arn:GetIncidentRecord' :: GetIncidentRecord -> Text
arn} -> Text
arn) (\s :: GetIncidentRecord
s@GetIncidentRecord' {} Text
a -> GetIncidentRecord
s {$sel:arn:GetIncidentRecord' :: Text
arn = Text
a} :: GetIncidentRecord)

instance Core.AWSRequest GetIncidentRecord where
  type
    AWSResponse GetIncidentRecord =
      GetIncidentRecordResponse
  request :: GetIncidentRecord -> Request GetIncidentRecord
request = Service -> GetIncidentRecord -> Request GetIncidentRecord
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetIncidentRecord
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetIncidentRecord)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetIncidentRecord))
-> Logger
-> Service
-> Proxy GetIncidentRecord
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetIncidentRecord)))
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 -> IncidentRecord -> GetIncidentRecordResponse
GetIncidentRecordResponse'
            (Int -> IncidentRecord -> GetIncidentRecordResponse)
-> Either String Int
-> Either String (IncidentRecord -> GetIncidentRecordResponse)
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 (IncidentRecord -> GetIncidentRecordResponse)
-> Either String IncidentRecord
-> Either String GetIncidentRecordResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String IncidentRecord
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"incidentRecord")
      )

instance Prelude.Hashable GetIncidentRecord

instance Prelude.NFData GetIncidentRecord

instance Core.ToHeaders GetIncidentRecord where
  toHeaders :: GetIncidentRecord -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetIncidentRecord -> 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 GetIncidentRecord where
  toPath :: GetIncidentRecord -> ByteString
toPath = ByteString -> GetIncidentRecord -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/getIncidentRecord"

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

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

-- |
-- Create a value of 'GetIncidentRecordResponse' 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', 'getIncidentRecordResponse_httpStatus' - The response's http status code.
--
-- 'incidentRecord', 'getIncidentRecordResponse_incidentRecord' - Details structure of the incident record.
newGetIncidentRecordResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'incidentRecord'
  IncidentRecord ->
  GetIncidentRecordResponse
newGetIncidentRecordResponse :: Int -> IncidentRecord -> GetIncidentRecordResponse
newGetIncidentRecordResponse
  Int
pHttpStatus_
  IncidentRecord
pIncidentRecord_ =
    GetIncidentRecordResponse' :: Int -> IncidentRecord -> GetIncidentRecordResponse
GetIncidentRecordResponse'
      { $sel:httpStatus:GetIncidentRecordResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:incidentRecord:GetIncidentRecordResponse' :: IncidentRecord
incidentRecord = IncidentRecord
pIncidentRecord_
      }

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

-- | Details structure of the incident record.
getIncidentRecordResponse_incidentRecord :: Lens.Lens' GetIncidentRecordResponse IncidentRecord
getIncidentRecordResponse_incidentRecord :: (IncidentRecord -> f IncidentRecord)
-> GetIncidentRecordResponse -> f GetIncidentRecordResponse
getIncidentRecordResponse_incidentRecord = (GetIncidentRecordResponse -> IncidentRecord)
-> (GetIncidentRecordResponse
    -> IncidentRecord -> GetIncidentRecordResponse)
-> Lens
     GetIncidentRecordResponse
     GetIncidentRecordResponse
     IncidentRecord
     IncidentRecord
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetIncidentRecordResponse' {IncidentRecord
incidentRecord :: IncidentRecord
$sel:incidentRecord:GetIncidentRecordResponse' :: GetIncidentRecordResponse -> IncidentRecord
incidentRecord} -> IncidentRecord
incidentRecord) (\s :: GetIncidentRecordResponse
s@GetIncidentRecordResponse' {} IncidentRecord
a -> GetIncidentRecordResponse
s {$sel:incidentRecord:GetIncidentRecordResponse' :: IncidentRecord
incidentRecord = IncidentRecord
a} :: GetIncidentRecordResponse)

instance Prelude.NFData GetIncidentRecordResponse