{-# 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.UpdateVoiceConnector
-- 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 details for the specified Amazon Chime Voice Connector.
module Amazonka.Chime.UpdateVoiceConnector
  ( -- * Creating a Request
    UpdateVoiceConnector (..),
    newUpdateVoiceConnector,

    -- * Request Lenses
    updateVoiceConnector_voiceConnectorId,
    updateVoiceConnector_name,
    updateVoiceConnector_requireEncryption,

    -- * Destructuring the Response
    UpdateVoiceConnectorResponse (..),
    newUpdateVoiceConnectorResponse,

    -- * Response Lenses
    updateVoiceConnectorResponse_voiceConnector,
    updateVoiceConnectorResponse_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:/ 'newUpdateVoiceConnector' smart constructor.
data UpdateVoiceConnector = UpdateVoiceConnector'
  { -- | The Amazon Chime Voice Connector ID.
    UpdateVoiceConnector -> Text
voiceConnectorId :: Prelude.Text,
    -- | The name of the Amazon Chime Voice Connector.
    UpdateVoiceConnector -> Text
name :: Prelude.Text,
    -- | When enabled, requires encryption for the Amazon Chime Voice Connector.
    UpdateVoiceConnector -> Bool
requireEncryption :: Prelude.Bool
  }
  deriving (UpdateVoiceConnector -> UpdateVoiceConnector -> Bool
(UpdateVoiceConnector -> UpdateVoiceConnector -> Bool)
-> (UpdateVoiceConnector -> UpdateVoiceConnector -> Bool)
-> Eq UpdateVoiceConnector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVoiceConnector -> UpdateVoiceConnector -> Bool
$c/= :: UpdateVoiceConnector -> UpdateVoiceConnector -> Bool
== :: UpdateVoiceConnector -> UpdateVoiceConnector -> Bool
$c== :: UpdateVoiceConnector -> UpdateVoiceConnector -> Bool
Prelude.Eq, ReadPrec [UpdateVoiceConnector]
ReadPrec UpdateVoiceConnector
Int -> ReadS UpdateVoiceConnector
ReadS [UpdateVoiceConnector]
(Int -> ReadS UpdateVoiceConnector)
-> ReadS [UpdateVoiceConnector]
-> ReadPrec UpdateVoiceConnector
-> ReadPrec [UpdateVoiceConnector]
-> Read UpdateVoiceConnector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVoiceConnector]
$creadListPrec :: ReadPrec [UpdateVoiceConnector]
readPrec :: ReadPrec UpdateVoiceConnector
$creadPrec :: ReadPrec UpdateVoiceConnector
readList :: ReadS [UpdateVoiceConnector]
$creadList :: ReadS [UpdateVoiceConnector]
readsPrec :: Int -> ReadS UpdateVoiceConnector
$creadsPrec :: Int -> ReadS UpdateVoiceConnector
Prelude.Read, Int -> UpdateVoiceConnector -> ShowS
[UpdateVoiceConnector] -> ShowS
UpdateVoiceConnector -> String
(Int -> UpdateVoiceConnector -> ShowS)
-> (UpdateVoiceConnector -> String)
-> ([UpdateVoiceConnector] -> ShowS)
-> Show UpdateVoiceConnector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVoiceConnector] -> ShowS
$cshowList :: [UpdateVoiceConnector] -> ShowS
show :: UpdateVoiceConnector -> String
$cshow :: UpdateVoiceConnector -> String
showsPrec :: Int -> UpdateVoiceConnector -> ShowS
$cshowsPrec :: Int -> UpdateVoiceConnector -> ShowS
Prelude.Show, (forall x. UpdateVoiceConnector -> Rep UpdateVoiceConnector x)
-> (forall x. Rep UpdateVoiceConnector x -> UpdateVoiceConnector)
-> Generic UpdateVoiceConnector
forall x. Rep UpdateVoiceConnector x -> UpdateVoiceConnector
forall x. UpdateVoiceConnector -> Rep UpdateVoiceConnector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateVoiceConnector x -> UpdateVoiceConnector
$cfrom :: forall x. UpdateVoiceConnector -> Rep UpdateVoiceConnector x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVoiceConnector' 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:
--
-- 'voiceConnectorId', 'updateVoiceConnector_voiceConnectorId' - The Amazon Chime Voice Connector ID.
--
-- 'name', 'updateVoiceConnector_name' - The name of the Amazon Chime Voice Connector.
--
-- 'requireEncryption', 'updateVoiceConnector_requireEncryption' - When enabled, requires encryption for the Amazon Chime Voice Connector.
newUpdateVoiceConnector ::
  -- | 'voiceConnectorId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'requireEncryption'
  Prelude.Bool ->
  UpdateVoiceConnector
newUpdateVoiceConnector :: Text -> Text -> Bool -> UpdateVoiceConnector
newUpdateVoiceConnector
  Text
pVoiceConnectorId_
  Text
pName_
  Bool
pRequireEncryption_ =
    UpdateVoiceConnector' :: Text -> Text -> Bool -> UpdateVoiceConnector
UpdateVoiceConnector'
      { $sel:voiceConnectorId:UpdateVoiceConnector' :: Text
voiceConnectorId =
          Text
pVoiceConnectorId_,
        $sel:name:UpdateVoiceConnector' :: Text
name = Text
pName_,
        $sel:requireEncryption:UpdateVoiceConnector' :: Bool
requireEncryption = Bool
pRequireEncryption_
      }

-- | The Amazon Chime Voice Connector ID.
updateVoiceConnector_voiceConnectorId :: Lens.Lens' UpdateVoiceConnector Prelude.Text
updateVoiceConnector_voiceConnectorId :: (Text -> f Text) -> UpdateVoiceConnector -> f UpdateVoiceConnector
updateVoiceConnector_voiceConnectorId = (UpdateVoiceConnector -> Text)
-> (UpdateVoiceConnector -> Text -> UpdateVoiceConnector)
-> Lens UpdateVoiceConnector UpdateVoiceConnector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceConnector' {Text
voiceConnectorId :: Text
$sel:voiceConnectorId:UpdateVoiceConnector' :: UpdateVoiceConnector -> Text
voiceConnectorId} -> Text
voiceConnectorId) (\s :: UpdateVoiceConnector
s@UpdateVoiceConnector' {} Text
a -> UpdateVoiceConnector
s {$sel:voiceConnectorId:UpdateVoiceConnector' :: Text
voiceConnectorId = Text
a} :: UpdateVoiceConnector)

