{-# 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.VirtualGatewayListenerTlsFileCertificate
-- 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.VirtualGatewayListenerTlsFileCertificate 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:/ 'newVirtualGatewayListenerTlsFileCertificate' smart constructor.
data VirtualGatewayListenerTlsFileCertificate = VirtualGatewayListenerTlsFileCertificate'
  { -- | The certificate chain for the certificate.
    VirtualGatewayListenerTlsFileCertificate -> Text
certificateChain :: Prelude.Text,
    -- | The private key for a certificate stored on the file system of the mesh
    -- endpoint that the proxy is running on.
    VirtualGatewayListenerTlsFileCertificate -> Text
privateKey :: Prelude.Text
  }
  deriving (VirtualGatewayListenerTlsFileCertificate
-> VirtualGatewayListenerTlsFileCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayListenerTlsFileCertificate
-> VirtualGatewayListenerTlsFileCertificate -> Bool
$c/= :: VirtualGatewayListenerTlsFileCertificate
-> VirtualGatewayListenerTlsFileCertificate -> Bool
== :: VirtualGatewayListenerTlsFileCertificate
-> VirtualGatewayListenerTlsFileCertificate -> Bool
$c== :: VirtualGatewayListenerTlsFileCertificate
-> VirtualGatewayListenerTlsFileCertificate -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayListenerTlsFileCertificate]
ReadPrec VirtualGatewayListenerTlsFileCertificate
Int -> ReadS VirtualGatewayListenerTlsFileCertificate
ReadS [VirtualGatewayListenerTlsFileCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayListenerTlsFileCertificate]
$creadListPrec :: ReadPrec [VirtualGatewayListenerTlsFileCertificate]
readPrec :: ReadPrec VirtualGatewayListenerTlsFileCertificate
$creadPrec :: ReadPrec VirtualGatewayListenerTlsFileCertificate
readList :: ReadS [VirtualGatewayListenerTlsFileCertificate]
$creadList :: ReadS [VirtualGatewayListenerTlsFileCertificate]
readsPrec :: Int -> ReadS VirtualGatewayListenerTlsFileCertificate
$creadsPrec :: Int -> ReadS VirtualGatewayListenerTlsFileCertificate
Prelude.Read, Int -> VirtualGatewayListenerTlsFileCertificate -> ShowS
[VirtualGatewayListenerTlsFileCertificate] -> ShowS
VirtualGatewayListenerTlsFileCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayListenerTlsFileCertificate] -> ShowS
$cshowList :: [VirtualGatewayListenerTlsFileCertificate] -> ShowS
show :: VirtualGatewayListenerTlsFileCertificate -> String
$cshow :: VirtualGatewayListenerTlsFileCertificate -> String
showsPrec :: Int -> VirtualGatewayListenerTlsFileCertificate -> ShowS
$cshowsPrec :: Int -> VirtualGatewayListenerTlsFileCertificate -> ShowS
Prelude.Show, forall x.
Rep VirtualGatewayListenerTlsFileCertificate x
-> VirtualGatewayListenerTlsFileCertificate
forall x.
VirtualGatewayListenerTlsFileCertificate
-> Rep VirtualGatewayListenerTlsFileCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayListenerTlsFileCertificate x
-> VirtualGatewayListenerTlsFileCertificate
$cfrom :: forall x.
VirtualGatewayListenerTlsFileCertificate
-> Rep VirtualGatewayListenerTlsFileCertificate x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayListenerTlsFileCertificate' 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', 'virtualGatewayListenerTlsFileCertificate_certificateChain' - The certificate chain for the certificate.
--
-- 'privateKey', 'virtualGatewayListenerTlsFileCertificate_privateKey' - The private key for a certificate stored on the file system of the mesh
-- endpoint that the proxy is running on.
newVirtualGatewayListenerTlsFileCertificate ::
  -- | 'certificateChain'
  Prelude.Text ->
  -- | 'privateKey'
  Prelude.Text ->
  VirtualGatewayListenerTlsFileCertificate
newVirtualGatewayListenerTlsFileCertificate :: Text -> Text -> VirtualGatewayListenerTlsFileCertificate
newVirtualGatewayListenerTlsFileCertificate
  Text
pCertificateChain_
  Text
pPrivateKey_ =
    VirtualGatewayListenerTlsFileCertificate'
      { $sel:certificateChain:VirtualGatewayListenerTlsFileCertificate' :: Text
certificateChain =
          Text
pCertificateChain_,
        $sel:privateKey:VirtualGatewayListenerTlsFileCertificate' :: Text
privateKey = Text
pPrivateKey_
      }

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

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

instance
  Data.FromJSON
    VirtualGatewayListenerTlsFileCertificate
  where
  parseJSON :: Value -> Parser VirtualGatewayListenerTlsFileCertificate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayListenerTlsFileCertificate"
      ( \Object
x ->
          Text -> Text -> VirtualGatewayListenerTlsFileCertificate
VirtualGatewayListenerTlsFileCertificate'
            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
    VirtualGatewayListenerTlsFileCertificate
  where
  hashWithSalt :: Int -> VirtualGatewayListenerTlsFileCertificate -> Int
hashWithSalt
    Int
_salt
    VirtualGatewayListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> Text
$sel:certificateChain:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> 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
    VirtualGatewayListenerTlsFileCertificate
  where
  rnf :: VirtualGatewayListenerTlsFileCertificate -> ()
rnf VirtualGatewayListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> Text
$sel:certificateChain:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> 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
    VirtualGatewayListenerTlsFileCertificate
  where
  toJSON :: VirtualGatewayListenerTlsFileCertificate -> Value
toJSON VirtualGatewayListenerTlsFileCertificate' {Text
privateKey :: Text
certificateChain :: Text
$sel:privateKey:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> Text
$sel:certificateChain:VirtualGatewayListenerTlsFileCertificate' :: VirtualGatewayListenerTlsFileCertificate -> 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)
          ]
      )