{-# 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.ChimeSDKMessaging.GetChannelMessageStatus
-- 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)
--
-- Gets message status for a specified @messageId@. Use this API to
-- determine the intermediate status of messages going through channel flow
-- processing. The API provides an alternative to retrieving message status
-- if the event was not received because a client wasn\'t connected to a
-- websocket.
--
-- Messages can have any one of these statuses.
--
-- [SENT]
--     Message processed successfully
--
-- [PENDING]
--     Ongoing processing
--
-- [FAILED]
--     Processing failed
--
-- [DENIED]
--     Messasge denied by the processor
--
-- -   This API does not return statuses for denied messages, because we
--     don\'t store them once the processor denies them.
--
-- -   Only the message sender can invoke this API.
--
-- -   The @x-amz-chime-bearer@ request header is mandatory. Use the
--     @AppInstanceUserArn@ of the user that makes the API call as the
--     value in the header
module Amazonka.ChimeSDKMessaging.GetChannelMessageStatus
  ( -- * Creating a Request
    GetChannelMessageStatus (..),
    newGetChannelMessageStatus,

    -- * Request Lenses
    getChannelMessageStatus_channelArn,
    getChannelMessageStatus_messageId,
    getChannelMessageStatus_chimeBearer,

    -- * Destructuring the Response
    GetChannelMessageStatusResponse (..),
    newGetChannelMessageStatusResponse,

    -- * Response Lenses
    getChannelMessageStatusResponse_status,
    getChannelMessageStatusResponse_httpStatus,
  )
where

import Amazonka.ChimeSDKMessaging.Types
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

-- | /See:/ 'newGetChannelMessageStatus' smart constructor.
data GetChannelMessageStatus = GetChannelMessageStatus'
  { -- | The ARN of the channel
    GetChannelMessageStatus -> Text
channelArn :: Prelude.Text,
    -- | The ID of the message.
    GetChannelMessageStatus -> Text
messageId :: Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user making the API call.
    GetChannelMessageStatus -> Text
chimeBearer :: Prelude.Text
  }
  deriving (GetChannelMessageStatus -> GetChannelMessageStatus -> Bool
(GetChannelMessageStatus -> GetChannelMessageStatus -> Bool)
-> (GetChannelMessageStatus -> GetChannelMessageStatus -> Bool)
-> Eq GetChannelMessageStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetChannelMessageStatus -> GetChannelMessageStatus -> Bool
$c/= :: GetChannelMessageStatus -> GetChannelMessageStatus -> Bool
== :: GetChannelMessageStatus -> GetChannelMessageStatus -> Bool
$c== :: GetChannelMessageStatus -> GetChannelMessageStatus -> Bool
Prelude.Eq, ReadPrec [GetChannelMessageStatus]
ReadPrec GetChannelMessageStatus
Int -> ReadS GetChannelMessageStatus
ReadS [GetChannelMessageStatus]
(Int -> ReadS GetChannelMessageStatus)
-> ReadS [GetChannelMessageStatus]
-> ReadPrec GetChannelMessageStatus
-> ReadPrec [GetChannelMessageStatus]
-> Read GetChannelMessageStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetChannelMessageStatus]
$creadListPrec :: ReadPrec [GetChannelMessageStatus]
readPrec :: ReadPrec GetChannelMessageStatus
$creadPrec :: ReadPrec GetChannelMessageStatus
readList :: ReadS [GetChannelMessageStatus]
$creadList :: ReadS [GetChannelMessageStatus]
readsPrec :: Int -> ReadS GetChannelMessageStatus
$creadsPrec :: Int -> ReadS GetChannelMessageStatus
Prelude.Read, Int -> GetChannelMessageStatus -> ShowS
[GetChannelMessageStatus] -> ShowS
GetChannelMessageStatus -> String
(Int -> GetChannelMessageStatus -> ShowS)
-> (GetChannelMessageStatus -> String)
-> ([GetChannelMessageStatus] -> ShowS)
-> Show GetChannelMessageStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetChannelMessageStatus] -> ShowS
$cshowList :: [GetChannelMessageStatus] -> ShowS
show :: GetChannelMessageStatus -> String
$cshow :: GetChannelMessageStatus -> String
showsPrec :: Int -> GetChannelMessageStatus -> ShowS
$cshowsPrec :: Int -> GetChannelMessageStatus -> ShowS
Prelude.Show, (forall x.
 GetChannelMessageStatus -> Rep GetChannelMessageStatus x)
