{-# 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.Pinpoint.UpdateVoiceChannel
-- 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)
--
-- Enables the voice channel for an application or updates the status and
-- settings of the voice channel for an application.
module Amazonka.Pinpoint.UpdateVoiceChannel
  ( -- * Creating a Request
    UpdateVoiceChannel (..),
    newUpdateVoiceChannel,

    -- * Request Lenses
    updateVoiceChannel_applicationId,
    updateVoiceChannel_voiceChannelRequest,

    -- * Destructuring the Response
    UpdateVoiceChannelResponse (..),
    newUpdateVoiceChannelResponse,

    -- * Response Lenses
    updateVoiceChannelResponse_httpStatus,
    updateVoiceChannelResponse_voiceChannelResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateVoiceChannel' smart constructor.
data UpdateVoiceChannel = UpdateVoiceChannel'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateVoiceChannel -> Text
applicationId :: Prelude.Text,
    UpdateVoiceChannel -> VoiceChannelRequest
voiceChannelRequest :: VoiceChannelRequest
  }
  deriving (UpdateVoiceChannel -> UpdateVoiceChannel -> Bool
(UpdateVoiceChannel -> UpdateVoiceChannel -> Bool)
-> (UpdateVoiceChannel -> UpdateVoiceChannel -> Bool)
-> Eq UpdateVoiceChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateVoiceChannel -> UpdateVoiceChannel -> Bool
$c/= :: UpdateVoiceChannel -> UpdateVoiceChannel -> Bool
== :: UpdateVoiceChannel -> UpdateVoiceChannel -> Bool
$c== :: UpdateVoiceChannel -> UpdateVoiceChannel -> Bool
Prelude.Eq, ReadPrec [UpdateVoiceChannel]
ReadPrec UpdateVoiceChannel
Int -> ReadS UpdateVoiceChannel
ReadS [UpdateVoiceChannel]
(Int -> ReadS UpdateVoiceChannel)
-> ReadS [UpdateVoiceChannel]
-> ReadPrec UpdateVoiceChannel
-> ReadPrec [UpdateVoiceChannel]
-> Read UpdateVoiceChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateVoiceChannel]
$creadListPrec :: ReadPrec [UpdateVoiceChannel]
readPrec :: ReadPrec UpdateVoiceChannel
$creadPrec :: ReadPrec UpdateVoiceChannel
readList :: ReadS [UpdateVoiceChannel]
$creadList :: ReadS [UpdateVoiceChannel]
readsPrec :: Int -> ReadS UpdateVoiceChannel
$creadsPrec :: Int -> ReadS UpdateVoiceChannel
Prelude.Read, Int -> UpdateVoiceChannel -> ShowS
[UpdateVoiceChannel] -> ShowS
UpdateVoiceChannel -> String
(Int -> UpdateVoiceChannel -> ShowS)
-> (UpdateVoiceChannel -> String)
-> ([UpdateVoiceChannel] -> ShowS)
-> Show UpdateVoiceChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateVoiceChannel] -> ShowS
$cshowList :: [UpdateVoiceChannel] -> ShowS
show :: UpdateVoiceChannel -> String
$cshow :: UpdateVoiceChannel -> String
showsPrec :: Int -> UpdateVoiceChannel -> ShowS
$cshowsPrec :: Int -> UpdateVoiceChannel -> ShowS
Prelude.Show, (forall x. UpdateVoiceChannel -> Rep UpdateVoiceChannel x)
-> (forall x. Rep UpdateVoiceChannel x -> UpdateVoiceChannel)
-> Generic UpdateVoiceChannel
forall x. Rep UpdateVoiceChannel x -> UpdateVoiceChannel
forall x. UpdateVoiceChannel -> Rep UpdateVoiceChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateVoiceChannel x -> UpdateVoiceChannel
$cfrom :: forall x. UpdateVoiceChannel -> Rep UpdateVoiceChannel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateVoiceChannel' 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:
--
-- 'applicationId', 'updateVoiceChannel_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'voiceChannelRequest', 'updateVoiceChannel_voiceChannelRequest' - Undocumented member.
newUpdateVoiceChannel ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'voiceChannelRequest'
  VoiceChannelRequest ->
  UpdateVoiceChannel
newUpdateVoiceChannel :: Text -> VoiceChannelRequest -> UpdateVoiceChannel
newUpdateVoiceChannel
  Text
pApplicationId_
  VoiceChannelRequest
pVoiceChannelRequest_ =
    UpdateVoiceChannel' :: Text -> VoiceChannelRequest -> UpdateVoiceChannel
UpdateVoiceChannel'
      { $sel:applicationId:UpdateVoiceChannel' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:voiceChannelRequest:UpdateVoiceChannel' :: VoiceChannelRequest
voiceChannelRequest = VoiceChannelRequest
pVoiceChannelRequest_
      }

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
updateVoiceChannel_applicationId :: Lens.Lens' UpdateVoiceChannel Prelude.Text
updateVoiceChannel_applicationId :: (Text -> f Text) -> UpdateVoiceChannel -> f UpdateVoiceChannel
updateVoiceChannel_applicationId = (UpdateVoiceChannel -> Text)
-> (UpdateVoiceChannel -> Text -> UpdateVoiceChannel)
-> Lens UpdateVoiceChannel UpdateVoiceChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceChannel' {Text
applicationId :: Text
$sel:applicationId:UpdateVoiceChannel' :: UpdateVoiceChannel -> Text
applicationId} -> Text
applicationId) (\s :: UpdateVoiceChannel
s@UpdateVoiceChannel' {} Text
a -> UpdateVoiceChannel
s {$sel:applicationId:UpdateVoiceChannel' :: Text
applicationId = Text
a} :: UpdateVoiceChannel)

