{-# 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.IoT.Types.TlsContext
-- 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.IoT.Types.TlsContext where

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

-- | Specifies the TLS context to use for the test authorizer request.
--
-- /See:/ 'newTlsContext' smart constructor.
data TlsContext = TlsContext'
  { -- | The value of the @serverName@ key in a TLS authorization request.
    TlsContext -> Maybe Text
serverName :: Prelude.Maybe Prelude.Text
  }
  deriving (TlsContext -> TlsContext -> Bool
(TlsContext -> TlsContext -> Bool)
-> (TlsContext -> TlsContext -> Bool) -> Eq TlsContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TlsContext -> TlsContext -> Bool
$c/= :: TlsContext -> TlsContext -> Bool
== :: TlsContext -> TlsContext -> Bool
$c== :: TlsContext -> TlsContext -> Bool
Prelude.Eq, ReadPrec [TlsContext]
ReadPrec TlsContext
Int -> ReadS TlsContext
ReadS [TlsContext]
(Int -> ReadS TlsContext)
-> ReadS [TlsContext]
-> ReadPrec TlsContext
-> ReadPrec [TlsContext]
-> Read TlsContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TlsContext]
$creadListPrec :: ReadPrec [TlsContext]
readPrec :: ReadPrec TlsContext
$creadPrec :: ReadPrec TlsContext
readList :: ReadS [TlsContext]
$creadList :: ReadS [TlsContext]
readsPrec :: Int -> ReadS TlsContext
$creadsPrec :: Int -> ReadS TlsContext
Prelude.Read, Int -> TlsContext -> ShowS
[TlsContext] -> ShowS
TlsContext -> String
(Int -> TlsContext -> ShowS)
-> (TlsContext -> String)
-> ([TlsContext] -> ShowS)
-> Show TlsContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TlsContext] -> ShowS
$cshowList :: [TlsContext] -> ShowS
show :: TlsContext -> String
$cshow :: TlsContext -> String
showsPrec :: Int -> TlsContext -> ShowS
$cshowsPrec :: Int -> TlsContext -> ShowS
Prelude.Show, (forall x. TlsContext -> Rep TlsContext x)
-> (forall x. Rep TlsContext x -> TlsContext) -> Generic TlsContext
forall x. Rep TlsContext x -> TlsContext
forall x. TlsContext -> Rep TlsContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TlsContext x -> TlsContext
$cfrom :: forall x. TlsContext -> Rep TlsContext x
Prelude.Generic)

-- |
-- Create a value of 'TlsContext' 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:
--
-- 'serverName', 'tlsContext_serverName' - The value of the @serverName@ key in a TLS authorization request.
newTlsContext ::
  TlsContext
newTlsContext :: TlsContext
newTlsContext =
  TlsContext' :: Maybe Text -> TlsContext
TlsContext' {$sel:serverName:TlsContext' :: Maybe Text
serverName = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The value of the @serverName@ key in a TLS authorization request.
tlsContext_serverName :: Lens.Lens' TlsContext (Prelude.Maybe Prelude.Text)
tlsContext_serverName :: (Maybe Text -> f (Maybe Text)) -> TlsContext -> f TlsContext
tlsContext_serverName = (TlsContext -> Maybe Text)
-> (TlsContext -> Maybe Text -> TlsContext)
-> Lens TlsContext TlsContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TlsContext' {Maybe Text
serverName :: Maybe Text
$sel:serverName:TlsContext' :: TlsContext -> Maybe Text
serverName} -> Maybe Text
serverName) (\s :: TlsContext
s@TlsContext' {} Maybe Text
a -> TlsContext
s {$sel:serverName:TlsContext' :: Maybe Text
serverName = Maybe Text
a} :: TlsContext)

instance Prelude.Hashable TlsContext

instance Prelude.NFData TlsContext

instance Core.ToJSON TlsContext where
  toJSON :: TlsContext -> Value
toJSON TlsContext' {Maybe Text
serverName :: Maybe Text
$sel:serverName:TlsContext' :: TlsContext -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"serverName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serverName]
      )