{-# 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.UpdateChannelReadMarker
-- 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)
--
-- The details of the time when a user last read messages in a channel.
--
-- 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.UpdateChannelReadMarker
  ( -- * Creating a Request
    UpdateChannelReadMarker (..),
    newUpdateChannelReadMarker,

    -- * Request Lenses
    updateChannelReadMarker_channelArn,
    updateChannelReadMarker_chimeBearer,

    -- * Destructuring the Response
    UpdateChannelReadMarkerResponse (..),
    newUpdateChannelReadMarkerResponse,

    -- * Response Lenses
    updateChannelReadMarkerResponse_channelArn,
    updateChannelReadMarkerResponse_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:/ 'newUpdateChannelReadMarker' smart constructor.
data UpdateChannelReadMarker = UpdateChannelReadMarker'
  { -- | The ARN of the channel.
    UpdateChannelReadMarker -> Text
channelArn :: Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user that makes the API call.
    UpdateChannelReadMarker -> Text
chimeBearer :: Prelude.Text
  }
  deriving (UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool
(UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool)
-> (UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool)
-> Eq UpdateChannelReadMarker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool
$c/= :: UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool
== :: UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool
$c== :: UpdateChannelReadMarker -> UpdateChannelReadMarker -> Bool
Prelude.Eq, ReadPrec [UpdateChannelReadMarker]
ReadPrec UpdateChannelReadMarker
Int -> ReadS UpdateChannelReadMarker
ReadS [UpdateChannelReadMarker]
(Int -> ReadS UpdateChannelReadMarker)
-> ReadS [UpdateChannelReadMarker]
-> ReadPrec UpdateChannelReadMarker
-> ReadPrec [UpdateChannelReadMarker]
-> Read UpdateChannelReadMarker
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateChannelReadMarker]
$creadListPrec :: ReadPrec [UpdateChannelReadMarker]
readPrec :: ReadPrec UpdateChannelReadMarker
$creadPrec :: ReadPrec UpdateChannelReadMarker
readList :: ReadS [UpdateChannelReadMarker]
$creadList :: ReadS [UpdateChannelReadMarker]
readsPrec :: Int -> ReadS UpdateChannelReadMarker
$creadsPrec :: Int -> ReadS UpdateChannelReadMarker
Prelude.Read, Int -> UpdateChannelReadMarker -> ShowS
[UpdateChannelReadMarker] -> ShowS
UpdateChannelReadMarker -> String
(Int -> UpdateChannelReadMarker -> ShowS)
-> (UpdateChannelReadMarker -> String)
-> ([UpdateChannelReadMarker] -> ShowS)
-> Show UpdateChannelReadMarker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateChannelReadMarker] -> ShowS
$cshowList :: [UpdateChannelReadMarker] -> ShowS
show :: UpdateChannelReadMarker -> String
$cshow :: UpdateChannelReadMarker -> String
showsPrec :: Int -> UpdateChannelReadMarker -> ShowS
$cshowsPrec :: Int -> UpdateChannelReadMarker -> ShowS
Prelude.Show, (forall x.
 UpdateChannelReadMarker -> Rep UpdateChannelReadMarker x)
-> (forall x.
    Rep UpdateChannelReadMarker x -> UpdateChannelReadMarker)
-> Generic UpdateChannelReadMarker
forall x. Rep UpdateChannelReadMarker x -> UpdateChannelReadMarker
forall x. UpdateChannelReadMarker -> Rep UpdateChannelReadMarker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateChannelReadMarker x -> UpdateChannelReadMarker
$cfrom :: forall x. UpdateChannelReadMarker -> Rep UpdateChannelReadMarker x
Prelude.Generic)

-- |
-- Create a value of 'UpdateChannelReadMarker' 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', 'updateChannelReadMarker_channelArn' - The ARN of the channel.
--
-- 'chimeBearer', 'updateChannelReadMarker_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
newUpdateChannelReadMarker ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  UpdateChannelReadMarker
newUpdateChannelReadMarker :: Text -> Text -> UpdateChannelReadMarker
newUpdateChannelReadMarker Text
pChannelArn_ Text
pChimeBearer_ =
  UpdateChannelReadMarker' :: Text -> Text -> UpdateChannelReadMarker
UpdateChannelReadMarker'
    { $sel:channelArn:UpdateChannelReadMarker' :: Text
channelArn = Text
pChannelArn_,
      $sel:chimeBearer:UpdateChannelReadMarker' :: Text
chimeBearer = Text
pChimeBearer_
    }

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

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

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

instance Prelude.NFData UpdateChannelReadMarker

instance Core.ToHeaders UpdateChannelReadMarker where
  toHeaders :: UpdateChannelReadMarker -> ResponseHeaders
toHeaders UpdateChannelReadMarker' {Text
chimeBearer :: Text
channelArn :: Text
$sel:chimeBearer:UpdateChannelReadMarker' :: UpdateChannelReadMarker -> Text
$sel:channelArn:UpdateChannelReadMarker' :: UpdateChannelReadMarker -> 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.ToJSON UpdateChannelReadMarker where
  toJSON :: UpdateChannelReadMarker -> Value
toJSON = Value -> UpdateChannelReadMarker -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath UpdateChannelReadMarker where
  toPath :: UpdateChannelReadMarker -> ByteString
toPath UpdateChannelReadMarker' {Text
chimeBearer :: Text
channelArn :: Text
$sel:chimeBearer:UpdateChannelReadMarker' :: UpdateChannelReadMarker -> Text
$sel:channelArn:UpdateChannelReadMarker' :: UpdateChannelReadMarker -> 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
"/readMarker"]

instance Core.ToQuery UpdateChannelReadMarker where
  toQuery :: UpdateChannelReadMarker -> QueryString
toQuery = QueryString -> UpdateChannelReadMarker -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'UpdateChannelReadMarkerResponse' 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', 'updateChannelReadMarkerResponse_channelArn' - The ARN of the channel.
--
-- 'httpStatus', 'updateChannelReadMarkerResponse_httpStatus' - The response's http status code.
newUpdateChannelReadMarkerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateChannelReadMarkerResponse
newUpdateChannelReadMarkerResponse :: Int -> UpdateChannelReadMarkerResponse
newUpdateChannelReadMarkerResponse Int
pHttpStatus_ =
  UpdateChannelReadMarkerResponse' :: Maybe Text -> Int -> UpdateChannelReadMarkerResponse
UpdateChannelReadMarkerResponse'
    { $sel:channelArn:UpdateChannelReadMarkerResponse' :: Maybe Text
channelArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateChannelReadMarkerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance
  Prelude.NFData
    UpdateChannelReadMarkerResponse