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

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

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

-- |
-- Create a value of 'BackendDefaults' 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:
--
-- 'clientPolicy', 'backendDefaults_clientPolicy' - A reference to an object that represents a client policy.
newBackendDefaults ::
  BackendDefaults
newBackendDefaults :: BackendDefaults
newBackendDefaults =
  BackendDefaults' :: Maybe ClientPolicy -> BackendDefaults
BackendDefaults' {$sel:clientPolicy:BackendDefaults' :: Maybe ClientPolicy
clientPolicy = Maybe ClientPolicy
forall a. Maybe a
Prelude.Nothing}

-- | A reference to an object that represents a client policy.
backendDefaults_clientPolicy :: Lens.Lens' BackendDefaults (Prelude.Maybe ClientPolicy)
backendDefaults_clientPolicy :: (Maybe ClientPolicy -> f (Maybe ClientPolicy))
-> BackendDefaults -> f BackendDefaults
backendDefaults_clientPolicy = (BackendDefaults -> Maybe ClientPolicy)
-> (BackendDefaults -> Maybe ClientPolicy -> BackendDefaults)
-> Lens
     BackendDefaults
     BackendDefaults
     (Maybe ClientPolicy)
     (Maybe ClientPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackendDefaults' {Maybe ClientPolicy
clientPolicy :: Maybe ClientPolicy
$sel:clientPolicy:BackendDefaults' :: BackendDefaults -> Maybe ClientPolicy
clientPolicy} -> Maybe ClientPolicy
clientPolicy) (\s :: BackendDefaults
s@BackendDefaults' {} Maybe ClientPolicy
a -> BackendDefaults
s {$sel:clientPolicy:BackendDefaults' :: Maybe ClientPolicy
clientPolicy = Maybe ClientPolicy
a} :: BackendDefaults)

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

instance Prelude.Hashable BackendDefaults

instance Prelude.NFData BackendDefaults

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