{-# 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.UpdateAccount
-- 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 account details for the specified Amazon Chime account.
-- Currently, only account name and default license updates are supported
-- for this action.
module Amazonka.Chime.UpdateAccount
  ( -- * Creating a Request
    UpdateAccount (..),
    newUpdateAccount,

    -- * Request Lenses
    updateAccount_defaultLicense,
    updateAccount_name,
    updateAccount_accountId,

    -- * Destructuring the Response
    UpdateAccountResponse (..),
    newUpdateAccountResponse,

    -- * Response Lenses
    updateAccountResponse_account,
    updateAccountResponse_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:/ 'newUpdateAccount' smart constructor.
data UpdateAccount = UpdateAccount'
  { -- | The default license applied when you add users to an Amazon Chime
    -- account.
    UpdateAccount -> Maybe License
defaultLicense :: Prelude.Maybe License,
    -- | The new name for the specified Amazon Chime account.
    UpdateAccount -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Chime account ID.
    UpdateAccount -> Text
accountId :: Prelude.Text
  }
  deriving (UpdateAccount -> UpdateAccount -> Bool
(UpdateAccount -> UpdateAccount -> Bool)
-> (UpdateAccount -> UpdateAccount -> Bool) -> Eq UpdateAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAccount -> UpdateAccount -> Bool
$c/= :: UpdateAccount -> UpdateAccount -> Bool
== :: UpdateAccount -> UpdateAccount -> Bool
$c== :: UpdateAccount -> UpdateAccount -> Bool
Prelude.Eq, ReadPrec [UpdateAccount]
ReadPrec UpdateAccount
Int -> ReadS UpdateAccount
ReadS [UpdateAccount]
(Int -> ReadS UpdateAccount)
-> ReadS [UpdateAccount]
-> ReadPrec UpdateAccount
-> ReadPrec [UpdateAccount]
-> Read UpdateAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAccount]
$creadListPrec :: ReadPrec [UpdateAccount]
readPrec :: ReadPrec UpdateAccount
$creadPrec :: ReadPrec UpdateAccount
readList :: ReadS [UpdateAccount]
$creadList :: ReadS [UpdateAccount]
readsPrec :: Int -> ReadS UpdateAccount
$creadsPrec :: Int -> ReadS UpdateAccount
Prelude.Read, Int -> UpdateAccount -> ShowS
[UpdateAccount] -> ShowS
UpdateAccount -> String
(Int -> UpdateAccount -> ShowS)
-> (UpdateAccount -> String)
-> ([UpdateAccount] -> ShowS)
-> Show UpdateAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAccount] -> ShowS
$cshowList :: [UpdateAccount] -> ShowS
show :: UpdateAccount -> String
$cshow :: UpdateAccount -> String
showsPrec :: Int -> UpdateAccount -> ShowS
$cshowsPrec :: Int -> UpdateAccount -> ShowS
Prelude.Show, (forall x. UpdateAccount -> Rep UpdateAccount x)
-> (forall x. Rep UpdateAccount x -> UpdateAccount)
-> Generic UpdateAccount
forall x. Rep UpdateAccount x -> UpdateAccount
forall x. UpdateAccount -> Rep UpdateAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAccount x -> UpdateAccount
$cfrom :: forall x. UpdateAccount -> Rep UpdateAccount x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAccount' 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:
--
-- 'defaultLicense', 'updateAccount_defaultLicense' - The default license applied when you add users to an Amazon Chime
-- account.
--
-- 'name', 'updateAccount_name' - The new name for the specified Amazon Chime account.
--
-- 'accountId', 'updateAccount_accountId' - The Amazon Chime account ID.
newUpdateAccount ::
  -- | 'accountId'
  Prelude.Text ->
  UpdateAccount
newUpdateAccount :: Text -> UpdateAccount
newUpdateAccount Text
pAccountId_ =
  UpdateAccount' :: Maybe License -> Maybe Text -> Text -> UpdateAccount
UpdateAccount'
    { $sel:defaultLicense:UpdateAccount' :: Maybe License
defaultLicense = Maybe License
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateAccount' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:UpdateAccount' :: Text
accountId = Text
pAccountId_
    }

-- | The default license applied when you add users to an Amazon Chime
-- account.
updateAccount_defaultLicense :: Lens.Lens' UpdateAccount (Prelude.Maybe License)
updateAccount_defaultLicense :: (Maybe License -> f (Maybe License))
-> UpdateAccount -> f UpdateAccount
updateAccount_defaultLicense = (UpdateAccount -> Maybe License)
-> (UpdateAccount -> Maybe License -> UpdateAccount)
-> Lens UpdateAccount UpdateAccount (Maybe License) (Maybe License)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAccount' {Maybe License
defaultLicense :: Maybe License
$sel:defaultLicense:UpdateAccount' :: UpdateAccount -> Maybe License
defaultLicense} -> Maybe License
defaultLicense) (\s :: UpdateAccount
s@UpdateAccount' {} Maybe License
a -> UpdateAccount
s {$sel:defaultLicense:UpdateAccount' :: Maybe License
defaultLicense = Maybe License
a} :: UpdateAccount)

