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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:serverName:TlsContext' :: Maybe Text
serverName = 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 :: Lens' TlsContext (Maybe Text)
tlsContext_serverName = 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 where
  hashWithSalt :: Int -> TlsContext -> Int
hashWithSalt Int
_salt TlsContext' {Maybe Text
serverName :: Maybe Text
$sel:serverName:TlsContext' :: TlsContext -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serverName

instance Prelude.NFData TlsContext where
  rnf :: TlsContext -> ()
rnf TlsContext' {Maybe Text
serverName :: Maybe Text
$sel:serverName:TlsContext' :: TlsContext -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serverName

instance Data.ToJSON TlsContext where
  toJSON :: TlsContext -> Value
toJSON TlsContext' {Maybe Text
serverName :: Maybe Text
$sel:serverName:TlsContext' :: TlsContext -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"serverName" 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 Text
serverName]
      )