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

import Amazonka.AppMesh.Types.ListenerTlsFileCertificate
import Amazonka.AppMesh.Types.ListenerTlsSdsCertificate
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the client\'s certificate.
--
-- /See:/ 'newClientTlsCertificate' smart constructor.
data ClientTlsCertificate = ClientTlsCertificate'
  { -- | A reference to an object that represents a client\'s TLS Secret
    -- Discovery Service certificate.
    ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
sds :: Prelude.Maybe ListenerTlsSdsCertificate,
    -- | 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
  }
  deriving (ClientTlsCertificate -> ClientTlsCertificate -> Bool
(ClientTlsCertificate -> ClientTlsCertificate -> Bool)
-> (ClientTlsCertificate -> ClientTlsCertificate -> Bool)
-> Eq ClientTlsCertificate
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]
(Int -> ReadS ClientTlsCertificate)
-> ReadS [ClientTlsCertificate]
-> ReadPrec ClientTlsCertificate
-> ReadPrec [ClientTlsCertificate]
-> Read 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
(Int -> ClientTlsCertificate -> ShowS)
-> (ClientTlsCertificate -> String)
-> ([ClientTlsCertificate] -> ShowS)
-> Show ClientTlsCertificate
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. ClientTlsCertificate -> Rep ClientTlsCertificate x)
-> (forall x. Rep ClientTlsCertificate x -> ClientTlsCertificate)
-> Generic ClientTlsCertificate
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:
--
-- 'sds', 'clientTlsCertificate_sds' - A reference to an object that represents a client\'s TLS Secret
-- Discovery Service certificate.
--
-- '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)>.
newClientTlsCertificate ::
  ClientTlsCertificate
newClientTlsCertificate :: ClientTlsCertificate
newClientTlsCertificate =
  ClientTlsCertificate' :: Maybe ListenerTlsSdsCertificate
-> Maybe ListenerTlsFileCertificate -> ClientTlsCertificate
ClientTlsCertificate'
    { $sel:sds:ClientTlsCertificate' :: Maybe ListenerTlsSdsCertificate
sds = Maybe ListenerTlsSdsCertificate
forall a. Maybe a
Prelude.Nothing,
      $sel:file:ClientTlsCertificate' :: Maybe ListenerTlsFileCertificate
file = Maybe ListenerTlsFileCertificate
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe ListenerTlsSdsCertificate
 -> f (Maybe ListenerTlsSdsCertificate))
-> ClientTlsCertificate -> f ClientTlsCertificate
clientTlsCertificate_sds = (ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate)
-> (ClientTlsCertificate
    -> Maybe ListenerTlsSdsCertificate -> ClientTlsCertificate)
-> Lens
     ClientTlsCertificate
     ClientTlsCertificate
     (Maybe ListenerTlsSdsCertificate)
     (Maybe ListenerTlsSdsCertificate)
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)

-- | 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 :: (Maybe ListenerTlsFileCertificate
 -> f (Maybe ListenerTlsFileCertificate))
-> ClientTlsCertificate -> f ClientTlsCertificate
clientTlsCertificate_file = (ClientTlsCertificate -> Maybe ListenerTlsFileCertificate)
-> (ClientTlsCertificate
    -> Maybe ListenerTlsFileCertificate -> ClientTlsCertificate)
-> Lens
     ClientTlsCertificate
     ClientTlsCertificate
     (Maybe ListenerTlsFileCertificate)
     (Maybe ListenerTlsFileCertificate)
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)

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

instance Prelude.Hashable ClientTlsCertificate

instance Prelude.NFData ClientTlsCertificate

instance Core.ToJSON ClientTlsCertificate where
  toJSON :: ClientTlsCertificate -> Value
toJSON ClientTlsCertificate' {Maybe ListenerTlsFileCertificate
Maybe ListenerTlsSdsCertificate
file :: Maybe ListenerTlsFileCertificate
sds :: Maybe ListenerTlsSdsCertificate
$sel:file:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsFileCertificate
$sel:sds:ClientTlsCertificate' :: ClientTlsCertificate -> Maybe ListenerTlsSdsCertificate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sds" Text -> ListenerTlsSdsCertificate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ListenerTlsSdsCertificate -> Pair)
-> Maybe ListenerTlsSdsCertificate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ListenerTlsSdsCertificate
sds,
            (Text
"file" Text -> ListenerTlsFileCertificate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ListenerTlsFileCertificate -> Pair)
-> Maybe ListenerTlsFileCertificate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ListenerTlsFileCertificate
file
          ]
      )