{-# 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.UpdateProxySession
-- 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 the specified proxy session details, such as voice or SMS
-- capabilities.
module Amazonka.Chime.UpdateProxySession
  ( -- * Creating a Request
    UpdateProxySession (..),
    newUpdateProxySession,

    -- * Request Lenses
    updateProxySession_expiryMinutes,
    updateProxySession_capabilities,
    updateProxySession_voiceConnectorId,
    updateProxySession_proxySessionId,

    -- * Destructuring the Response
    UpdateProxySessionResponse (..),
    newUpdateProxySessionResponse,

    -- * Response Lenses
    updateProxySessionResponse_proxySession,
    updateProxySessionResponse_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:/ 'newUpdateProxySession' smart constructor.
data UpdateProxySession = UpdateProxySession'
  { -- | The number of minutes allowed for the proxy session.
    UpdateProxySession -> Maybe Natural
expiryMinutes :: Prelude.Maybe Prelude.Natural,
    -- | The proxy session capabilities.
    UpdateProxySession -> [Capability]
capabilities :: [Capability],
    -- | The Amazon Chime voice connector ID.
    UpdateProxySession -> Text
voiceConnectorId :: Prelude.Text,
    -- | The proxy session ID.
    UpdateProxySession -> Text
proxySessionId :: Prelude.Text
  }
  deriving (UpdateProxySession -> UpdateProxySession -> Bool
(UpdateProxySession -> UpdateProxySession -> Bool)
-> (UpdateProxySession -> UpdateProxySession -> Bool)
-> Eq UpdateProxySession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProxySession -> UpdateProxySession -> Bool
$c/= :: UpdateProxySession -> UpdateProxySession -> Bool
== :: UpdateProxySession -> UpdateProxySession -> Bool
$c== :: UpdateProxySession -> UpdateProxySession -> Bool
Prelude.Eq, ReadPrec [UpdateProxySession]
ReadPrec UpdateProxySession
Int -> ReadS UpdateProxySession
ReadS [UpdateProxySession]
(Int -> ReadS UpdateProxySession)
-> ReadS [UpdateProxySession]
-> ReadPrec UpdateProxySession
-> ReadPrec [UpdateProxySession]
-> Read UpdateProxySession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProxySession]
$creadListPrec :: ReadPrec [UpdateProxySession]
readPrec :: ReadPrec UpdateProxySession
$creadPrec :: ReadPrec UpdateProxySession
readList :: ReadS [UpdateProxySession]
$creadList :: ReadS [UpdateProxySession]
readsPrec :: Int -> ReadS UpdateProxySession
$creadsPrec :: Int -> ReadS UpdateProxySession
Prelude.Read, Int -> UpdateProxySession -> ShowS
[UpdateProxySession] -> ShowS
UpdateProxySession -> String
(Int -> UpdateProxySession -> ShowS)
-> (UpdateProxySession -> String)
-> ([UpdateProxySession] -> ShowS)
-> Show UpdateProxySession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProxySession] -> ShowS
$cshowList :: [UpdateProxySession] -> ShowS
show :: UpdateProxySession -> String
$cshow :: UpdateProxySession -> String
showsPrec :: Int -> UpdateProxySession -> ShowS
$cshowsPrec :: Int -> UpdateProxySession -> ShowS
Prelude.Show, (forall x. UpdateProxySession -> Rep UpdateProxySession x)
-> (forall x. Rep UpdateProxySession x -> UpdateProxySession)
-> Generic UpdateProxySession
forall x. Rep UpdateProxySession x -> UpdateProxySession
forall x. UpdateProxySession -> Rep UpdateProxySession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateProxySession x -> UpdateProxySession
$cfrom :: forall x. UpdateProxySession -> Rep UpdateProxySession x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProxySession' 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:
--
-- 'expiryMinutes', 'updateProxySession_expiryMinutes' - The number of minutes allowed for the proxy session.
--
-- 'capabilities', 'updateProxySession_capabilities' - The proxy session capabilities.
--
-- 'voiceConnectorId', 'updateProxySession_voiceConnectorId' - The Amazon Chime voice connector ID.
--
-- 'proxySessionId', 'updateProxySession_proxySessionId' - The proxy session ID.
newUpdateProxySession ::
  -- | 'voiceConnectorId'
  Prelude.Text ->
  -- | 'proxySessionId'
  Prelude.Text ->
  UpdateProxySession
newUpdateProxySession :: Text -> Text -> UpdateProxySession
newUpdateProxySession
  Text
pVoiceConnectorId_
  Text
pProxySessionId_ =
    UpdateProxySession' :: Maybe Natural -> [Capability] -> Text -> Text -> UpdateProxySession
UpdateProxySession'
      { $sel:expiryMinutes:UpdateProxySession' :: Maybe Natural
expiryMinutes =
          Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:capabilities:UpdateProxySession' :: [Capability]
capabilities = [Capability]
forall a. Monoid a => a
Prelude.mempty,
        $sel:voiceConnectorId:UpdateProxySession' :: Text
voiceConnectorId = Text
pVoiceConnectorId_,
        $sel:proxySessionId:UpdateProxySession' :: Text
proxySessionId = Text
pProxySessionId_
      }

-- | The number of minutes allowed for the proxy session.
updateProxySession_expiryMinutes :: Lens.Lens' UpdateProxySession (Prelude.Maybe Prelude.Natural)
updateProxySession_expiryMinutes :: (Maybe Natural -> f (Maybe Natural))
-> UpdateProxySession -> f UpdateProxySession
updateProxySession_expiryMinutes = (UpdateProxySession -> Maybe Natural)
-> (UpdateProxySession -> Maybe Natural -> UpdateProxySession)
-> Lens
     UpdateProxySession
     UpdateProxySession
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProxySession' {Maybe Natural
expiryMinutes :: Maybe Natural
$sel:expiryMinutes:UpdateProxySession' :: UpdateProxySession -> Maybe Natural
expiryMinutes} -> Maybe Natural
expiryMinutes) (\s :: UpdateProxySession
s@UpdateProxySession' {} Maybe Natural
a -> UpdateProxySession
s {$sel:expiryMinutes:UpdateProxySession' :: Maybe Natural
expiryMinutes = Maybe Natural
a} :: UpdateProxySession)

