{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.KinesisVideoSignaling.Types.IceServer
-- 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)
module Amazonka.KinesisVideoSignaling.Types.IceServer where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure for the ICE server connection data.
--
-- /See:/ 'newIceServer' smart constructor.
data IceServer = IceServer'
  { -- | The period of time, in seconds, during which the username and password
    -- are valid.
    IceServer -> Maybe Natural
ttl :: Prelude.Maybe Prelude.Natural,
    -- | An array of URIs, in the form specified in the
    -- <https://tools.ietf.org/html/draft-petithuguenin-behave-turn-uris-03 I-D.petithuguenin-behave-turn-uris>
    -- spec. These URIs provide the different addresses and\/or protocols that
    -- can be used to reach the TURN server.
    IceServer -> Maybe [Text]
uris :: Prelude.Maybe [Prelude.Text],
    -- | A username to login to the ICE server.
    IceServer -> Maybe Text
username :: Prelude.Maybe Prelude.Text,
    -- | A password to login to the ICE server.
    IceServer -> Maybe Text
password :: Prelude.Maybe Prelude.Text
  }
  deriving (IceServer -> IceServer -> Bool
(IceServer -> IceServer -> Bool)
-> (IceServer -> IceServer -> Bool) -> Eq IceServer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IceServer -> IceServer -> Bool
$c/= :: IceServer -> IceServer -> Bool
== :: IceServer -> IceServer -> Bool
$c== :: IceServer -> IceServer -> Bool
Prelude.Eq, ReadPrec [IceServer]
ReadPrec IceServer
Int -> ReadS IceServer
ReadS [IceServer]
(Int -> ReadS IceServer)
-> ReadS [IceServer]
-> ReadPrec IceServer
-> ReadPrec [IceServer]
-> Read IceServer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IceServer]
$creadListPrec :: ReadPrec [IceServer]
readPrec :: ReadPrec IceServer
$creadPrec :: ReadPrec IceServer
readList :: ReadS [IceServer]
$creadList :: ReadS [IceServer]
readsPrec :: Int -> ReadS IceServer
$creadsPrec :: Int -> ReadS IceServer
Prelude.Read, Int -> IceServer -> ShowS
[IceServer] -> ShowS
IceServer -> String
(Int -> IceServer -> ShowS)
-> (IceServer -> String)
-> ([IceServer] -> ShowS)
-> Show IceServer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IceServer] -> ShowS
$cshowList :: [IceServer] -> ShowS
show :: IceServer -> String
$cshow :: IceServer -> String
showsPrec :: Int -> IceServer -> ShowS
$cshowsPrec :: Int -> IceServer -> ShowS
Prelude.Show, (forall x. IceServer -> Rep IceServer x)
-> (forall x. Rep IceServer x -> IceServer) -> Generic IceServer
forall x. Rep IceServer x -> IceServer
forall x. IceServer -> Rep IceServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IceServer x -> IceServer
$cfrom :: forall x. IceServer -> Rep IceServer x
Prelude.Generic)

-- |
-- Create a value of 'IceServer' 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:
--
-- 'ttl', 'iceServer_ttl' - The period of time, in seconds, during which the username and password
-- are valid.
--
-- 'uris', 'iceServer_uris' - An array of URIs, in the form specified in the
-- <https://tools.ietf.org/html/draft-petithuguenin-behave-turn-uris-03 I-D.petithuguenin-behave-turn-uris>
-- spec. These URIs provide the different addresses and\/or protocols that
-- can be used to reach the TURN server.
--
-- 'username', 'iceServer_username' - A username to login to the ICE server.
--
-- 'password', 'iceServer_password' - A password to login to the ICE server.
newIceServer ::
  IceServer
newIceServer :: IceServer
newIceServer =
  IceServer' :: Maybe Natural
