{-# 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.BatchSuspendUser
-- 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)
--
-- Suspends up to 50 users from a @Team@ or @EnterpriseLWA@ Amazon Chime
-- account. For more information about different account types, see
-- <https://docs.aws.amazon.com/chime/latest/ag/manage-chime-account.html Managing Your Amazon Chime Accounts>
-- in the /Amazon Chime Administration Guide/.
--
-- Users suspended from a @Team@ account are disassociated from the
-- account,but they can continue to use Amazon Chime as free users. To
-- remove the suspension from suspended @Team@ account users, invite them
-- to the @Team@ account again. You can use the InviteUsers action to do
-- so.
--
-- Users suspended from an @EnterpriseLWA@ account are immediately signed
-- out of Amazon Chime and can no longer sign in. To remove the suspension
-- from suspended @EnterpriseLWA@ account users, use the BatchUnsuspendUser
-- action.
--
-- To sign out users without suspending them, use the LogoutUser action.
module Amazonka.Chime.BatchSuspendUser
  ( -- * Creating a Request
    BatchSuspendUser (..),
    newBatchSuspendUser,

    -- * Request Lenses
    batchSuspendUser_accountId,
    batchSuspendUser_userIdList,

    -- * Destructuring the Response
    BatchSuspendUserResponse (..),
    newBatchSuspendUserResponse,

    -- * Response Lenses
    batchSuspendUserResponse_userErrors,
    batchSuspendUserResponse_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:/ 'newBatchSuspendUser' smart constructor.
data BatchSuspendUser = BatchSuspendUser'
  { -- | The Amazon Chime account ID.
    BatchSuspendUser -> Text
accountId :: Prelude.Text,
    -- | The request containing the user IDs to suspend.
    BatchSuspendUser -> [Text]
userIdList :: [Prelude.Text]
  }
  deriving (BatchSuspendUser -> BatchSuspendUser -> Bool
(BatchSuspendUser -> BatchSuspendUser -> Bool)
-> (BatchSuspendUser -> BatchSuspendUser -> Bool)
-> Eq BatchSuspendUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchSuspendUser -> BatchSuspendUser -> Bool
$c/= :: BatchSuspendUser -> BatchSuspendUser -> Bool
== :: BatchSuspendUser -> BatchSuspendUser -> Bool
$c== :: BatchSuspendUser -> BatchSuspendUser -> Bool
Prelude.Eq, ReadPrec [BatchSuspendUser]
ReadPrec BatchSuspendUser
Int -> ReadS BatchSuspendUser
ReadS [BatchSuspendUser]
(Int -> ReadS BatchSuspendUser)
-> ReadS [BatchSuspendUser]
-> ReadPrec BatchSuspendUser
-> ReadPrec [BatchSuspendUser]
-> Read BatchSuspendUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchSuspendUser]
$creadListPrec :: ReadPrec [BatchSuspendUser]
readPrec :: ReadPrec BatchSuspendUser
$creadPrec :: ReadPrec BatchSuspendUser
readList :: ReadS [BatchSuspendUser]
$creadList :: ReadS [BatchSuspendUser]
readsPrec :: Int -> ReadS BatchSuspendUser
$creadsPrec :: Int -> ReadS BatchSuspendUser
Prelude.Read, Int -> BatchSuspendUser -> ShowS
[BatchSuspendUser] -> ShowS
BatchSuspendUser -> String
(Int -> BatchSuspendUser -> ShowS)
-> (BatchSuspendUser -> String)
-> ([BatchSuspendUser] -> ShowS)
-> Show BatchSuspendUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchSuspendUser] -> ShowS
$cshowList :: [BatchSuspendUser] -> ShowS
show :: BatchSuspendUser -> String
$cshow :: BatchSuspendUser -> String
showsPrec :: Int -> BatchSuspendUser -> ShowS
$cshowsPrec :: Int -> BatchSuspendUser -> ShowS
Prelude.Show, (forall x. BatchSuspendUser -> Rep BatchSuspendUser x)
-> (forall x. Rep BatchSuspendUser x -> BatchSuspendUser)
-> Generic BatchSuspendUser
forall x. Rep BatchSuspendUser x -> BatchSuspendUser
forall x. BatchSuspendUser -> Rep BatchSuspendUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchSuspendUser x -> BatchSuspendUser
$cfrom :: forall x. BatchSuspendUser -> Rep BatchSuspendUser x
Prelude.Generic)

-- |
-- Create a value of 'BatchSuspendUser' 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', 'batchSuspendUser_accountId' - The Amazon Chime account ID.
--
-- 'userIdList', 'batchSuspendUser_userIdList' - The request containing the user IDs to suspend.
newBatchSuspendUser ::
  -- | 'accountId'
  Prelude.Text ->
  BatchSuspendUser
