{-# 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.UpdateUser
-- 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)
--
-- Updates user details for a specified user ID. Currently, only
-- @LicenseType@ updates are supported for this action.
module Amazonka.Chime.UpdateUser
  ( -- * Creating a Request
    UpdateUser (..),
    newUpdateUser,

    -- * Request Lenses
    updateUser_licenseType,
    updateUser_userType,
    updateUser_alexaForBusinessMetadata,
    updateUser_accountId,
    updateUser_userId,

    -- * Destructuring the Response
    UpdateUserResponse (..),
    newUpdateUserResponse,

    -- * Response Lenses
    updateUserResponse_user,
    updateUserResponse_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:/ 'newUpdateUser' smart constructor.
data UpdateUser = UpdateUser'
  { -- | The user license type to update. This must be a supported license type
    -- for the Amazon Chime account that the user belongs to.
    UpdateUser -> Maybe License
licenseType :: Prelude.Maybe License,
    -- | The user type.
    UpdateUser -> Maybe UserType
userType :: Prelude.Maybe UserType,
    -- | The Alexa for Business metadata.
    UpdateUser -> Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata :: Prelude.Maybe AlexaForBusinessMetadata,
    -- | The Amazon Chime account ID.
    UpdateUser -> Text
accountId :: Prelude.Text,
    -- | The user ID.
    UpdateUser -> Text
userId :: Prelude.Text
  }
  deriving (UpdateUser -> UpdateUser -> Bool
(UpdateUser -> UpdateUser -> Bool)
-> (UpdateUser -> UpdateUser -> Bool) -> Eq UpdateUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUser -> UpdateUser -> Bool
$c/= :: UpdateUser -> UpdateUser -> Bool
== :: UpdateUser -> UpdateUser -> Bool
$c== :: UpdateUser -> UpdateUser -> Bool
Prelude.Eq, Int -> UpdateUser -> ShowS
[UpdateUser] -> ShowS
UpdateUser -> String
(Int -> UpdateUser -> ShowS)
-> (UpdateUser -> String)
-> ([UpdateUser] -> ShowS)
-> Show UpdateUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUser] -> ShowS
$cshowList :: [UpdateUser] -> ShowS
show :: UpdateUser -> String
$cshow :: UpdateUser -> String
showsPrec :: Int -> UpdateUser -> ShowS
$cshowsPrec :: Int -> UpdateUser -> ShowS
Prelude.Show, (forall x. UpdateUser -> Rep UpdateUser x)
-> (forall x. Rep UpdateUser x -> UpdateUser) -> Generic UpdateUser
forall x. Rep UpdateUser x -> UpdateUser
forall x. UpdateUser -> Rep UpdateUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUser x -> UpdateUser
$cfrom :: forall x. UpdateUser -> Rep UpdateUser x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUser' 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:
--
-- 'licenseType', 'updateUser_licenseType' - The user license type to update. This must be a supported license type
-- for the Amazon Chime account that the user belongs to.
--
-- 'userType', 'updateUser_userType' - The user type.
--
-- 'alexaForBusinessMetadata', 'updateUser_alexaForBusinessMetadata' - The Alexa for Business metadata.
--
-- 'accountId', 'updateUser_accountId' - The Amazon Chime account ID.
--
-- 'userId', 'updateUser_userId' - The user ID.
newUpdateUser ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  UpdateUser
newUpdateUser :: Text -> Text -> UpdateUser
newUpdateUser Text
pAccountId_ Text
pUserId_ =
  UpdateUser' :: Maybe License
-> Maybe UserType
-> Maybe AlexaForBusinessMetadata
-> Text
-> Text
-> UpdateUser
UpdateUser'
    { $sel:licenseType:UpdateUser' :: Maybe License
licenseType = Maybe License
forall a. Maybe a
Prelude.Nothing,
      $sel:userType:UpdateUser' :: Maybe UserType
userType = Maybe UserType
forall a. Maybe a
Prelude.Nothing,
      $sel:alexaForBusinessMetadata:UpdateUser' :: Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata = Maybe AlexaForBusinessMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:UpdateUser' :: Text
accountId = Text
pAccountId_,
      $sel:userId:UpdateUser' :: Text
userId = Text
pUserId_
    }

-- | The user license type to update. This must be a supported license type
-- for the Amazon Chime account that the user belongs to.
updateUser_licenseType :: Lens.Lens' UpdateUser (Prelude.Maybe License)
updateUser_licenseType :: (Maybe License -> f (Maybe License)) -> UpdateUser -> f UpdateUser
updateUser_licenseType = (UpdateUser -> Maybe License)
-> (UpdateUser -> Maybe License -> UpdateUser)
-> Lens UpdateUser UpdateUser (Maybe License) (Maybe License)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Maybe License
licenseType :: Maybe License
$sel:licenseType:UpdateUser' :: UpdateUser -> Maybe License
licenseType} -> Maybe License
licenseType) (\s :: UpdateUser
s@UpdateUser' {} Maybe License
a -> UpdateUser
s {$sel:licenseType:UpdateUser' :: Maybe License
licenseType = Maybe License
a} :: UpdateUser)

