{-# 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.Chime.LogoutUser
-- 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)
--
-- Logs out the specified user from all of the devices they are currently
-- logged into.
module Amazonka.Chime.LogoutUser
  ( -- * Creating a Request
    LogoutUser (..),
    newLogoutUser,

    -- * Request Lenses
    logoutUser_accountId,
    logoutUser_userId,

    -- * Destructuring the Response
    LogoutUserResponse (..),
    newLogoutUserResponse,

    -- * Response Lenses
    logoutUserResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newLogoutUser' smart constructor.
data LogoutUser = LogoutUser'
  { -- | The Amazon Chime account ID.
    LogoutUser -> Text
accountId :: Prelude.Text,
    -- | The user ID.
    LogoutUser -> Text
userId :: Prelude.Text
  }
  deriving (LogoutUser -> LogoutUser -> Bool
(LogoutUser -> LogoutUser -> Bool)
-> (LogoutUser -> LogoutUser -> Bool) -> Eq LogoutUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogoutUser -> LogoutUser -> Bool
$c/= :: LogoutUser -> LogoutUser -> Bool
== :: LogoutUser -> LogoutUser -> Bool
$c== :: LogoutUser -> LogoutUser -> Bool
Prelude.Eq, ReadPrec [LogoutUser]
ReadPrec LogoutUser
Int -> ReadS LogoutUser
ReadS [LogoutUser]
(Int -> ReadS LogoutUser)
-> ReadS [LogoutUser]
-> ReadPrec LogoutUser
-> ReadPrec [LogoutUser]
-> Read LogoutUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogoutUser]
$creadListPrec :: ReadPrec [LogoutUser]
readPrec :: ReadPrec LogoutUser
$creadPrec :: ReadPrec LogoutUser
readList :: ReadS [LogoutUser]
$creadList :: ReadS [LogoutUser]
readsPrec :: Int -> ReadS LogoutUser
$creadsPrec :: Int -> ReadS LogoutUser
Prelude.Read, Int -> LogoutUser -> ShowS
[LogoutUser] -> ShowS
LogoutUser -> String
(Int -> LogoutUser -> ShowS)
-> (LogoutUser -> String)
-> ([LogoutUser] -> ShowS)
-> Show LogoutUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogoutUser] -> ShowS
$cshowList :: [LogoutUser] -> ShowS
show :: LogoutUser -> String
$cshow :: LogoutUser -> String
showsPrec :: Int -> LogoutUser -> ShowS
$cshowsPrec :: Int -> LogoutUser -> ShowS
Prelude.Show, (forall x. LogoutUser -> Rep LogoutUser x)
-> (forall x. Rep LogoutUser x -> LogoutUser) -> Generic LogoutUser
forall x. Rep LogoutUser x -> LogoutUser
forall x. LogoutUser -> Rep LogoutUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogoutUser x -> LogoutUser
$cfrom :: forall x. LogoutUser -> Rep LogoutUser x
Prelude.Generic)

-- |
-- Create a value of 'LogoutUser' 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:
--
-- 'accountId', 'logoutUser_accountId' - The Amazon Chime account ID.
--
-- 'userId', 'logoutUser_userId' - The user ID.
newLogoutUser ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  LogoutUser
newLogoutUser :: Text -> Text -> LogoutUser
newLogoutUser Text
pAccountId_ Text
pUserId_ =
  LogoutUser' :: Text -> Text -> LogoutUser
LogoutUser'
    { $sel:accountId:LogoutUser' :: Text
accountId = Text
pAccountId_,
      $sel:userId:LogoutUser' :: Text
userId = Text
pUserId_
    }

-- | The Amazon Chime account ID.
logoutUser_accountId :: Lens.Lens' LogoutUser Prelude.Text
logoutUser_accountId :: (Text -> f Text) -> LogoutUser -> f LogoutUser
logoutUser_accountId = (LogoutUser -> Text)
-> (LogoutUser -> Text -> LogoutUser)
-> Lens LogoutUser LogoutUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogoutUser' {Text
accountId :: Text
$sel:accountId:LogoutUser' :: LogoutUser -> Text
accountId} -> Text
accountId) (\s :: LogoutUser
s@LogoutUser' {} Text
a -> LogoutUser
s {$sel:accountId:LogoutUser' :: Text
accountId = Text
a} :: LogoutUser)

-- | The user ID.
logoutUser_userId :: Lens.Lens' LogoutUser Prelude.Text
logoutUser_userId :: (Text -> f Text) -> LogoutUser -> f LogoutUser
logoutUser_userId = (LogoutUser -> Text)
-> (LogoutUser -> Text -> LogoutUser)
-> Lens LogoutUser LogoutUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogoutUser' {Text
userId :: Text
$sel:userId:LogoutUser' :: LogoutUser -> Text
userId} -> Text
userId) (\s :: LogoutUser
s@LogoutUser' {} Text
a -> LogoutUser
s {$sel:userId:LogoutUser' :: Text
userId = Text
a} :: LogoutUser)

instance Core.AWSRequest LogoutUser where
  type AWSResponse LogoutUser = LogoutUserResponse
  request :: LogoutUser -> Request LogoutUser
request = Service -> LogoutUser -> Request LogoutUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy LogoutUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse LogoutUser)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse LogoutUser))
-> Logger
-> Service
-> Proxy LogoutUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse LogoutUser)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> LogoutUserResponse
LogoutUserResponse'
            (Int -> LogoutUserResponse)
-> Either String Int -> Either String LogoutUserResponse
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))
      )

instance Prelude.Hashable LogoutUser

instance Prelude.NFData LogoutUser

instance Core.ToHeaders LogoutUser where
  toHeaders :: LogoutUser -> ResponseHeaders
toHeaders = ResponseHeaders -> LogoutUser -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON LogoutUser where
  toJSON :: LogoutUser -> Value
toJSON = Value -> LogoutUser -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath LogoutUser where
  toPath :: LogoutUser -> ByteString
toPath LogoutUser' {Text
userId :: Text
accountId :: Text
$sel:userId:LogoutUser' :: LogoutUser -> Text
$sel:accountId:LogoutUser' :: LogoutUser -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/users/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId
      ]

instance Core.ToQuery LogoutUser where
  toQuery :: LogoutUser -> QueryString
toQuery =
    QueryString -> LogoutUser -> QueryString
forall a b. a -> b -> a
Prelude.const
      ([QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"operation=logout"])

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

-- |
-- Create a value of 'LogoutUserResponse' 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', 'logoutUserResponse_httpStatus' - The response's http status code.
newLogoutUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  LogoutUserResponse
newLogoutUserResponse :: Int -> LogoutUserResponse
newLogoutUserResponse Int
pHttpStatus_ =
  LogoutUserResponse' :: Int -> LogoutUserResponse
LogoutUserResponse' {$sel:httpStatus:LogoutUserResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData LogoutUserResponse