-> (forall x.
    Rep GetChannelMessageStatus x -> GetChannelMessageStatus)
-> Generic GetChannelMessageStatus
forall x. Rep GetChannelMessageStatus x -> GetChannelMessageStatus
forall x. GetChannelMessageStatus -> Rep GetChannelMessageStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetChannelMessageStatus x -> GetChannelMessageStatus
$cfrom :: forall x. GetChannelMessageStatus -> Rep GetChannelMessageStatus x
Prelude.Generic)

-- |
-- Create a value of 'GetChannelMessageStatus' 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:
--
-- 'channelArn', 'getChannelMessageStatus_channelArn' - The ARN of the channel
--
-- 'messageId', 'getChannelMessageStatus_messageId' - The ID of the message.
--
-- 'chimeBearer', 'getChannelMessageStatus_chimeBearer' - The @AppInstanceUserArn@ of the user making the API call.
newGetChannelMessageStatus ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'messageId'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  GetChannelMessageStatus
newGetChannelMessageStatus :: Text -> Text -> Text -> GetChannelMessageStatus
newGetChannelMessageStatus
  Text
pChannelArn_
  Text
pMessageId_
  Text
pChimeBearer_ =
    GetChannelMessageStatus' :: Text -> Text -> Text -> GetChannelMessageStatus
GetChannelMessageStatus'
      { $sel:channelArn:GetChannelMessageStatus' :: Text
channelArn = Text
pChannelArn_,
        $sel:messageId:GetChannelMessageStatus' :: Text
messageId = Text
pMessageId_,
        $sel:chimeBearer:GetChannelMessageStatus' :: Text
chimeBearer = Text
pChimeBearer_
      }

-- | The ARN of the channel
getChannelMessageStatus_channelArn :: Lens.Lens' GetChannelMessageStatus Prelude.Text
getChannelMessageStatus_channelArn :: (Text -> f Text)
-> GetChannelMessageStatus -> f GetChannelMessageStatus
getChannelMessageStatus_channelArn = (GetChannelMessageStatus -> Text)
-> (GetChannelMessageStatus -> Text -> GetChannelMessageStatus)
-> Lens GetChannelMessageStatus GetChannelMessageStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelMessageStatus' {Text
channelArn :: Text
$sel:channelArn:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
channelArn} -> Text
channelArn) (\s :: GetChannelMessageStatus
s@GetChannelMessageStatus' {} Text
a -> GetChannelMessageStatus
s {$sel:channelArn:GetChannelMessageStatus' :: Text
channelArn = Text
a} :: GetChannelMessageStatus)

-- | The ID of the message.
getChannelMessageStatus_messageId :: Lens.Lens' GetChannelMessageStatus Prelude.Text
getChannelMessageStatus_messageId :: (Text -> f Text)
-> GetChannelMessageStatus -> f GetChannelMessageStatus
getChannelMessageStatus_messageId = (GetChannelMessageStatus -> Text)
-> (GetChannelMessageStatus -> Text -> GetChannelMessageStatus)
-> Lens GetChannelMessageStatus GetChannelMessageStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelMessageStatus' {Text
messageId :: Text
$sel:messageId:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
messageId} -> Text
messageId) (\s :: GetChannelMessageStatus
s@GetChannelMessageStatus' {} Text
a -> GetChannelMessageStatus
s {$sel:messageId:GetChannelMessageStatus' :: Text
messageId = Text
a} :: GetChannelMessageStatus)

-- | The @AppInstanceUserArn@ of the user making the API call.
getChannelMessageStatus_chimeBearer :: Lens.Lens' GetChannelMessageStatus Prelude.Text
getChannelMessageStatus_chimeBearer :: (Text -> f Text)
-> GetChannelMessageStatus -> f GetChannelMessageStatus
getChannelMessageStatus_chimeBearer = (GetChannelMessageStatus -> Text)
-> (GetChannelMessageStatus -> Text -> GetChannelMessageStatus)
-> Lens GetChannelMessageStatus GetChannelMessageStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelMessageStatus' {Text
chimeBearer :: Text
$sel:chimeBearer:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
chimeBearer} -> Text
chimeBearer) (\s :: GetChannelMessageStatus
s@GetChannelMessageStatus' {} Text
a -> GetChannelMessageStatus
s {$sel:chimeBearer:GetChannelMessageStatus' :: Text
chimeBearer = Text
a} :: GetChannelMessageStatus)

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