-- | The user type.
updateUser_userType :: Lens.Lens' UpdateUser (Prelude.Maybe UserType)
updateUser_userType :: (Maybe UserType -> f (Maybe UserType))
-> UpdateUser -> f UpdateUser
updateUser_userType = (UpdateUser -> Maybe UserType)
-> (UpdateUser -> Maybe UserType -> UpdateUser)
-> Lens UpdateUser UpdateUser (Maybe UserType) (Maybe UserType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Maybe UserType
userType :: Maybe UserType
$sel:userType:UpdateUser' :: UpdateUser -> Maybe UserType
userType} -> Maybe UserType
userType) (\s :: UpdateUser
s@UpdateUser' {} Maybe UserType
a -> UpdateUser
s {$sel:userType:UpdateUser' :: Maybe UserType
userType = Maybe UserType
a} :: UpdateUser)

-- | The Alexa for Business metadata.
updateUser_alexaForBusinessMetadata :: Lens.Lens' UpdateUser (Prelude.Maybe AlexaForBusinessMetadata)
updateUser_alexaForBusinessMetadata :: (Maybe AlexaForBusinessMetadata
 -> f (Maybe AlexaForBusinessMetadata))
-> UpdateUser -> f UpdateUser
updateUser_alexaForBusinessMetadata = (UpdateUser -> Maybe AlexaForBusinessMetadata)
-> (UpdateUser -> Maybe AlexaForBusinessMetadata -> UpdateUser)
-> Lens
     UpdateUser
     UpdateUser
     (Maybe AlexaForBusinessMetadata)
     (Maybe AlexaForBusinessMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUser' {Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata :: Maybe AlexaForBusinessMetadata
$sel:alexaForBusinessMetadata:UpdateUser' :: UpdateUser -> Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata} -> Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata) (\s :: UpdateUser
s@UpdateUser' {} Maybe AlexaForBusinessMetadata
a -> UpdateUser
s {$sel:alexaForBusinessMetadata:UpdateUser' :: Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata = Maybe AlexaForBusinessMetadata
a} :: UpdateUser)

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

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

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

instance Prelude.NFData UpdateUser

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

instance Core.ToJSON UpdateUser where
  toJSON :: UpdateUser -> Value
toJSON UpdateUser' {Maybe AlexaForBusinessMetadata
Maybe License
Maybe UserType
Text
userId :: Text
accountId :: Text
alexaForBusinessMetadata :: Maybe AlexaForBusinessMetadata
userType :: Maybe UserType
licenseType :: Maybe License
$sel:userId:UpdateUser' :: UpdateUser -> Text
$sel:accountId:UpdateUser' :: UpdateUser -> Text
$sel:alexaForBusinessMetadata:UpdateUser' :: UpdateUser -> Maybe AlexaForBusinessMetadata
$sel:userType:UpdateUser' :: UpdateUser -> Maybe UserType
$sel:licenseType:UpdateUser' :: UpdateUser -> Maybe License
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LicenseType" Text -> License -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (License -> Pair) -> Maybe License -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe License
licenseType,
            (Text
"UserType" Text -> UserType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UserType -> Pair) -> Maybe UserType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UserType
userType,
            (Text
"AlexaForBusinessMetadata" Text -> AlexaForBusinessMetadata -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AlexaForBusinessMetadata -> Pair)
-> Maybe AlexaForBusinessMetadata -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AlexaForBusinessMetadata
alexaForBusinessMetadata
          ]
      )

instance Core.ToPath UpdateUser where
  toPath :: UpdateUser -> ByteString