-- | The proxy session capabilities.
updateProxySession_capabilities :: Lens.Lens' UpdateProxySession [Capability]
updateProxySession_capabilities :: ([Capability] -> f [Capability])
-> UpdateProxySession -> f UpdateProxySession
updateProxySession_capabilities = (UpdateProxySession -> [Capability])
-> (UpdateProxySession -> [Capability] -> UpdateProxySession)
-> Lens
     UpdateProxySession UpdateProxySession [Capability] [Capability]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProxySession' {[Capability]
capabilities :: [Capability]
$sel:capabilities:UpdateProxySession' :: UpdateProxySession -> [Capability]
capabilities} -> [Capability]
capabilities) (\s :: UpdateProxySession
s@UpdateProxySession' {} [Capability]
a -> UpdateProxySession
s {$sel:capabilities:UpdateProxySession' :: [Capability]
capabilities = [Capability]
a} :: UpdateProxySession) (([Capability] -> f [Capability])
 -> UpdateProxySession -> f UpdateProxySession)
-> (([Capability] -> f [Capability])
    -> [Capability] -> f [Capability])
-> ([Capability] -> f [Capability])
-> UpdateProxySession
-> f UpdateProxySession
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Capability] -> f [Capability]) -> [Capability] -> f [Capability]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Chime voice connector ID.
updateProxySession_voiceConnectorId :: Lens.Lens' UpdateProxySession Prelude.Text
updateProxySession_voiceConnectorId :: (Text -> f Text) -> UpdateProxySession -> f UpdateProxySession
updateProxySession_voiceConnectorId = (UpdateProxySession -> Text)
-> (UpdateProxySession -> Text -> UpdateProxySession)
-> Lens UpdateProxySession UpdateProxySession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProxySession' {Text
voiceConnectorId :: Text
$sel:voiceConnectorId:UpdateProxySession' :: UpdateProxySession -> Text
voiceConnectorId} -> Text
voiceConnectorId) (\s :: UpdateProxySession
s@UpdateProxySession' {} Text
a -> UpdateProxySession
s {$sel:voiceConnectorId:UpdateProxySession' :: Text
voiceConnectorId = Text
a} :: UpdateProxySession)