-- | The name of the Amazon Chime Voice Connector.
updateVoiceConnector_name :: Lens.Lens' UpdateVoiceConnector Prelude.Text
updateVoiceConnector_name :: (Text -> f Text) -> UpdateVoiceConnector -> f UpdateVoiceConnector
updateVoiceConnector_name = (UpdateVoiceConnector -> Text)
-> (UpdateVoiceConnector -> Text -> UpdateVoiceConnector)
-> Lens UpdateVoiceConnector UpdateVoiceConnector Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceConnector' {Text
name :: Text
$sel:name:UpdateVoiceConnector' :: UpdateVoiceConnector -> Text
name} -> Text
name) (\s :: UpdateVoiceConnector
s@UpdateVoiceConnector' {} Text
a -> UpdateVoiceConnector
s {$sel:name:UpdateVoiceConnector' :: Text
name = Text
a} :: UpdateVoiceConnector)

-- | When enabled, requires encryption for the Amazon Chime Voice Connector.
updateVoiceConnector_requireEncryption :: Lens.Lens' UpdateVoiceConnector Prelude.Bool
updateVoiceConnector_requireEncryption :: (Bool -> f Bool) -> UpdateVoiceConnector -> f UpdateVoiceConnector
updateVoiceConnector_requireEncryption = (UpdateVoiceConnector -> Bool)
-> (UpdateVoiceConnector -> Bool -> UpdateVoiceConnector)
-> Lens UpdateVoiceConnector UpdateVoiceConnector Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceConnector' {Bool
requireEncryption :: Bool
$sel:requireEncryption:UpdateVoiceConnector' :: UpdateVoiceConnector -> Bool
requireEncryption} -> Bool
requireEncryption) (\s :: UpdateVoiceConnector
s@UpdateVoiceConnector' {} Bool
a -> UpdateVoiceConnector
s {$sel:requireEncryption:UpdateVoiceConnector' :: Bool
requireEncryption = Bool
a} :: UpdateVoiceConnector)

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