instance Prelude.Hashable GetChannelMessageStatus

instance Prelude.NFData GetChannelMessageStatus

instance Core.ToHeaders GetChannelMessageStatus where
  toHeaders :: GetChannelMessageStatus -> ResponseHeaders
toHeaders GetChannelMessageStatus' {Text
chimeBearer :: Text
messageId :: Text
channelArn :: Text
$sel:chimeBearer:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
$sel:messageId:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
$sel:channelArn:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-chime-bearer" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
chimeBearer]

instance Core.ToPath GetChannelMessageStatus where
  toPath :: GetChannelMessageStatus -> ByteString
toPath GetChannelMessageStatus' {Text
chimeBearer :: Text
messageId :: Text
channelArn :: Text
$sel:chimeBearer:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
$sel:messageId:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
$sel:channelArn:GetChannelMessageStatus' :: GetChannelMessageStatus -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/channels/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
channelArn,
        ByteString
"/messages/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
messageId
      ]

instance Core.ToQuery GetChannelMessageStatus where
  toQuery :: GetChannelMessageStatus -> QueryString
toQuery =
    QueryString -> GetChannelMessageStatus -> QueryString
forall a b. a -> b -> a
Prelude.const
      ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"scope=message-status"])

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

-- |
-- Create a value of 'GetChannelMessageStatusResponse' 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:
--
-- 'status', 'getChannelMessageStatusResponse_status' - The message status and details.
--
-- 'httpStatus', 'getChannelMessageStatusResponse_httpStatus' - The response's http status code.
newGetChannelMessageStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetChannelMessageStatusResponse
newGetChannelMessageStatusResponse :: Int -> GetChannelMessageStatusResponse
newGetChannelMessageStatusResponse Int
pHttpStatus_ =
  GetChannelMessageStatusResponse' :: Maybe ChannelMessageStatusStructure
-> Int -> GetChannelMessageStatusResponse
GetChannelMessageStatusResponse'
    { $sel:status:GetChannelMessageStatusResponse' :: Maybe ChannelMessageStatusStructure
status =
        Maybe ChannelMessageStatusStructure
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetChannelMessageStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The message status and details.
getChannelMessageStatusResponse_status :: Lens.Lens' GetChannelMessageStatusResponse (Prelude.Maybe ChannelMessageStatusStructure)
getChannelMessageStatusResponse_status :: (Maybe ChannelMessageStatusStructure
 -> f (Maybe ChannelMessageStatusStructure))
-> GetChannelMessageStatusResponse
-> f GetChannelMessageStatusResponse
getChannelMessageStatusResponse_status = (GetChannelMessageStatusResponse
 -> Maybe ChannelMessageStatusStructure)
-> (GetChannelMessageStatusResponse
    -> Maybe ChannelMessageStatusStructure
    -> GetChannelMessageStatusResponse)
-> Lens
     GetChannelMessageStatusResponse
     GetChannelMessageStatusResponse
     (Maybe ChannelMessageStatusStructure)
     (Maybe ChannelMessageStatusStructure)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetChannelMessageStatusResponse' {Maybe ChannelMessageStatusStructure
status :: Maybe ChannelMessageStatusStructure
$sel:status:GetChannelMessageStatusResponse' :: GetChannelMessageStatusResponse
-> Maybe ChannelMessageStatusStructure
status} -> Maybe ChannelMessageStatusStructure
status) (\s :: GetChannelMessageStatusResponse
s@GetChannelMessageStatusResponse' {} Maybe ChannelMessageStatusStructure
a -> GetChannelMessageStatusResponse
s {$sel:status:GetChannelMessageStatusResponse' :: Maybe ChannelMessageStatusStructure
status = Maybe ChannelMessageStatusStructure
a} :: GetChannelMessageStatusResponse)

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

instance
  Prelude.NFData
    GetChannelMessageStatusResponse