{-# 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.PutVoiceConnectorTermination
-- 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)
--
-- Adds termination settings for the specified Amazon Chime Voice
-- Connector.
--
-- If emergency calling is configured for the Amazon Chime Voice Connector,
-- it must be deleted prior to turning off termination settings.
module Amazonka.Chime.PutVoiceConnectorTermination
  ( -- * Creating a Request
    PutVoiceConnectorTermination (..),
    newPutVoiceConnectorTermination,

    -- * Request Lenses
    putVoiceConnectorTermination_voiceConnectorId,
    putVoiceConnectorTermination_termination,

    -- * Destructuring the Response
    PutVoiceConnectorTerminationResponse (..),
    newPutVoiceConnectorTerminationResponse,

    -- * Response Lenses
    putVoiceConnectorTerminationResponse_termination,
    putVoiceConnectorTerminationResponse_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:/ 'newPutVoiceConnectorTermination' smart constructor.
data PutVoiceConnectorTermination = PutVoiceConnectorTermination'
  { -- | The Amazon Chime Voice Connector ID.
    PutVoiceConnectorTermination -> Text
voiceConnectorId :: Prelude.Text,
    -- | The termination setting details to add.
    PutVoiceConnectorTermination -> Termination
termination :: Termination
  }
  deriving (PutVoiceConnectorTermination
-> PutVoiceConnectorTermination -> Bool
(PutVoiceConnectorTermination
 -> PutVoiceConnectorTermination -> Bool)
-> (PutVoiceConnectorTermination
    -> PutVoiceConnectorTermination -> Bool)
-> Eq PutVoiceConnectorTermination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutVoiceConnectorTermination
-> PutVoiceConnectorTermination -> Bool
$c/= :: PutVoiceConnectorTermination
-> PutVoiceConnectorTermination -> Bool
== :: PutVoiceConnectorTermination
-> PutVoiceConnectorTermination -> Bool
$c== :: PutVoiceConnectorTermination
-> PutVoiceConnectorTermination -> Bool
Prelude.Eq, Int -> PutVoiceConnectorTermination -> ShowS
[PutVoiceConnectorTermination] -> ShowS
PutVoiceConnectorTermination -> String
(Int -> PutVoiceConnectorTermination -> ShowS)
-> (PutVoiceConnectorTermination -> String)
-> ([PutVoiceConnectorTermination] -> ShowS)
-> Show PutVoiceConnectorTermination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutVoiceConnectorTermination] -> ShowS
$cshowList :: [PutVoiceConnectorTermination] -> ShowS
show :: PutVoiceConnectorTermination -> String
$cshow :: PutVoiceConnectorTermination -> String
showsPrec :: Int -> PutVoiceConnectorTermination -> ShowS
$cshowsPrec :: Int -> PutVoiceConnectorTermination -> ShowS
Prelude.Show, (forall x.
 PutVoiceConnectorTermination -> Rep PutVoiceConnectorTermination x)
-> (forall x.
    Rep PutVoiceConnectorTermination x -> PutVoiceConnectorTermination)
-> Generic PutVoiceConnectorTermination
forall x.
Rep PutVoiceConnectorTermination x -> PutVoiceConnectorTermination
forall x.
PutVoiceConnectorTermination -> Rep PutVoiceConnectorTermination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutVoiceConnectorTermination x -> PutVoiceConnectorTermination
$cfrom :: forall x.
PutVoiceConnectorTermination -> Rep PutVoiceConnectorTermination x
Prelude.Generic)

-- |
-- Create a value of 'PutVoiceConnectorTermination' 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', 'putVoiceConnectorTermination_voiceConnectorId' - The Amazon Chime Voice Connector ID.
--
-- 'termination', 'putVoiceConnectorTermination_termination' - The termination setting details to add.
newPutVoiceConnectorTermination ::
  -- | 'voiceConnectorId'
  Prelude.Text ->
  -- | 'termination'
  Termination ->
  PutVoiceConnectorTermination
newPutVoiceConnectorTermination :: Text -> Termination -> PutVoiceConnectorTermination
newPutVoiceConnectorTermination
  Text
pVoiceConnectorId_
  Termination
pTermination_ =
    PutVoiceConnectorTermination' :: Text -> Termination -> PutVoiceConnectorTermination
PutVoiceConnectorTermination'
      { $sel:voiceConnectorId:PutVoiceConnectorTermination' :: Text
voiceConnectorId =
          Text
pVoiceConnectorId_,
        $sel:termination:PutVoiceConnectorTermination' :: Termination
termination = Termination
pTermination_
      }

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

