{-# 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.KinesisVideo.Types.SingleMasterChannelEndpointConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisVideo.Types.SingleMasterChannelEndpointConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideo.Types.ChannelProtocol
import Amazonka.KinesisVideo.Types.ChannelRole
import qualified Amazonka.Prelude as Prelude

-- | An object that contains the endpoint configuration for the
-- @SINGLE_MASTER@ channel type.
--
-- /See:/ 'newSingleMasterChannelEndpointConfiguration' smart constructor.
data SingleMasterChannelEndpointConfiguration = SingleMasterChannelEndpointConfiguration'
  { -- | This property is used to determine the nature of communication over this
    -- @SINGLE_MASTER@ signaling channel. If @WSS@ is specified, this API
    -- returns a websocket endpoint. If @HTTPS@ is specified, this API returns
    -- an @HTTPS@ endpoint.
    SingleMasterChannelEndpointConfiguration
-> Maybe (NonEmpty ChannelProtocol)
protocols :: Prelude.Maybe (Prelude.NonEmpty ChannelProtocol),
    -- | This property is used to determine messaging permissions in this
    -- @SINGLE_MASTER@ signaling channel. If @MASTER@ is specified, this API
    -- returns an endpoint that a client can use to receive offers from and
    -- send answers to any of the viewers on this signaling channel. If
    -- @VIEWER@ is specified, this API returns an endpoint that a client can
    -- use only to send offers to another @MASTER@ client on this signaling
    -- channel.
    SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole
role' :: Prelude.Maybe ChannelRole
  }
  deriving (SingleMasterChannelEndpointConfiguration
-> SingleMasterChannelEndpointConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SingleMasterChannelEndpointConfiguration
-> SingleMasterChannelEndpointConfiguration -> Bool
$c/= :: SingleMasterChannelEndpointConfiguration
-> SingleMasterChannelEndpointConfiguration -> Bool
== :: SingleMasterChannelEndpointConfiguration
-> SingleMasterChannelEndpointConfiguration -> Bool
$c== :: SingleMasterChannelEndpointConfiguration
-> SingleMasterChannelEndpointConfiguration -> Bool
Prelude.Eq, ReadPrec [SingleMasterChannelEndpointConfiguration]
ReadPrec SingleMasterChannelEndpointConfiguration
Int -> ReadS SingleMasterChannelEndpointConfiguration
ReadS [SingleMasterChannelEndpointConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SingleMasterChannelEndpointConfiguration]
$creadListPrec :: ReadPrec [SingleMasterChannelEndpointConfiguration]
readPrec :: ReadPrec SingleMasterChannelEndpointConfiguration
$creadPrec :: ReadPrec SingleMasterChannelEndpointConfiguration
readList :: ReadS [SingleMasterChannelEndpointConfiguration]
$creadList :: ReadS [SingleMasterChannelEndpointConfiguration]
readsPrec :: Int -> ReadS SingleMasterChannelEndpointConfiguration
$creadsPrec :: Int -> ReadS SingleMasterChannelEndpointConfiguration
Prelude.Read, Int -> SingleMasterChannelEndpointConfiguration -> ShowS
[SingleMasterChannelEndpointConfiguration] -> ShowS
SingleMasterChannelEndpointConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SingleMasterChannelEndpointConfiguration] -> ShowS
$cshowList :: [SingleMasterChannelEndpointConfiguration] -> ShowS
show :: SingleMasterChannelEndpointConfiguration -> String
$cshow :: SingleMasterChannelEndpointConfiguration -> String
showsPrec :: Int -> SingleMasterChannelEndpointConfiguration -> ShowS
$cshowsPrec :: Int -> SingleMasterChannelEndpointConfiguration -> ShowS
Prelude.Show, forall x.
Rep SingleMasterChannelEndpointConfiguration x
-> SingleMasterChannelEndpointConfiguration
forall x.
SingleMasterChannelEndpointConfiguration
-> Rep SingleMasterChannelEndpointConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SingleMasterChannelEndpointConfiguration x
-> SingleMasterChannelEndpointConfiguration
$cfrom :: forall x.
SingleMasterChannelEndpointConfiguration
-> Rep SingleMasterChannelEndpointConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SingleMasterChannelEndpointConfiguration' 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:
--
-- 'protocols', 'singleMasterChannelEndpointConfiguration_protocols' - This property is used to determine the nature of communication over this
-- @SINGLE_MASTER@ signaling channel. If @WSS@ is specified, this API
-- returns a websocket endpoint. If @HTTPS@ is specified, this API returns
-- an @HTTPS@ endpoint.
--
-- 'role'', 'singleMasterChannelEndpointConfiguration_role' - This property is used to determine messaging permissions in this
-- @SINGLE_MASTER@ signaling channel. If @MASTER@ is specified, this API
-- returns an endpoint that a client can use to receive offers from and
-- send answers to any of the viewers on this signaling channel. If
-- @VIEWER@ is specified, this API returns an endpoint that a client can
-- use only to send offers to another @MASTER@ client on this signaling
-- channel.
newSingleMasterChannelEndpointConfiguration ::
  SingleMasterChannelEndpointConfiguration
newSingleMasterChannelEndpointConfiguration :: SingleMasterChannelEndpointConfiguration
newSingleMasterChannelEndpointConfiguration =
  SingleMasterChannelEndpointConfiguration'
    { $sel:protocols:SingleMasterChannelEndpointConfiguration' :: Maybe (NonEmpty ChannelProtocol)
protocols =
        forall a. Maybe a
Prelude.Nothing,
      $sel:role':SingleMasterChannelEndpointConfiguration' :: Maybe ChannelRole
role' = forall a. Maybe a
Prelude.Nothing
    }

-- | This property is used to determine the nature of communication over this
-- @SINGLE_MASTER@ signaling channel. If @WSS@ is specified, this API
-- returns a websocket endpoint. If @HTTPS@ is specified, this API returns
-- an @HTTPS@ endpoint.
singleMasterChannelEndpointConfiguration_protocols :: Lens.Lens' SingleMasterChannelEndpointConfiguration (Prelude.Maybe (Prelude.NonEmpty ChannelProtocol))
singleMasterChannelEndpointConfiguration_protocols :: Lens'
  SingleMasterChannelEndpointConfiguration
  (Maybe (NonEmpty ChannelProtocol))
singleMasterChannelEndpointConfiguration_protocols = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SingleMasterChannelEndpointConfiguration' {Maybe (NonEmpty ChannelProtocol)
protocols :: Maybe (NonEmpty ChannelProtocol)
$sel:protocols:SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration
-> Maybe (NonEmpty ChannelProtocol)
protocols} -> Maybe (NonEmpty ChannelProtocol)
protocols) (\s :: SingleMasterChannelEndpointConfiguration
s@SingleMasterChannelEndpointConfiguration' {} Maybe (NonEmpty ChannelProtocol)
a -> SingleMasterChannelEndpointConfiguration
s {$sel:protocols:SingleMasterChannelEndpointConfiguration' :: Maybe (NonEmpty ChannelProtocol)
protocols = Maybe (NonEmpty ChannelProtocol)
a} :: SingleMasterChannelEndpointConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This property is used to determine messaging permissions in this
-- @SINGLE_MASTER@ signaling channel. If @MASTER@ is specified, this API
-- returns an endpoint that a client can use to receive offers from and
-- send answers to any of the viewers on this signaling channel. If
-- @VIEWER@ is specified, this API returns an endpoint that a client can
-- use only to send offers to another @MASTER@ client on this signaling
-- channel.
singleMasterChannelEndpointConfiguration_role :: Lens.Lens' SingleMasterChannelEndpointConfiguration (Prelude.Maybe ChannelRole)
singleMasterChannelEndpointConfiguration_role :: Lens' SingleMasterChannelEndpointConfiguration (Maybe ChannelRole)
singleMasterChannelEndpointConfiguration_role = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SingleMasterChannelEndpointConfiguration' {Maybe ChannelRole
role' :: Maybe ChannelRole
$sel:role':SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole
role'} -> Maybe ChannelRole
role') (\s :: SingleMasterChannelEndpointConfiguration
s@SingleMasterChannelEndpointConfiguration' {} Maybe ChannelRole
a -> SingleMasterChannelEndpointConfiguration
s {$sel:role':SingleMasterChannelEndpointConfiguration' :: Maybe ChannelRole
role' = Maybe ChannelRole
a} :: SingleMasterChannelEndpointConfiguration)

