{-# 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-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.KinesisVideo.Types.SingleMasterChannelEndpointConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideo.Types.ChannelProtocol
import Amazonka.KinesisVideo.Types.ChannelRole
import qualified Amazonka.Lens as Lens
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
(SingleMasterChannelEndpointConfiguration
 -> SingleMasterChannelEndpointConfiguration -> Bool)
-> (SingleMasterChannelEndpointConfiguration
    -> SingleMasterChannelEndpointConfiguration -> Bool)
-> Eq SingleMasterChannelEndpointConfiguration
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]
(Int -> ReadS SingleMasterChannelEndpointConfiguration)
-> ReadS [SingleMasterChannelEndpointConfiguration]
-> ReadPrec SingleMasterChannelEndpointConfiguration
-> ReadPrec [SingleMasterChannelEndpointConfiguration]
-> Read 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
(Int -> SingleMasterChannelEndpointConfiguration -> ShowS)
-> (SingleMasterChannelEndpointConfiguration -> String)
-> ([SingleMasterChannelEndpointConfiguration] -> ShowS)
-> Show SingleMasterChannelEndpointConfiguration
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.
 SingleMasterChannelEndpointConfiguration
 -> Rep SingleMasterChannelEndpointConfiguration x)
-> (forall x.
    Rep SingleMasterChannelEndpointConfiguration x
    -> SingleMasterChannelEndpointConfiguration)
-> Generic SingleMasterChannelEndpointConfiguration
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' :: Maybe (NonEmpty ChannelProtocol)
-> Maybe ChannelRole -> SingleMasterChannelEndpointConfiguration
SingleMasterChannelEndpointConfiguration'
    { $sel:protocols:SingleMasterChannelEndpointConfiguration' :: Maybe (NonEmpty ChannelProtocol)
protocols =
        Maybe (NonEmpty ChannelProtocol)
forall a. Maybe a
Prelude.Nothing,
      $sel:role':SingleMasterChannelEndpointConfiguration' :: Maybe ChannelRole
role' = Maybe ChannelRole
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 :: (Maybe (NonEmpty ChannelProtocol)
 -> f (Maybe (NonEmpty ChannelProtocol)))
-> SingleMasterChannelEndpointConfiguration
-> f SingleMasterChannelEndpointConfiguration
singleMasterChannelEndpointConfiguration_protocols = (SingleMasterChannelEndpointConfiguration
 -> Maybe (NonEmpty ChannelProtocol))
-> (SingleMasterChannelEndpointConfiguration
    -> Maybe (NonEmpty ChannelProtocol)
    -> SingleMasterChannelEndpointConfiguration)
-> Lens
     SingleMasterChannelEndpointConfiguration
     SingleMasterChannelEndpointConfiguration
     (Maybe (NonEmpty ChannelProtocol))
     (Maybe (NonEmpty ChannelProtocol))
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) ((Maybe (NonEmpty ChannelProtocol)
  -> f (Maybe (NonEmpty ChannelProtocol)))
 -> SingleMasterChannelEndpointConfiguration
 -> f SingleMasterChannelEndpointConfiguration)
-> ((Maybe (NonEmpty ChannelProtocol)
     -> f (Maybe (NonEmpty ChannelProtocol)))
    -> Maybe (NonEmpty ChannelProtocol)
    -> f (Maybe (NonEmpty ChannelProtocol)))
-> (Maybe (NonEmpty ChannelProtocol)
    -> f (Maybe (NonEmpty ChannelProtocol)))
-> SingleMasterChannelEndpointConfiguration
-> f SingleMasterChannelEndpointConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
-> Iso
     (Maybe (NonEmpty ChannelProtocol))
     (Maybe (NonEmpty ChannelProtocol))
     (Maybe (NonEmpty ChannelProtocol))
     (Maybe (NonEmpty ChannelProtocol))
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
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
  (NonEmpty ChannelProtocol)
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 :: (Maybe ChannelRole -> f (Maybe ChannelRole))
-> SingleMasterChannelEndpointConfiguration
-> f SingleMasterChannelEndpointConfiguration
singleMasterChannelEndpointConfiguration_role = (SingleMasterChannelEndpointConfiguration -> Maybe ChannelRole)
-> (SingleMasterChannelEndpointConfiguration
    -> Maybe ChannelRole -> SingleMasterChannelEndpointConfiguration)
-> Lens
     SingleMasterChannelEndpointConfiguration
     SingleMasterChannelEndpointConfiguration
     (Maybe ChannelRole)
     (Maybe ChannelRole)
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

instance
  Prelude.NFData
    SingleMasterChannelEndpointConfiguration

instance
  Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Protocols" Text -> NonEmpty ChannelProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ChannelProtocol -> Pair)
-> Maybe (NonEmpty ChannelProtocol) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ChannelProtocol)
protocols,
            (Text
"Role" Text -> ChannelRole -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ChannelRole -> Pair) -> Maybe ChannelRole -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelRole
role'
          ]
      )