-- | The termination setting details to add.
putVoiceConnectorTermination_termination :: Lens.Lens' PutVoiceConnectorTermination Termination
putVoiceConnectorTermination_termination :: (Termination -> f Termination)
-> PutVoiceConnectorTermination -> f PutVoiceConnectorTermination
putVoiceConnectorTermination_termination = (PutVoiceConnectorTermination -> Termination)
-> (PutVoiceConnectorTermination
    -> Termination -> PutVoiceConnectorTermination)
-> Lens
     PutVoiceConnectorTermination
     PutVoiceConnectorTermination
     Termination
     Termination
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutVoiceConnectorTermination' {Termination
termination :: Termination
$sel:termination:PutVoiceConnectorTermination' :: PutVoiceConnectorTermination -> Termination
termination} -> Termination
termination) (\s :: PutVoiceConnectorTermination
s@PutVoiceConnectorTermination' {} Termination
a -> PutVoiceConnectorTermination
s {$sel:termination:PutVoiceConnectorTermination' :: Termination
termination = Termination
a} :: PutVoiceConnectorTermination)

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

instance Prelude.NFData PutVoiceConnectorTermination

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

instance Core.ToJSON PutVoiceConnectorTermination where
  toJSON :: PutVoiceConnectorTermination -> Value
toJSON PutVoiceConnectorTermination' {Text
Termination
termination :: Termination
voiceConnectorId :: Text
$sel:termination:PutVoiceConnectorTermination' :: PutVoiceConnectorTermination -> Termination
$sel:voiceConnectorId:PutVoiceConnectorTermination' :: PutVoiceConnectorTermination -> 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
"Termination" Text -> Termination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Termination
termination)]
      )

instance Core.ToPath PutVoiceConnectorTermination where
  toPath :: PutVoiceConnectorTermination -> ByteString
toPath PutVoiceConnectorTermination' {Text
Termination
termination :: Termination
voiceConnectorId :: Text
$sel:termination:PutVoiceConnectorTermination' :: PutVoiceConnectorTermination -> Termination
$sel:voiceConnectorId:PutVoiceConnectorTermination' :: PutVoiceConnectorTermination -> 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,
        ByteString
"/termination"
      ]

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

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

-- |
-- Create a value of 'PutVoiceConnectorTerminationResponse' 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:
--
-- 'termination', 'putVoiceConnectorTerminationResponse_termination' - The updated termination setting details.
--
-- 'httpStatus', 'putVoiceConnectorTerminationResponse_httpStatus' - The response's http status code.
newPutVoiceConnectorTerminationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutVoiceConnectorTerminationResponse
newPutVoiceConnectorTerminationResponse :: Int -> PutVoiceConnectorTerminationResponse
newPutVoiceConnectorTerminationResponse Int
pHttpStatus_ =
  PutVoiceConnectorTerminationResponse' :: Maybe Termination -> Int -> PutVoiceConnectorTerminationResponse
PutVoiceConnectorTerminationResponse'
    { $sel:termination:PutVoiceConnectorTerminationResponse' :: Maybe Termination
termination =
        Maybe Termination
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutVoiceConnectorTerminationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated termination setting details.
putVoiceConnectorTerminationResponse_termination :: Lens.Lens' PutVoiceConnectorTerminationResponse (Prelude.Maybe Termination)
putVoiceConnectorTerminationResponse_termination :: (Maybe Termination -> f (Maybe Termination))
-> PutVoiceConnectorTerminationResponse
-> f PutVoiceConnectorTerminationResponse
putVoiceConnectorTerminationResponse_termination = (PutVoiceConnectorTerminationResponse -> Maybe Termination)
-> (PutVoiceConnectorTerminationResponse
    -> Maybe Termination -> PutVoiceConnectorTerminationResponse)
-> Lens
     PutVoiceConnectorTerminationResponse
     PutVoiceConnectorTerminationResponse
     (Maybe Termination)
     (Maybe Termination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutVoiceConnectorTerminationResponse' {Maybe Termination
termination :: Maybe Termination
$sel:termination:PutVoiceConnectorTerminationResponse' :: PutVoiceConnectorTerminationResponse -> Maybe Termination
termination} -> Maybe Termination
termination) (\s :: PutVoiceConnectorTerminationResponse
s@PutVoiceConnectorTerminationResponse' {} Maybe Termination
a -> PutVoiceConnectorTerminationResponse
s {$sel:termination:PutVoiceConnectorTerminationResponse' :: Maybe Termination
termination = Maybe Termination
a} :: PutVoiceConnectorTerminationResponse)

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

instance
  Prelude.NFData
    PutVoiceConnectorTerminationResponse