instance
  Prelude.Hashable
    SingleMasterChannelEndpointConfiguration
  where
  hashWithSalt :: Int -> SingleMasterChannelEndpointConfiguration -> Int
hashWithSalt
    Int
_salt
    SingleMasterChannelEndpointConfiguration' {Maybe (NonEmpty ChannelProtocol)
Maybe ChannelRole
role' :: Maybe ChannelRole
protocols :: Maybe (NonEmpty ChannelProtocol)
$sel:role':SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole
$sel:protocols:SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration
-> Maybe (NonEmpty ChannelProtocol)
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ChannelProtocol)
protocols
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChannelRole
role'

instance
  Prelude.NFData
    SingleMasterChannelEndpointConfiguration
  where
  rnf :: SingleMasterChannelEndpointConfiguration -> ()
rnf SingleMasterChannelEndpointConfiguration' {Maybe (NonEmpty ChannelProtocol)
Maybe ChannelRole
role' :: Maybe ChannelRole
protocols :: Maybe (NonEmpty ChannelProtocol)
$sel:role':SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole
$sel:protocols:SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration
-> Maybe (NonEmpty ChannelProtocol)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ChannelProtocol)
protocols
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChannelRole
role'

instance
  Data.ToJSON
    SingleMasterChannelEndpointConfiguration
  where
  toJSON :: SingleMasterChannelEndpointConfiguration -> Value
toJSON SingleMasterChannelEndpointConfiguration' {Maybe (NonEmpty ChannelProtocol)
Maybe ChannelRole
role' :: Maybe ChannelRole
protocols :: Maybe (NonEmpty ChannelProtocol)
$sel:role':SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole
$sel:protocols:SingleMasterChannelEndpointConfiguration' :: SingleMasterChannelEndpointConfiguration
-> Maybe (NonEmpty ChannelProtocol)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Protocols" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ChannelProtocol)
protocols,
            (Key
"Role" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelRole
role'
          ]
      )