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

import Amazonka.AppMesh.Types.ClientPolicyTls
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a client policy.
--
-- /See:/ 'newClientPolicy' smart constructor.
data ClientPolicy = ClientPolicy'
  { -- | A reference to an object that represents a Transport Layer Security
    -- (TLS) client policy.
    ClientPolicy -> Maybe ClientPolicyTls
tls :: Prelude.Maybe ClientPolicyTls
  }
  deriving (ClientPolicy -> ClientPolicy -> Bool
(ClientPolicy -> ClientPolicy -> Bool)
-> (ClientPolicy -> ClientPolicy -> Bool) -> Eq ClientPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientPolicy -> ClientPolicy -> Bool
$c/= :: ClientPolicy -> ClientPolicy -> Bool
== :: ClientPolicy -> ClientPolicy -> Bool
$c== :: ClientPolicy -> ClientPolicy -> Bool
Prelude.Eq, ReadPrec [ClientPolicy]
ReadPrec ClientPolicy
Int -> ReadS ClientPolicy
ReadS [ClientPolicy]
(Int -> ReadS ClientPolicy)
-> ReadS [ClientPolicy]
-> ReadPrec ClientPolicy
-> ReadPrec [ClientPolicy]
-> Read ClientPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClientPolicy]
$creadListPrec :: ReadPrec [ClientPolicy]
readPrec :: ReadPrec ClientPolicy
$creadPrec :: ReadPrec ClientPolicy
readList :: ReadS [ClientPolicy]
$creadList :: ReadS [ClientPolicy]
readsPrec :: Int -> ReadS ClientPolicy
$creadsPrec :: Int -> ReadS ClientPolicy
Prelude.Read, Int -> ClientPolicy -> ShowS
[ClientPolicy] -> ShowS
ClientPolicy -> String
(Int -> ClientPolicy -> ShowS)
-> (ClientPolicy -> String)
-> ([ClientPolicy] -> ShowS)
-> Show ClientPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientPolicy] -> ShowS
$cshowList :: [ClientPolicy] -> ShowS
show :: ClientPolicy -> String
$cshow :: ClientPolicy -> String
showsPrec :: Int -> ClientPolicy -> ShowS
$cshowsPrec :: Int -> ClientPolicy -> ShowS
Prelude.Show, (forall x. ClientPolicy -> Rep ClientPolicy x)
-> (forall x. Rep ClientPolicy x -> ClientPolicy)
-> Generic ClientPolicy
forall x. Rep ClientPolicy x -> ClientPolicy
forall x. ClientPolicy -> Rep ClientPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClientPolicy x -> ClientPolicy
$cfrom :: forall x. ClientPolicy -> Rep ClientPolicy x
Prelude.Generic)

-- |
-- Create a value of 'ClientPolicy' 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:
--
-- 'tls', 'clientPolicy_tls' - A reference to an object that represents a Transport Layer Security
-- (TLS) client policy.
newClientPolicy ::
  ClientPolicy
newClientPolicy :: ClientPolicy
newClientPolicy =
  ClientPolicy' :: Maybe ClientPolicyTls -> ClientPolicy
ClientPolicy' {$sel:tls:ClientPolicy' :: Maybe ClientPolicyTls
tls = Maybe ClientPolicyTls
forall a. Maybe a
Prelude.Nothing}

-- | A reference to an object that represents a Transport Layer Security
-- (TLS) client policy.
clientPolicy_tls :: Lens.Lens' ClientPolicy (Prelude.Maybe ClientPolicyTls)
clientPolicy_tls :: (Maybe ClientPolicyTls -> f (Maybe ClientPolicyTls))
-> ClientPolicy -> f ClientPolicy
clientPolicy_tls = (ClientPolicy -> Maybe ClientPolicyTls)
-> (ClientPolicy -> Maybe ClientPolicyTls -> ClientPolicy)
-> Lens
     ClientPolicy
     ClientPolicy
     (Maybe ClientPolicyTls)
     (Maybe ClientPolicyTls)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientPolicy' {Maybe ClientPolicyTls
tls :: Maybe ClientPolicyTls
$sel:tls:ClientPolicy' :: ClientPolicy -> Maybe ClientPolicyTls
tls} -> Maybe ClientPolicyTls
tls) (\s :: ClientPolicy
s@ClientPolicy' {} Maybe ClientPolicyTls
a -> ClientPolicy
s {$sel:tls:ClientPolicy' :: Maybe ClientPolicyTls
tls = Maybe ClientPolicyTls
a} :: ClientPolicy)

instance Core.FromJSON ClientPolicy where
  parseJSON :: Value -> Parser ClientPolicy
parseJSON =
    String
-> (Object -> Parser ClientPolicy) -> Value -> Parser ClientPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ClientPolicy"
      (\Object
x -> Maybe ClientPolicyTls -> ClientPolicy
ClientPolicy' (Maybe ClientPolicyTls -> ClientPolicy)
-> Parser (Maybe ClientPolicyTls) -> Parser ClientPolicy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ClientPolicyTls)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tls"))

instance Prelude.Hashable ClientPolicy

instance Prelude.NFData ClientPolicy

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