newBatchSuspendUser :: Text -> BatchSuspendUser
newBatchSuspendUser Text
pAccountId_ =
  BatchSuspendUser' :: Text -> [Text] -> BatchSuspendUser
BatchSuspendUser'
    { $sel:accountId:BatchSuspendUser' :: Text
accountId = Text
pAccountId_,
      $sel:userIdList:BatchSuspendUser' :: [Text]
userIdList = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

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

-- | The request containing the user IDs to suspend.
batchSuspendUser_userIdList :: Lens.Lens' BatchSuspendUser [Prelude.Text]
batchSuspendUser_userIdList :: ([Text] -> f [Text]) -> BatchSuspendUser -> f BatchSuspendUser
batchSuspendUser_userIdList = (BatchSuspendUser -> [Text])
-> (BatchSuspendUser -> [Text] -> BatchSuspendUser)
-> Lens BatchSuspendUser BatchSuspendUser [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchSuspendUser' {[Text]
userIdList :: [Text]
$sel:userIdList:BatchSuspendUser' :: BatchSuspendUser -> [Text]
userIdList} -> [Text]
userIdList) (\s :: BatchSuspendUser
s@BatchSuspendUser' {} [Text]
a -> BatchSuspendUser
s {$sel:userIdList:BatchSuspendUser' :: [Text]
userIdList = [Text]
a} :: BatchSuspendUser) (([Text] -> f [Text]) -> BatchSuspendUser -> f BatchSuspendUser)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> BatchSuspendUser
-> f BatchSuspendUser
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchSuspendUser where
  type
    AWSResponse BatchSuspendUser =
      BatchSuspendUserResponse
  request :: BatchSuspendUser -> Request BatchSuspendUser
request = Service -> BatchSuspendUser -> Request BatchSuspendUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchSuspendUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchSuspendUser)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchSuspendUser))
-> Logger
-> Service
-> Proxy BatchSuspendUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchSuspendUser)))
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 [UserError] -> Int -> BatchSuspendUserResponse
BatchSuspendUserResponse'
            (Maybe [UserError] -> Int -> BatchSuspendUserResponse)
-> Either String (Maybe [UserError])
-> Either String (Int -> BatchSuspendUserResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [UserError]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserErrors" Either String (Maybe (Maybe [UserError]))
-> Maybe [UserError] -> Either String (Maybe [UserError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UserError]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> BatchSuspendUserResponse)
-> Either String Int -> Either String BatchSuspendUserResponse
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 BatchSuspendUser

instance Prelude.NFData BatchSuspendUser

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

instance Core.ToJSON BatchSuspendUser where
  toJSON :: BatchSuspendUser -> Value
toJSON BatchSuspendUser' {[Text]
Text
userIdList :: [Text]
accountId :: Text
$sel:userIdList:BatchSuspendUser' :: BatchSuspendUser -> [Text]
$sel:accountId:BatchSuspendUser' :: BatchSuspendUser -> 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
"UserIdList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
userIdList)]
      )

instance Core.ToPath BatchSuspendUser where
  toPath :: BatchSuspendUser -> ByteString
toPath BatchSuspendUser' {[Text]
Text
userIdList :: [Text]
accountId :: Text
$sel:userIdList:BatchSuspendUser' :: BatchSuspendUser -> [Text]
$sel:accountId:BatchSuspendUser' :: BatchSuspendUser -> 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"]

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

-- | /See:/ 'newBatchSuspendUserResponse' smart constructor.
data BatchSuspendUserResponse = BatchSuspendUserResponse'
  { -- | If the BatchSuspendUser action fails for one or more of the user IDs in
    -- the request, a list of the user IDs is returned, along with error codes
    -- and error messages.
    BatchSuspendUserResponse -> Maybe [UserError]
userErrors :: Prelude.Maybe [UserError],
    -- | The response's http status code.
    BatchSuspendUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool
(BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool)
-> (BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool)
-> Eq BatchSuspendUserResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool
$c/= :: BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool
== :: BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool
$c== :: BatchSuspendUserResponse -> BatchSuspendUserResponse -> Bool
Prelude.Eq, ReadPrec [BatchSuspendUserResponse]
ReadPrec BatchSuspendUserResponse
Int -> ReadS BatchSuspendUserResponse
ReadS [BatchSuspendUserResponse]
(Int -> ReadS BatchSuspendUserResponse)
-> ReadS [BatchSuspendUserResponse]
-> ReadPrec BatchSuspendUserResponse
-> ReadPrec [BatchSuspendUserResponse]
-> Read BatchSuspendUserResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchSuspendUserResponse]
$creadListPrec :: ReadPrec [BatchSuspendUserResponse]
readPrec :: ReadPrec BatchSuspendUserResponse
$creadPrec :: ReadPrec BatchSuspendUserResponse
readList :: ReadS [BatchSuspendUserResponse]
$creadList :: ReadS [BatchSuspendUserResponse]
readsPrec :: Int -> ReadS BatchSuspendUserResponse
$creadsPrec :: Int -> ReadS BatchSuspendUserResponse
Prelude.Read, Int -> BatchSuspendUserResponse -> ShowS
[BatchSuspendUserResponse] -> ShowS
BatchSuspendUserResponse -> String
(Int -> BatchSuspendUserResponse -> ShowS)
-> (BatchSuspendUserResponse -> String)
-> ([BatchSuspendUserResponse] -> ShowS)
-> Show BatchSuspendUserResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchSuspendUserResponse] -> ShowS
$cshowList :: [BatchSuspendUserResponse] -> ShowS
show :: BatchSuspendUserResponse -> String
$cshow :: BatchSuspendUserResponse -> String
showsPrec :: Int -> BatchSuspendUserResponse -> ShowS
$cshowsPrec :: Int -> BatchSuspendUserResponse -> ShowS
Prelude.Show, (forall x.
 BatchSuspendUserResponse -> Rep BatchSuspendUserResponse x)