-- | Undocumented member.
updateVoiceChannel_voiceChannelRequest :: Lens.Lens' UpdateVoiceChannel VoiceChannelRequest
updateVoiceChannel_voiceChannelRequest :: (VoiceChannelRequest -> f VoiceChannelRequest)
-> UpdateVoiceChannel -> f UpdateVoiceChannel
updateVoiceChannel_voiceChannelRequest = (UpdateVoiceChannel -> VoiceChannelRequest)
-> (UpdateVoiceChannel
    -> VoiceChannelRequest -> UpdateVoiceChannel)
-> Lens
     UpdateVoiceChannel
     UpdateVoiceChannel
     VoiceChannelRequest
     VoiceChannelRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceChannel' {VoiceChannelRequest
voiceChannelRequest :: VoiceChannelRequest
$sel:voiceChannelRequest:UpdateVoiceChannel' :: UpdateVoiceChannel -> VoiceChannelRequest
voiceChannelRequest} -> VoiceChannelRequest
voiceChannelRequest) (\s :: UpdateVoiceChannel
s@UpdateVoiceChannel' {} VoiceChannelRequest
a -> UpdateVoiceChannel
s {$sel:voiceChannelRequest:UpdateVoiceChannel' :: VoiceChannelRequest
voiceChannelRequest = VoiceChannelRequest
a} :: UpdateVoiceChannel)

instance Core.AWSRequest UpdateVoiceChannel where
  type
    AWSResponse UpdateVoiceChannel =
      UpdateVoiceChannelResponse
  request :: UpdateVoiceChannel -> Request UpdateVoiceChannel
request = Service -> UpdateVoiceChannel -> Request UpdateVoiceChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateVoiceChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateVoiceChannel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateVoiceChannel))
-> Logger
-> Service
-> Proxy UpdateVoiceChannel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateVoiceChannel)))
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 ->
          Int -> VoiceChannelResponse -> UpdateVoiceChannelResponse
UpdateVoiceChannelResponse'
            (Int -> VoiceChannelResponse -> UpdateVoiceChannelResponse)
-> Either String Int
-> Either
     String (VoiceChannelResponse -> UpdateVoiceChannelResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (VoiceChannelResponse -> UpdateVoiceChannelResponse)
-> Either String VoiceChannelResponse
-> Either String UpdateVoiceChannelResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String VoiceChannelResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateVoiceChannel

instance Prelude.NFData UpdateVoiceChannel

instance Core.ToHeaders UpdateVoiceChannel where
  toHeaders :: UpdateVoiceChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateVoiceChannel -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Core.ToPath UpdateVoiceChannel where
  toPath :: UpdateVoiceChannel -> ByteString
toPath UpdateVoiceChannel' {Text
VoiceChannelRequest
voiceChannelRequest :: VoiceChannelRequest
applicationId :: Text
$sel:voiceChannelRequest:UpdateVoiceChannel' :: UpdateVoiceChannel -> VoiceChannelRequest
$sel:applicationId:UpdateVoiceChannel' :: UpdateVoiceChannel -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/channels/voice"
      ]

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

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

-- |
-- Create a value of 'UpdateVoiceChannelResponse' 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:
--
-- 'httpStatus', 'updateVoiceChannelResponse_httpStatus' - The response's http status code.
--
-- 'voiceChannelResponse', 'updateVoiceChannelResponse_voiceChannelResponse' - Undocumented member.
newUpdateVoiceChannelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'voiceChannelResponse'
  VoiceChannelResponse ->
  UpdateVoiceChannelResponse
newUpdateVoiceChannelResponse :: Int -> VoiceChannelResponse -> UpdateVoiceChannelResponse
newUpdateVoiceChannelResponse
  Int
pHttpStatus_
  VoiceChannelResponse
pVoiceChannelResponse_ =
    UpdateVoiceChannelResponse' :: Int -> VoiceChannelResponse -> UpdateVoiceChannelResponse
UpdateVoiceChannelResponse'
      { $sel:httpStatus:UpdateVoiceChannelResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:voiceChannelResponse:UpdateVoiceChannelResponse' :: VoiceChannelResponse
voiceChannelResponse = VoiceChannelResponse
pVoiceChannelResponse_
      }

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

-- | Undocumented member.
updateVoiceChannelResponse_voiceChannelResponse :: Lens.Lens' UpdateVoiceChannelResponse VoiceChannelResponse
updateVoiceChannelResponse_voiceChannelResponse :: (VoiceChannelResponse -> f VoiceChannelResponse)
-> UpdateVoiceChannelResponse -> f UpdateVoiceChannelResponse
updateVoiceChannelResponse_voiceChannelResponse = (UpdateVoiceChannelResponse -> VoiceChannelResponse)
-> (UpdateVoiceChannelResponse
    -> VoiceChannelResponse -> UpdateVoiceChannelResponse)
-> Lens
     UpdateVoiceChannelResponse
     UpdateVoiceChannelResponse
     VoiceChannelResponse
     VoiceChannelResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateVoiceChannelResponse' {VoiceChannelResponse
voiceChannelResponse :: VoiceChannelResponse
$sel:voiceChannelResponse:UpdateVoiceChannelResponse' :: UpdateVoiceChannelResponse -> VoiceChannelResponse
voiceChannelResponse} -> VoiceChannelResponse
voiceChannelResponse) (\s :: UpdateVoiceChannelResponse
s@UpdateVoiceChannelResponse' {} VoiceChannelResponse
a -> UpdateVoiceChannelResponse
s {$sel:voiceChannelResponse:UpdateVoiceChannelResponse' :: VoiceChannelResponse
voiceChannelResponse = VoiceChannelResponse
a} :: UpdateVoiceChannelResponse)

instance Prelude.NFData UpdateVoiceChannelResponse