-- | The new name for the specified Amazon Chime account.
updateAccount_name :: Lens.Lens' UpdateAccount (Prelude.Maybe Prelude.Text)
updateAccount_name :: (Maybe Text -> f (Maybe Text)) -> UpdateAccount -> f UpdateAccount
updateAccount_name = (UpdateAccount -> Maybe Text)
-> (UpdateAccount -> Maybe Text -> UpdateAccount)
-> Lens UpdateAccount UpdateAccount (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAccount' {Maybe Text
name :: Maybe Text
$sel:name:UpdateAccount' :: UpdateAccount -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateAccount
s@UpdateAccount' {} Maybe Text
a -> UpdateAccount
s {$sel:name:UpdateAccount' :: Maybe Text
name = Maybe Text
a} :: UpdateAccount)

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

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

instance Prelude.NFData UpdateAccount

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

instance Core.ToJSON UpdateAccount where
  toJSON :: UpdateAccount -> Value
toJSON UpdateAccount' {Maybe Text
Maybe License
Text
accountId :: Text
name :: Maybe Text
defaultLicense :: Maybe License
$sel:accountId:UpdateAccount' :: UpdateAccount -> Text
$sel:name:UpdateAccount' :: UpdateAccount -> Maybe Text
$sel:defaultLicense:UpdateAccount' :: UpdateAccount -> Maybe License
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DefaultLicense" 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
defaultLicense,
            (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name
          ]
      )

instance Core.ToPath UpdateAccount where
  toPath :: UpdateAccount -> ByteString
toPath UpdateAccount' {Maybe Text
Maybe License
Text
accountId :: Text
name :: Maybe Text
defaultLicense :: Maybe License
$sel:accountId:UpdateAccount' :: UpdateAccount -> Text
$sel:name:UpdateAccount' :: UpdateAccount -> Maybe Text
$sel:defaultLicense:UpdateAccount' :: UpdateAccount -> 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]

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

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

-- |
-- Create a value of 'UpdateAccountResponse' 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:
--
-- 'account', 'updateAccountResponse_account' - The updated Amazon Chime account details.
--
-- 'httpStatus', 'updateAccountResponse_httpStatus' - The response's http status code.
newUpdateAccountResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAccountResponse
newUpdateAccountResponse :: Int -> UpdateAccountResponse
newUpdateAccountResponse Int
pHttpStatus_ =
  UpdateAccountResponse' :: Maybe Account -> Int -> UpdateAccountResponse
UpdateAccountResponse'
    { $sel:account:UpdateAccountResponse' :: Maybe Account
account = Maybe Account
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAccountResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated Amazon Chime account details.
updateAccountResponse_account :: Lens.Lens' UpdateAccountResponse (Prelude.Maybe Account)
updateAccountResponse_account :: (Maybe Account -> f (Maybe Account))
-> UpdateAccountResponse -> f UpdateAccountResponse
updateAccountResponse_account = (UpdateAccountResponse -> Maybe Account)
-> (UpdateAccountResponse
    -> Maybe Account -> UpdateAccountResponse)
-> Lens
     UpdateAccountResponse
     UpdateAccountResponse
     (Maybe Account)
     (Maybe Account)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAccountResponse' {Maybe Account
account :: Maybe Account
$sel:account:UpdateAccountResponse' :: UpdateAccountResponse -> Maybe Account
account} -> Maybe Account
account) (\s :: UpdateAccountResponse
s@UpdateAccountResponse' {} Maybe Account
a -> UpdateAccountResponse
s {$sel:account:UpdateAccountResponse' :: Maybe Account
account = Maybe Account
a} :: UpdateAccountResponse)

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

instance Prelude.NFData UpdateAccountResponse