-> Maybe [Text] -> Maybe Text -> Maybe Text -> IceServer
IceServer'
    { $sel:ttl:IceServer' :: Maybe Natural
ttl = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:uris:IceServer' :: Maybe [Text]
uris = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:username:IceServer' :: Maybe Text
username = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:password:IceServer' :: Maybe Text
password = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The period of time, in seconds, during which the username and password
-- are valid.
iceServer_ttl :: Lens.Lens' IceServer (Prelude.Maybe Prelude.Natural)
iceServer_ttl :: (Maybe Natural -> f (Maybe Natural)) -> IceServer -> f IceServer
iceServer_ttl = (IceServer -> Maybe Natural)
-> (IceServer -> Maybe Natural -> IceServer)
-> Lens IceServer IceServer (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IceServer' {Maybe Natural
ttl :: Maybe Natural
$sel:ttl:IceServer' :: IceServer -> Maybe Natural
ttl} -> Maybe Natural
ttl) (\s :: IceServer
s@IceServer' {} Maybe Natural
a -> IceServer
s {$sel:ttl:IceServer' :: Maybe Natural
ttl = Maybe Natural
a} :: IceServer)

-- | An array of URIs, in the form specified in the
-- <https://tools.ietf.org/html/draft-petithuguenin-behave-turn-uris-03 I-D.petithuguenin-behave-turn-uris>
-- spec. These URIs provide the different addresses and\/or protocols that
-- can be used to reach the TURN server.
iceServer_uris :: Lens.Lens' IceServer (Prelude.Maybe [Prelude.Text])
iceServer_uris :: (Maybe [Text] -> f (Maybe [Text])) -> IceServer -> f IceServer
iceServer_uris = (IceServer -> Maybe [Text])
-> (IceServer -> Maybe [Text] -> IceServer)
-> Lens IceServer IceServer (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IceServer' {Maybe [Text]
uris :: Maybe [Text]
$sel:uris:IceServer' :: IceServer -> Maybe [Text]
uris} -> Maybe [Text]
uris) (\s :: IceServer
s@IceServer' {} Maybe [Text]
a -> IceServer
s {$sel:uris:IceServer' :: Maybe [Text]
uris = Maybe [Text]
a} :: IceServer) ((Maybe [Text] -> f (Maybe [Text])) -> IceServer -> f IceServer)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> IceServer
-> f IceServer
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A username to login to the ICE server.
iceServer_username :: Lens.Lens' IceServer (Prelude.Maybe Prelude.Text)
iceServer_username :: (Maybe Text -> f (Maybe Text)) -> IceServer -> f IceServer
iceServer_username = (IceServer -> Maybe Text)
-> (IceServer -> Maybe Text -> IceServer)
-> Lens IceServer IceServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IceServer' {Maybe Text
username :: Maybe Text
$sel:username:IceServer' :: IceServer -> Maybe Text
username} -> Maybe Text
username) (\s :: IceServer
s@IceServer' {} Maybe Text
a -> IceServer
s {$sel:username:IceServer' :: Maybe Text
username = Maybe Text
a} :: IceServer)

-- | A password to login to the ICE server.
iceServer_password :: Lens.Lens' IceServer (Prelude.Maybe Prelude.Text)
iceServer_password :: (Maybe Text -> f (Maybe Text)) -> IceServer -> f IceServer
iceServer_password = (IceServer -> Maybe Text)
-> (IceServer -> Maybe Text -> IceServer)
-> Lens IceServer IceServer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IceServer' {Maybe Text
password :: Maybe Text
$sel:password:IceServer' :: IceServer -> Maybe Text
password} -> Maybe Text
password) (\s :: IceServer
s@IceServer' {} Maybe Text
a -> IceServer
s {$sel:password:IceServer' :: Maybe Text
password = Maybe Text
a} :: IceServer)

instance Core.FromJSON IceServer where
  parseJSON :: Value -> Parser IceServer
parseJSON =
    String -> (Object -> Parser IceServer) -> Value -> Parser IceServer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IceServer"
      ( \Object
x ->
          Maybe Natural
-> Maybe [Text] -> Maybe Text -> Maybe Text -> IceServer
IceServer'
            (Maybe Natural
 -> Maybe [Text] -> Maybe Text -> Maybe Text -> IceServer)
-> Parser (Maybe Natural)
-> Parser (Maybe [Text] -> Maybe Text -> Maybe Text -> IceServer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Ttl")
            Parser (Maybe [Text] -> Maybe Text -> Maybe Text -> IceServer)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> IceServer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Uris" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> IceServer)
-> Parser (Maybe Text) -> Parser (Maybe Text -> IceServer)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Username")
            Parser (Maybe Text -> IceServer)
-> Parser (Maybe Text) -> Parser IceServer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Password")
      )

instance Prelude.Hashable IceServer

instance Prelude.NFData IceServer