{-# 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.ClientTlsCertificate
-- 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.ClientTlsCertificate where

import Amazonka.AppMesh.Types.ListenerTlsFileCertificate
import Amazonka.AppMesh.Types.ListenerTlsSdsCertificate
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 the client\'s certificate.
--
-- /See:/ 'newClientTlsCertificate' smart constructor.
data ClientTlsCertificate = ClientTlsCertificate'
  { -- | 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 Transport Layer Security (TLS)>.
    ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
file :: Prelude.Maybe ListenerTlsFileCertificate,
    -- | A reference to an object that represents a client\'s TLS Secret
    -- Discovery Service certificate.
    ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
sds :: Prelude.Maybe ListenerTlsSdsCertificate
  }
  deriving (ClientTlsCertificate -> ClientTlsCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientTlsCertificate -> ClientTlsCertificate -> Bool
$c/= :: ClientTlsCertificate -> ClientTlsCertificate -> Bool
== :: ClientTlsCertificate -> ClientTlsCertificate -> Bool
$c== :: ClientTlsCertificate -> ClientTlsCertificate -> Bool
Prelude.Eq, ReadPrec [ClientTlsCertificate]
ReadPrec ClientTlsCertificate
Int -> ReadS ClientTlsCertificate
ReadS [ClientTlsCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClientTlsCertificate]
$creadListPrec :: ReadPrec [ClientTlsCertificate]
readPrec :: ReadPrec ClientTlsCertificate
$creadPrec :: ReadPrec ClientTlsCertificate
readList :: ReadS [ClientTlsCertificate]
$creadList :: ReadS [ClientTlsCertificate]
readsPrec :: Int -> ReadS ClientTlsCertificate
$creadsPrec :: Int -> ReadS ClientTlsCertificate
Prelude.Read, Int -> ClientTlsCertificate -> ShowS
[ClientTlsCertificate] -> ShowS
ClientTlsCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientTlsCertificate] -> ShowS
$cshowList :: [ClientTlsCertificate] -> ShowS
show :: ClientTlsCertificate -> String
$cshow :: ClientTlsCertificate -> String
showsPrec :: Int -> ClientTlsCertificate -> ShowS
$cshowsPrec :: Int -> ClientTlsCertificate -> ShowS
Prelude.Show, forall x. Rep ClientTlsCertificate x -> ClientTlsCertificate
forall x. ClientTlsCertificate -> Rep ClientTlsCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClientTlsCertificate x -> ClientTlsCertificate
$cfrom :: forall x. ClientTlsCertificate -> Rep ClientTlsCertificate x
Prelude.Generic)

-- |
-- Create a value of 'ClientTlsCertificate' 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:
--
-- 'file', 'clientTlsCertificate_file' - 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 Transport Layer Security (TLS)>.
--
-- 'sds', 'clientTlsCertificate_sds' - A reference to an object that represents a client\'s TLS Secret
-- Discovery Service certificate.
newClientTlsCertificate ::
  ClientTlsCertificate
newClientTlsCertificate :: ClientTlsCertificate
newClientTlsCertificate =
  ClientTlsCertificate'
    { $sel:file:ClientTlsCertificate' :: Maybe ListenerTlsFileCertificate
file = forall a. Maybe a
Prelude.Nothing,
      $sel:sds:ClientTlsCertificate' :: Maybe ListenerTlsSdsCertificate
sds = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 Transport Layer Security (TLS)>.
clientTlsCertificate_file :: Lens.Lens' ClientTlsCertificate (Prelude.Maybe ListenerTlsFileCertificate)
clientTlsCertificate_file :: Lens' ClientTlsCertificate (Maybe ListenerTlsFileCertificate)
clientTlsCertificate_file = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientTlsCertificate' {Maybe ListenerTlsFileCertificate
file :: Maybe ListenerTlsFileCertificate
$sel:file:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
file} -> Maybe ListenerTlsFileCertificate
file) (\s :: ClientTlsCertificate
s@ClientTlsCertificate' {} Maybe ListenerTlsFileCertificate
a -> ClientTlsCertificate
s {$sel:file:ClientTlsCertificate' :: Maybe ListenerTlsFileCertificate
file = Maybe ListenerTlsFileCertificate
a} :: ClientTlsCertificate)

-- | A reference to an object that represents a client\'s TLS Secret
-- Discovery Service certificate.
clientTlsCertificate_sds :: Lens.Lens' ClientTlsCertificate (Prelude.Maybe ListenerTlsSdsCertificate)
clientTlsCertificate_sds :: Lens' ClientTlsCertificate (Maybe ListenerTlsSdsCertificate)
clientTlsCertificate_sds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientTlsCertificate' {Maybe ListenerTlsSdsCertificate
sds :: Maybe ListenerTlsSdsCertificate
$sel:sds:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
sds} -> Maybe ListenerTlsSdsCertificate
sds) (\s :: ClientTlsCertificate
s@ClientTlsCertificate' {} Maybe ListenerTlsSdsCertificate
a -> ClientTlsCertificate
s {$sel:sds:ClientTlsCertificate' :: Maybe ListenerTlsSdsCertificate
sds = Maybe ListenerTlsSdsCertificate
a} :: ClientTlsCertificate)

instance Data.FromJSON ClientTlsCertificate where
  parseJSON :: Value -> Parser ClientTlsCertificate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClientTlsCertificate"
      ( \Object
x ->
          Maybe ListenerTlsFileCertificate
-> Maybe ListenerTlsSdsCertificate -> ClientTlsCertificate
ClientTlsCertificate'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"file")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sds")
      )

instance Prelude.Hashable ClientTlsCertificate where
  hashWithSalt :: Int -> ClientTlsCertificate -> Int
hashWithSalt Int
_salt ClientTlsCertificate' {Maybe ListenerTlsFileCertificate
Maybe ListenerTlsSdsCertificate
sds :: Maybe ListenerTlsSdsCertificate
file :: Maybe ListenerTlsFileCertificate
$sel:sds:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
$sel:file:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListenerTlsFileCertificate
file
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListenerTlsSdsCertificate
sds

instance Prelude.NFData ClientTlsCertificate where
  rnf :: ClientTlsCertificate -> ()
rnf ClientTlsCertificate' {Maybe ListenerTlsFileCertificate
Maybe ListenerTlsSdsCertificate
sds :: Maybe ListenerTlsSdsCertificate
file :: Maybe ListenerTlsFileCertificate
$sel:sds:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
$sel:file:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ListenerTlsFileCertificate
file seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ListenerTlsSdsCertificate
sds

instance Data.ToJSON ClientTlsCertificate where
  toJSON :: ClientTlsCertificate -> Value
toJSON ClientTlsCertificate' {Maybe ListenerTlsFileCertificate
Maybe ListenerTlsSdsCertificate
sds :: Maybe ListenerTlsSdsCertificate
file :: Maybe ListenerTlsFileCertificate
$sel:sds:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
$sel:file:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"file" 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 ListenerTlsFileCertificate
file,
            (Key
"sds" 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 ListenerTlsSdsCertificate
sds
          ]
      )