{-# 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.AppMesh.Types.ListenerTlsFileCertificate
-- 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.AppMesh.Types.ListenerTlsFileCertificate 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

-- | An object that represents a local file certificate. The certificate must
-- meet specific requirements and you must have proxy authorization
-- enabled. For more information, see
-- <https://docs.aws.amazon.com/app-mesh/latest/userguide/tls.html#virtual-node-tls-prerequisites Transport Layer Security (TLS)>.
--
-- /See:/ 'newListenerTlsFileCertificate' smart constructor.
data ListenerTlsFileCertificate = ListenerTlsFileCertificate'
  { -- | The certificate chain for the certificate.
    ListenerTlsFileCertificate -> Text
certificateChain :: Prelude.Text,
    -- | The private key for a certificate stored on the file system of the
    -- virtual node that the proxy is running on.
    ListenerTlsFileCertificate -> Text
privateKey :: Prelude.Text
  }
  deriving (ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool
$c/= :: ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool
== :: ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool
$c== :: ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool
Prelude.Eq, ReadPrec [ListenerTlsFileCertificate]
ReadPrec ListenerTlsFileCertificate
Int -> ReadS ListenerTlsFileCertificate
ReadS [ListenerTlsFileCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListenerTlsFileCertificate]
$creadListPrec :: ReadPrec [ListenerTlsFileCertificate]
readPrec :: ReadPrec ListenerTlsFileCertificate
$creadPrec :: ReadPrec ListenerTlsFileCertificate
readList :: ReadS [ListenerTlsFileCertificate]
$creadList :: ReadS [ListenerTlsFileCertificate]
readsPrec :: Int -> ReadS ListenerTlsFileCertificate
$creadsPrec :: Int -> ReadS ListenerTlsFileCertificate
Prelude.Read, Int -> ListenerTlsFileCertificate -> ShowS
[ListenerTlsFileCertificate] -> ShowS
ListenerTlsFileCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListenerTlsFileCertificate] -> ShowS
$cshowList :: [ListenerTlsFileCertificate] -> ShowS
show :: ListenerTlsFileCertificate -> String
$cshow :: ListenerTlsFileCertificate -> String
showsPrec :: Int -> ListenerTlsFileCertificate -> ShowS
$cshowsPrec :: Int -> ListenerTlsFileCertificate -> ShowS
Prelude.Show, forall x.
Rep ListenerTlsFileCertificate x -> ListenerTlsFileCertificate
forall x.
ListenerTlsFileCertificate -> Rep ListenerTlsFileCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListenerTlsFileCertificate x -> ListenerTlsFileCertificate
$cfrom :: forall x.
ListenerTlsFileCertificate -> Rep ListenerTlsFileCertificate x
Prelude.Generic)

-- |
-- Create a value of 'ListenerTlsFileCertificate' 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:
--
-- 'certificateChain', 'listenerTlsFileCertificate_certificateChain' - The certificate chain for the certificate.
--
-- 'privateKey', 'listenerTlsFileCertificate_privateKey' - The private key for a certificate stored on the file system of the
-- virtual node that the proxy is running on.
newListenerTlsFileCertificate ::
  -- | 'certificateChain'
  Prelude.Text ->
  -- | 'privateKey'
  Prelude.Text ->
  ListenerTlsFileCertificate
newListenerTlsFileCertificate :: Text -> Text -> ListenerTlsFileCertificate
newListenerTlsFileCertificate
  Text
pCertificateChain_
  Text
pPrivateKey_ =
    ListenerTlsFileCertificate'
      { $sel:certificateChain:ListenerTlsFileCertificate' :: Text
certificateChain =
          Text
pCertificateChain_,
        $sel:privateKey:ListenerTlsFileCertificate' :: Text
privateKey = Text
pPrivateKey_
      }

-- | The certificate chain for the certificate.
listenerTlsFileCertificate_certificateChain :: Lens.Lens' ListenerTlsFileCertificate Prelude.Text
listenerTlsFileCertificate_certificateChain :: Lens' ListenerTlsFileCertificate Text
listenerTlsFileCertificate_certificateChain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListenerTlsFileCertificate' {Text
certificateChain :: Text
$sel:certificateChain:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
certificateChain} -> Text
certificateChain) (\s :: ListenerTlsFileCertificate
s@ListenerTlsFileCertificate' {} Text
a -> ListenerTlsFileCertificate
s {$sel:certificateChain:ListenerTlsFileCertificate' :: Text
certificateChain = Text
a} :: ListenerTlsFileCertificate)

-- | The private key for a certificate stored on the file system of the
-- virtual node that the proxy is running on.
listenerTlsFileCertificate_privateKey :: Lens.Lens' ListenerTlsFileCertificate Prelude.Text
listenerTlsFileCertificate_privateKey :: Lens' ListenerTlsFileCertificate Text
listenerTlsFileCertificate_privateKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListenerTlsFileCertificate' {Text
privateKey :: Text
$sel:privateKey:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
privateKey} -> Text
privateKey) (\s :: ListenerTlsFileCertificate
s@ListenerTlsFileCertificate' {} Text
a -> ListenerTlsFileCertificate
s {$sel:privateKey:ListenerTlsFileCertificate' :: Text
privateKey = Text
a} :: ListenerTlsFileCertificate)

instance Data.FromJSON ListenerTlsFileCertificate where
  parseJSON :: Value -> Parser ListenerTlsFileCertificate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ListenerTlsFileCertificate"
      ( \Object
x ->
          Text -> Text -> ListenerTlsFileCertificate
ListenerTlsFileCertificate'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"certificateChain")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"privateKey")
      )

instance Prelude.Hashable ListenerTlsFileCertificate where
  hashWithSalt :: Int -> ListenerTlsFileCertificate -> Int
hashWithSalt Int
_salt ListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
$sel:certificateChain:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateChain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
privateKey

instance Prelude.NFData ListenerTlsFileCertificate where
  rnf :: ListenerTlsFileCertificate -> ()
rnf ListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
$sel:certificateChain:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
certificateChain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
privateKey

instance Data.ToJSON ListenerTlsFileCertificate where
  toJSON :: ListenerTlsFileCertificate -> Value
toJSON ListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
$sel:certificateChain:ListenerTlsFileCertificate' :: ListenerTlsFileCertificate -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"certificateChain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
certificateChain),
            forall a. a -> Maybe a
Prelude.Just (Key
"privateKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
privateKey)
          ]
      )