{-# 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.WorkLink.SignOutUser
-- 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)
--
-- Signs the user out from all of their devices. The user can sign in again
-- if they have valid credentials.
module Amazonka.WorkLink.SignOutUser
  ( -- * Creating a Request
    SignOutUser (..),
    newSignOutUser,

    -- * Request Lenses
    signOutUser_fleetArn,
    signOutUser_username,

    -- * Destructuring the Response
    SignOutUserResponse (..),
    newSignOutUserResponse,

    -- * Response Lenses
    signOutUserResponse_httpStatus,
  )
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.WorkLink.Types

-- | /See:/ 'newSignOutUser' smart constructor.
data SignOutUser = SignOutUser'
  { -- | The ARN of the fleet.
    SignOutUser -> Text
fleetArn :: Prelude.Text,
    -- | The name of the user.
    SignOutUser -> Text
username :: Prelude.Text
  }
  deriving (SignOutUser -> SignOutUser -> Bool
(SignOutUser -> SignOutUser -> Bool)
-> (SignOutUser -> SignOutUser -> Bool) -> Eq SignOutUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignOutUser -> SignOutUser -> Bool
$c/= :: SignOutUser -> SignOutUser -> Bool
== :: SignOutUser -> SignOutUser -> Bool
$c== :: SignOutUser -> SignOutUser -> Bool
Prelude.Eq, ReadPrec [SignOutUser]
ReadPrec SignOutUser
Int -> ReadS SignOutUser
ReadS [SignOutUser]
(Int -> ReadS SignOutUser)
-> ReadS [SignOutUser]
-> ReadPrec SignOutUser
-> ReadPrec [SignOutUser]
-> Read SignOutUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignOutUser]
$creadListPrec :: ReadPrec [SignOutUser]
readPrec :: ReadPrec SignOutUser
$creadPrec :: ReadPrec SignOutUser
readList :: ReadS [SignOutUser]
$creadList :: ReadS [SignOutUser]
readsPrec :: Int -> ReadS SignOutUser
$creadsPrec :: Int -> ReadS SignOutUser
Prelude.Read, Int -> SignOutUser -> ShowS
[SignOutUser] -> ShowS
SignOutUser -> String
(Int -> SignOutUser -> ShowS)
-> (SignOutUser -> String)
-> ([SignOutUser] -> ShowS)
-> Show SignOutUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignOutUser] -> ShowS
$cshowList :: [SignOutUser] -> ShowS
show :: SignOutUser -> String
$cshow :: SignOutUser -> String
showsPrec :: Int -> SignOutUser -> ShowS
$cshowsPrec :: Int -> SignOutUser -> ShowS
Prelude.Show, (forall x. SignOutUser -> Rep SignOutUser x)
-> (forall x. Rep SignOutUser x -> SignOutUser)
-> Generic SignOutUser
forall x. Rep SignOutUser x -> SignOutUser
forall x. SignOutUser -> Rep SignOutUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignOutUser x -> SignOutUser
$cfrom :: forall x. SignOutUser -> Rep SignOutUser x
Prelude.Generic)

-- |
-- Create a value of 'SignOutUser' 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:
--
-- 'fleetArn', 'signOutUser_fleetArn' - The ARN of the fleet.
--
-- 'username', 'signOutUser_username' - The name of the user.
newSignOutUser ::
  -- | 'fleetArn'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  SignOutUser
newSignOutUser :: Text -> Text -> SignOutUser
newSignOutUser Text
pFleetArn_ Text
pUsername_ =
  SignOutUser' :: Text -> Text -> SignOutUser
SignOutUser'
    { $sel:fleetArn:SignOutUser' :: Text
fleetArn = Text
pFleetArn_,
      $sel:username:SignOutUser' :: Text
username = Text
pUsername_
    }

-- | The ARN of the fleet.
signOutUser_fleetArn :: Lens.Lens' SignOutUser Prelude.Text
signOutUser_fleetArn :: (Text -> f Text) -> SignOutUser -> f SignOutUser
signOutUser_fleetArn = (SignOutUser -> Text)
-> (SignOutUser -> Text -> SignOutUser)
-> Lens SignOutUser SignOutUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignOutUser' {Text
fleetArn :: Text
$sel:fleetArn:SignOutUser' :: SignOutUser -> Text
fleetArn} -> Text
fleetArn) (\s :: SignOutUser
s@SignOutUser' {} Text
a -> SignOutUser
s {$sel:fleetArn:SignOutUser' :: Text
fleetArn = Text
a} :: SignOutUser)

-- | The name of the user.
signOutUser_username :: Lens.Lens' SignOutUser Prelude.Text
signOutUser_username :: (Text -> f Text) -> SignOutUser -> f SignOutUser
signOutUser_username = (SignOutUser -> Text)
-> (SignOutUser -> Text -> SignOutUser)
-> Lens SignOutUser SignOutUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignOutUser' {Text
username :: Text
$sel:username:SignOutUser' :: SignOutUser -> Text
username} -> Text
username) (\s :: SignOutUser
s@SignOutUser' {} Text
a -> SignOutUser
s {$sel:username:SignOutUser' :: Text
username = Text
a} :: SignOutUser)

instance Core.AWSRequest SignOutUser where
  type AWSResponse SignOutUser = SignOutUserResponse
  request :: SignOutUser -> Request SignOutUser
request = Service -> SignOutUser -> Request SignOutUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SignOutUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SignOutUser)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse SignOutUser))
-> Logger
-> Service
-> Proxy SignOutUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SignOutUser)))
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 -> SignOutUserResponse
SignOutUserResponse'
            (Int -> SignOutUserResponse)
-> Either String Int -> Either String SignOutUserResponse
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 SignOutUser

instance Prelude.NFData SignOutUser

instance Core.ToHeaders SignOutUser where
  toHeaders :: SignOutUser -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SignOutUser -> 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.ToJSON SignOutUser where
  toJSON :: SignOutUser -> Value
toJSON SignOutUser' {Text
username :: Text
fleetArn :: Text
$sel:username:SignOutUser' :: SignOutUser -> Text
$sel:fleetArn:SignOutUser' :: SignOutUser -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FleetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleetArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
username)
          ]
      )

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

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

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

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

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

instance Prelude.NFData SignOutUserResponse