toPath UpdateUser' {Maybe AlexaForBusinessMetadata
Maybe License
Maybe UserType
Text
userId :: Text
accountId :: Text
alexaForBusinessMetadata :: Maybe AlexaForBusinessMetadata
userType :: Maybe UserType
licenseType :: Maybe License
$sel:userId:UpdateUser' :: UpdateUser -> Text
$sel:accountId:UpdateUser' :: UpdateUser -> Text
$sel:alexaForBusinessMetadata:UpdateUser' :: UpdateUser -> Maybe AlexaForBusinessMetadata
$sel:userType:UpdateUser' :: UpdateUser -> Maybe UserType
$sel:licenseType:UpdateUser' :: UpdateUser -> Maybe License
..} =
    [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 UpdateUser where
  toQuery :: UpdateUser -> QueryString
toQuery = QueryString -> UpdateUser -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateUserResponse' smart constructor.
data UpdateUserResponse = UpdateUserResponse'
  { -- | The updated user details.
    UpdateUserResponse -> Maybe User
user :: Prelude.Maybe User,
    -- | The response's http status code.
    UpdateUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateUserResponse -> UpdateUserResponse -> Bool
(UpdateUserResponse -> UpdateUserResponse -> Bool)
-> (UpdateUserResponse -> UpdateUserResponse -> Bool)
-> Eq UpdateUserResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUserResponse -> UpdateUserResponse -> Bool
$c/= :: UpdateUserResponse -> UpdateUserResponse -> Bool
== :: UpdateUserResponse -> UpdateUserResponse -> Bool
$c== :: UpdateUserResponse -> UpdateUserResponse -> Bool
Prelude.Eq, Int -> UpdateUserResponse -> ShowS
[UpdateUserResponse] -> ShowS
UpdateUserResponse -> String
(Int -> UpdateUserResponse -> ShowS)
-> (UpdateUserResponse -> String)
-> ([UpdateUserResponse] -> ShowS)
-> Show UpdateUserResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUserResponse] -> ShowS
$cshowList :: [UpdateUserResponse] -> ShowS
show :: UpdateUserResponse -> String
$cshow :: UpdateUserResponse -> String
showsPrec :: Int -> UpdateUserResponse -> ShowS
$cshowsPrec :: Int -> UpdateUserResponse -> ShowS
Prelude.Show, (forall x. UpdateUserResponse -> Rep UpdateUserResponse x)
-> (forall x. Rep UpdateUserResponse x -> UpdateUserResponse)
-> Generic UpdateUserResponse
forall x. Rep UpdateUserResponse x -> UpdateUserResponse
forall x. UpdateUserResponse -> Rep UpdateUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUserResponse x -> UpdateUserResponse
$cfrom :: forall x. UpdateUserResponse -> Rep UpdateUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUserResponse' 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:
--
-- 'user', 'updateUserResponse_user' - The updated user details.
--
-- 'httpStatus', 'updateUserResponse_httpStatus' - The response's http status code.
newUpdateUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateUserResponse
newUpdateUserResponse :: Int -> UpdateUserResponse
newUpdateUserResponse Int
pHttpStatus_ =
  UpdateUserResponse' :: Maybe User -> Int -> UpdateUserResponse
UpdateUserResponse'
    { $sel:user:UpdateUserResponse' :: Maybe User
user = Maybe User
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated user details.
updateUserResponse_user :: Lens.Lens' UpdateUserResponse (Prelude.Maybe User)
updateUserResponse_user :: (Maybe User -> f (Maybe User))
-> UpdateUserResponse -> f UpdateUserResponse
updateUserResponse_user = (UpdateUserResponse -> Maybe User)
-> (UpdateUserResponse -> Maybe User -> UpdateUserResponse)
-> Lens
     UpdateUserResponse UpdateUserResponse (Maybe User) (Maybe User)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserResponse' {Maybe User
user :: Maybe User
$sel:user:UpdateUserResponse' :: UpdateUserResponse -> Maybe User
user} -> Maybe User
user) (\s :: UpdateUserResponse
s@UpdateUserResponse' {} Maybe User
a -> UpdateUserResponse
s {$sel:user:UpdateUserResponse' :: Maybe User
user = Maybe User
a} :: UpdateUserResponse)

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

instance Prelude.NFData UpdateUserResponse