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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ListenerTlsFileCertificate -> ListenerTlsFileCertificate -> Bool)
-> (ListenerTlsFileCertificate
    -> ListenerTlsFileCertificate -> Bool)
-> Eq ListenerTlsFileCertificate
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]
(Int -> ReadS ListenerTlsFileCertificate)
-> ReadS [ListenerTlsFileCertificate]
-> ReadPrec ListenerTlsFileCertificate
-> ReadPrec [ListenerTlsFileCertificate]
-> Read 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
(Int -> ListenerTlsFileCertificate -> ShowS)
-> (ListenerTlsFileCertificate -> String)
-> ([ListenerTlsFileCertificate] -> ShowS)
-> Show ListenerTlsFileCertificate
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.
 ListenerTlsFileCertificate -> Rep ListenerTlsFileCertificate x)
-> (forall x.
    Rep ListenerTlsFileCertificate x -> ListenerTlsFileCertificate)
-> Generic ListenerTlsFileCertificate
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' :: Text -> Text -> ListenerTlsFileCertificate
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 :: (Text -> f Text)
-> ListenerTlsFileCertificate -> f ListenerTlsFileCertificate
listenerTlsFileCertificate_certificateChain = (ListenerTlsFileCertificate -> Text)
-> (ListenerTlsFileCertificate
    -> Text -> ListenerTlsFileCertificate)
-> Lens
     ListenerTlsFileCertificate ListenerTlsFileCertificate Text Text
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 :: (Text -> f Text)
-> ListenerTlsFileCertificate -> f ListenerTlsFileCertificate
listenerTlsFileCertificate_privateKey = (ListenerTlsFileCertificate -> Text)
-> (ListenerTlsFileCertificate
    -> Text -> ListenerTlsFileCertificate)
-> Lens
     ListenerTlsFileCertificate ListenerTlsFileCertificate Text Text
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 Core.FromJSON ListenerTlsFileCertificate where
  parseJSON :: Value -> Parser ListenerTlsFileCertificate
parseJSON =
    String
-> (Object -> Parser ListenerTlsFileCertificate)
-> Value
-> Parser ListenerTlsFileCertificate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ListenerTlsFileCertificate"
      ( \Object
x ->
          Text -> Text -> ListenerTlsFileCertificate
ListenerTlsFileCertificate'
            (Text -> Text -> ListenerTlsFileCertificate)
-> Parser Text -> Parser (Text -> ListenerTlsFileCertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"certificateChain")
            Parser (Text -> ListenerTlsFileCertificate)
-> Parser Text -> Parser ListenerTlsFileCertificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"privateKey")
      )

instance Prelude.Hashable ListenerTlsFileCertificate

instance Prelude.NFData ListenerTlsFileCertificate

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"certificateChain" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateChain),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"privateKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
privateKey)
          ]
      )