instance Prelude.NFData UpdateVoiceConnector

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

instance Core.ToJSON UpdateVoiceConnector where
  toJSON :: UpdateVoiceConnector -> Value
toJSON UpdateVoiceConnector' {Bool
Text
requireEncryption :: Bool
name :: Text
voiceConnectorId :: Text
$sel:requireEncryption:UpdateVoiceConnector' :: UpdateVoiceConnector -> Bool
$sel:name:UpdateVoiceConnector' :: UpdateVoiceConnector -> Text
$sel:voiceConnectorId:UpdateVoiceConnector' :: UpdateVoiceConnector -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RequireEncryption" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
requireEncryption)
          ]
      )

instance Core.ToPath UpdateVoiceConnector where
  toPath :: UpdateVoiceConnector -> ByteString
toPath UpdateVoiceConnector' {Bool
Text
requireEncryption :: Bool
name :: Text
voiceConnectorId :: Text
$sel:requireEncryption:UpdateVoiceConnector' :: UpdateVoiceConnector -> Bool
$sel:name:UpdateVoiceConnector' :: UpdateVoiceConnector -> Text
$sel:voiceConnectorId:UpdateVoiceConnector' :: UpdateVoiceConnector -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/voice-connectors/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
voiceConnectorId]

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

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

-- |
-- Create a value of 'UpdateVoiceConnectorResponse' 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:
--
-- 'voiceConnector', 'updateVoiceConnectorResponse_voiceConnector' - The updated Amazon Chime Voice Connector details.
--
-- 'httpStatus', 'updateVoiceConnectorResponse_httpStatus' - The response's http status code.
newUpdateVoiceConnectorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateVoiceConnectorResponse
newUpdateVoiceConnectorResponse :: Int -> UpdateVoiceConnectorResponse
newUpdateVoiceConnectorResponse Int
pHttpStatus_ =
  UpdateVoiceConnectorResponse' :: Maybe VoiceConnector -> Int -> UpdateVoiceConnectorResponse
UpdateVoiceConnectorResponse'
    { $sel:voiceConnector:UpdateVoiceConnectorResponse' :: Maybe VoiceConnector
voiceConnector =
        Maybe VoiceConnector
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateVoiceConnectorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated Amazon Chime Voice Connector details.
updateVoiceConnectorResponse_voiceConnector :: Lens.Lens' UpdateVoiceConnectorResponse (Prelude.Maybe VoiceConnector)
updateVoiceConnectorResponse_voiceConnector :: (Maybe VoiceConnector -> f (Maybe VoiceConnector))
-> UpdateVoiceConnectorResponse -> f UpdateVoiceConnectorResponse
updateVoiceConnectorResponse_voiceConnector = (UpdateVoiceConnectorResponse -> Maybe VoiceConnector)
-> (UpdateVoiceConnectorResponse
    -> Maybe VoiceConnector -> UpdateVoiceConnectorResponse)
-> Lens
     UpdateVoiceConnectorResponse
     UpdateVoiceConnectorResponse
     (Maybe VoiceConnector)
     (Maybe VoiceConnector)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceConnectorResponse' {Maybe VoiceConnector
voiceConnector :: Maybe VoiceConnector
$sel:voiceConnector:UpdateVoiceConnectorResponse' :: UpdateVoiceConnectorResponse -> Maybe VoiceConnector
voiceConnector} -> Maybe VoiceConnector
voiceConnector) (\s :: UpdateVoiceConnectorResponse
s@UpdateVoiceConnectorResponse' {} Maybe VoiceConnector
a -> UpdateVoiceConnectorResponse
s {$sel:voiceConnector:UpdateVoiceConnectorResponse' :: Maybe VoiceConnector
voiceConnector = Maybe VoiceConnector
a} :: UpdateVoiceConnectorResponse)

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

instance Prelude.NFData UpdateVoiceConnectorResponse