-- | The proxy session ID.
updateProxySession_proxySessionId :: Lens.Lens' UpdateProxySession Prelude.Text
updateProxySession_proxySessionId :: (Text -> f Text) -> UpdateProxySession -> f UpdateProxySession
updateProxySession_proxySessionId = (UpdateProxySession -> Text)
-> (UpdateProxySession -> Text -> UpdateProxySession)
-> Lens UpdateProxySession UpdateProxySession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProxySession' {Text
proxySessionId :: Text
$sel:proxySessionId:UpdateProxySession' :: UpdateProxySession -> Text
proxySessionId} -> Text
proxySessionId) (\s :: UpdateProxySession
s@UpdateProxySession' {} Text
a -> UpdateProxySession
s {$sel:proxySessionId:UpdateProxySession' :: Text
proxySessionId = Text
a} :: UpdateProxySession)

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

instance Prelude.NFData UpdateProxySession

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

instance Core.ToJSON UpdateProxySession where
  toJSON :: UpdateProxySession -> Value
toJSON UpdateProxySession' {[Capability]
Maybe Natural
Text
proxySessionId :: Text
voiceConnectorId :: Text
capabilities :: [Capability]
expiryMinutes :: Maybe Natural
$sel:proxySessionId:UpdateProxySession' :: UpdateProxySession -> Text
$sel:voiceConnectorId:UpdateProxySession' :: UpdateProxySession -> Text
$sel:capabilities:UpdateProxySession' :: UpdateProxySession -> [Capability]
$sel:expiryMinutes:UpdateProxySession' :: UpdateProxySession -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExpiryMinutes" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
expiryMinutes,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Capabilities" Text -> [Capability] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Capability]
capabilities)
          ]
      )

instance Core.ToPath UpdateProxySession where
  toPath :: UpdateProxySession -> ByteString
toPath UpdateProxySession' {[Capability]
Maybe Natural
Text
proxySessionId :: Text
voiceConnectorId :: Text
capabilities :: [Capability]
expiryMinutes :: Maybe Natural
$sel:proxySessionId:UpdateProxySession' :: UpdateProxySession -> Text
$sel:voiceConnectorId:UpdateProxySession' :: UpdateProxySession -> Text
$sel:capabilities:UpdateProxySession' :: UpdateProxySession -> [Capability]
$sel:expiryMinutes:UpdateProxySession' :: UpdateProxySession -> Maybe Natural
..} =
    [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
"/proxy-sessions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
proxySessionId
      ]

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

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

-- |
-- Create a value of 'UpdateProxySessionResponse' 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:
--
-- 'proxySession', 'updateProxySessionResponse_proxySession' - The proxy session details.
--
-- 'httpStatus', 'updateProxySessionResponse_httpStatus' - The response's http status code.
newUpdateProxySessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateProxySessionResponse
newUpdateProxySessionResponse :: Int -> UpdateProxySessionResponse
newUpdateProxySessionResponse Int
pHttpStatus_ =
  UpdateProxySessionResponse' :: Maybe ProxySession -> Int -> UpdateProxySessionResponse
UpdateProxySessionResponse'
    { $sel:proxySession:UpdateProxySessionResponse' :: Maybe ProxySession
proxySession =
        Maybe ProxySession
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateProxySessionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The proxy session details.
updateProxySessionResponse_proxySession :: Lens.Lens' UpdateProxySessionResponse (Prelude.Maybe ProxySession)
updateProxySessionResponse_proxySession :: (Maybe ProxySession -> f (Maybe ProxySession))
-> UpdateProxySessionResponse -> f UpdateProxySessionResponse
updateProxySessionResponse_proxySession = (UpdateProxySessionResponse -> Maybe ProxySession)
-> (UpdateProxySessionResponse
    -> Maybe ProxySession -> UpdateProxySessionResponse)
-> Lens
     UpdateProxySessionResponse
     UpdateProxySessionResponse
     (Maybe ProxySession)
     (Maybe ProxySession)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProxySessionResponse' {Maybe ProxySession
proxySession :: Maybe ProxySession
$sel:proxySession:UpdateProxySessionResponse' :: UpdateProxySessionResponse -> Maybe ProxySession
proxySession} -> Maybe ProxySession
proxySession) (\s :: UpdateProxySessionResponse
s@UpdateProxySessionResponse' {} Maybe ProxySession
a -> UpdateProxySessionResponse
s {$sel:proxySession:UpdateProxySessionResponse' :: Maybe ProxySession
proxySession = Maybe ProxySession
a} :: UpdateProxySessionResponse)

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

instance Prelude.NFData UpdateProxySessionResponse