-> (forall x.
    Rep BatchSuspendUserResponse x -> BatchSuspendUserResponse)
-> Generic BatchSuspendUserResponse
forall x.
Rep BatchSuspendUserResponse x -> BatchSuspendUserResponse
forall x.
BatchSuspendUserResponse -> Rep BatchSuspendUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchSuspendUserResponse x -> BatchSuspendUserResponse
$cfrom :: forall x.
BatchSuspendUserResponse -> Rep BatchSuspendUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchSuspendUserResponse' 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:
--
-- 'userErrors', 'batchSuspendUserResponse_userErrors' - If the BatchSuspendUser action fails for one or more of the user IDs in
-- the request, a list of the user IDs is returned, along with error codes
-- and error messages.
--
-- 'httpStatus', 'batchSuspendUserResponse_httpStatus' - The response's http status code.
newBatchSuspendUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchSuspendUserResponse
newBatchSuspendUserResponse :: Int -> BatchSuspendUserResponse
newBatchSuspendUserResponse Int
pHttpStatus_ =
  BatchSuspendUserResponse' :: Maybe [UserError] -> Int -> BatchSuspendUserResponse
BatchSuspendUserResponse'
    { $sel:userErrors:BatchSuspendUserResponse' :: Maybe [UserError]
userErrors =
        Maybe [UserError]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchSuspendUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the BatchSuspendUser action fails for one or more of the user IDs in
-- the request, a list of the user IDs is returned, along with error codes
-- and error messages.
batchSuspendUserResponse_userErrors :: Lens.Lens' BatchSuspendUserResponse (Prelude.Maybe [UserError])
batchSuspendUserResponse_userErrors :: (Maybe [UserError] -> f (Maybe [UserError]))
-> BatchSuspendUserResponse -> f BatchSuspendUserResponse
batchSuspendUserResponse_userErrors = (BatchSuspendUserResponse -> Maybe [UserError])
-> (BatchSuspendUserResponse
    -> Maybe [UserError] -> BatchSuspendUserResponse)
-> Lens
     BatchSuspendUserResponse
     BatchSuspendUserResponse
     (Maybe [UserError])
     (Maybe [UserError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchSuspendUserResponse' {Maybe [UserError]
userErrors :: Maybe [UserError]
$sel:userErrors:BatchSuspendUserResponse' :: BatchSuspendUserResponse -> Maybe [UserError]
userErrors} -> Maybe [UserError]
userErrors) (\s :: BatchSuspendUserResponse
s@BatchSuspendUserResponse' {} Maybe [UserError]
a -> BatchSuspendUserResponse
s {$sel:userErrors:BatchSuspendUserResponse' :: Maybe [UserError]
userErrors = Maybe [UserError]
a} :: BatchSuspendUserResponse) ((Maybe [UserError] -> f (Maybe [UserError]))
 -> BatchSuspendUserResponse -> f BatchSuspendUserResponse)
-> ((Maybe [UserError] -> f (Maybe [UserError]))
    -> Maybe [UserError] -> f (Maybe [UserError]))
-> (Maybe [UserError] -> f (Maybe [UserError]))
-> BatchSuspendUserResponse
-> f BatchSuspendUserResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UserError] [UserError] [UserError] [UserError]
-> Iso
     (Maybe [UserError])
     (Maybe [UserError])
     (Maybe [UserError])
     (Maybe [UserError])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [UserError] [UserError] [UserError] [UserError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchSuspendUserResponse