{-# 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.ConnectParticipant.Types.Websocket
-- 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.ConnectParticipant.Types.Websocket where

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

-- | The websocket for the participant\'s connection.
--
-- /See:/ 'newWebsocket' smart constructor.
data Websocket = Websocket'
  { -- | The URL of the websocket.
    Websocket -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The URL expiration timestamp in ISO date format.
    --
    -- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
    -- example, 2019-11-08T02:41:28.172Z.
    Websocket -> Maybe Text
connectionExpiry :: Prelude.Maybe Prelude.Text
  }
  deriving (Websocket -> Websocket -> Bool
(Websocket -> Websocket -> Bool)
-> (Websocket -> Websocket -> Bool) -> Eq Websocket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Websocket -> Websocket -> Bool
$c/= :: Websocket -> Websocket -> Bool
== :: Websocket -> Websocket -> Bool
$c== :: Websocket -> Websocket -> Bool
Prelude.Eq, ReadPrec [Websocket]
ReadPrec Websocket
Int -> ReadS Websocket
ReadS [Websocket]
(Int -> ReadS Websocket)
-> ReadS [Websocket]
-> ReadPrec Websocket
-> ReadPrec [Websocket]
-> Read Websocket
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Websocket]
$creadListPrec :: ReadPrec [Websocket]
readPrec :: ReadPrec Websocket
$creadPrec :: ReadPrec Websocket
readList :: ReadS [Websocket]
$creadList :: ReadS [Websocket]
readsPrec :: Int -> ReadS Websocket
$creadsPrec :: Int -> ReadS Websocket
Prelude.Read, Int -> Websocket -> ShowS
[Websocket] -> ShowS
Websocket -> String
(Int -> Websocket -> ShowS)
-> (Websocket -> String)
-> ([Websocket] -> ShowS)
-> Show Websocket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Websocket] -> ShowS
$cshowList :: [Websocket] -> ShowS
show :: Websocket -> String
$cshow :: Websocket -> String
showsPrec :: Int -> Websocket -> ShowS
$cshowsPrec :: Int -> Websocket -> ShowS
Prelude.Show, (forall x. Websocket -> Rep Websocket x)
-> (forall x. Rep Websocket x -> Websocket) -> Generic Websocket
forall x. Rep Websocket x -> Websocket
forall x. Websocket -> Rep Websocket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Websocket x -> Websocket
$cfrom :: forall x. Websocket -> Rep Websocket x
Prelude.Generic)

-- |
-- Create a value of 'Websocket' 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:
--
-- 'url', 'websocket_url' - The URL of the websocket.
--
-- 'connectionExpiry', 'websocket_connectionExpiry' - The URL expiration timestamp in ISO date format.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
newWebsocket ::
  Websocket
newWebsocket :: Websocket
newWebsocket =
  Websocket' :: Maybe Text -> Maybe Text -> Websocket
Websocket'
    { $sel:url:Websocket' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionExpiry:Websocket' :: Maybe Text
connectionExpiry = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The URL of the websocket.
websocket_url :: Lens.Lens' Websocket (Prelude.Maybe Prelude.Text)
websocket_url :: (Maybe Text -> f (Maybe Text)) -> Websocket -> f Websocket
websocket_url = (Websocket -> Maybe Text)
-> (Websocket -> Maybe Text -> Websocket)
-> Lens Websocket Websocket (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Websocket' {Maybe Text
url :: Maybe Text
$sel:url:Websocket' :: Websocket -> Maybe Text
url} -> Maybe Text
url) (\s :: Websocket
s@Websocket' {} Maybe Text
a -> Websocket
s {$sel:url:Websocket' :: Maybe Text
url = Maybe Text
a} :: Websocket)

-- | The URL expiration timestamp in ISO date format.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
websocket_connectionExpiry :: Lens.Lens' Websocket (Prelude.Maybe Prelude.Text)
websocket_connectionExpiry :: (Maybe Text -> f (Maybe Text)) -> Websocket -> f Websocket
websocket_connectionExpiry = (Websocket -> Maybe Text)
-> (Websocket -> Maybe Text -> Websocket)
-> Lens Websocket Websocket (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Websocket' {Maybe Text
connectionExpiry :: Maybe Text
$sel:connectionExpiry:Websocket' :: Websocket -> Maybe Text
connectionExpiry} -> Maybe Text
connectionExpiry) (\s :: Websocket
s@Websocket' {} Maybe Text
a -> Websocket
s {$sel:connectionExpiry:Websocket' :: Maybe Text
connectionExpiry = Maybe Text
a} :: Websocket)

instance Core.FromJSON Websocket where
  parseJSON :: Value -> Parser Websocket
parseJSON =
    String -> (Object -> Parser Websocket) -> Value -> Parser Websocket
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Websocket"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Websocket
Websocket'
            (Maybe Text -> Maybe Text -> Websocket)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Websocket)
forall (f :: * -> *) a b. Functor 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
"Url")
            Parser (Maybe Text -> Websocket)
-> Parser (Maybe Text) -> Parser Websocket
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
"ConnectionExpiry")
      )

instance Prelude.Hashable Websocket

instance Prelude.NFData Websocket