{-# 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.ElasticSearch.Types.ZoneAwarenessConfig
-- 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.ElasticSearch.Types.ZoneAwarenessConfig 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

-- | Specifies the zone awareness configuration for the domain cluster, such
-- as the number of availability zones.
--
-- /See:/ 'newZoneAwarenessConfig' smart constructor.
data ZoneAwarenessConfig = ZoneAwarenessConfig'
  { -- | An integer value to indicate the number of availability zones for a
    -- domain when zone awareness is enabled. This should be equal to number of
    -- subnets if VPC endpoints is enabled
    ZoneAwarenessConfig -> Maybe Int
availabilityZoneCount :: Prelude.Maybe Prelude.Int
  }
  deriving (ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool
$c/= :: ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool
== :: ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool
$c== :: ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool
Prelude.Eq, ReadPrec [ZoneAwarenessConfig]
ReadPrec ZoneAwarenessConfig
Int -> ReadS ZoneAwarenessConfig
ReadS [ZoneAwarenessConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ZoneAwarenessConfig]
$creadListPrec :: ReadPrec [ZoneAwarenessConfig]
readPrec :: ReadPrec ZoneAwarenessConfig
$creadPrec :: ReadPrec ZoneAwarenessConfig
readList :: ReadS [ZoneAwarenessConfig]
$creadList :: ReadS [ZoneAwarenessConfig]
readsPrec :: Int -> ReadS ZoneAwarenessConfig
$creadsPrec :: Int -> ReadS ZoneAwarenessConfig
Prelude.Read, Int -> ZoneAwarenessConfig -> ShowS
[ZoneAwarenessConfig] -> ShowS
ZoneAwarenessConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZoneAwarenessConfig] -> ShowS
$cshowList :: [ZoneAwarenessConfig] -> ShowS
show :: ZoneAwarenessConfig -> String
$cshow :: ZoneAwarenessConfig -> String
showsPrec :: Int -> ZoneAwarenessConfig -> ShowS
$cshowsPrec :: Int -> ZoneAwarenessConfig -> ShowS
Prelude.Show, forall x. Rep ZoneAwarenessConfig x -> ZoneAwarenessConfig
forall x. ZoneAwarenessConfig -> Rep ZoneAwarenessConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ZoneAwarenessConfig x -> ZoneAwarenessConfig
$cfrom :: forall x. ZoneAwarenessConfig -> Rep ZoneAwarenessConfig x
Prelude.Generic)

-- |
-- Create a value of 'ZoneAwarenessConfig' 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:
--
-- 'availabilityZoneCount', 'zoneAwarenessConfig_availabilityZoneCount' - An integer value to indicate the number of availability zones for a
-- domain when zone awareness is enabled. This should be equal to number of
-- subnets if VPC endpoints is enabled
newZoneAwarenessConfig ::
  ZoneAwarenessConfig
newZoneAwarenessConfig :: ZoneAwarenessConfig
newZoneAwarenessConfig =
  ZoneAwarenessConfig'
    { $sel:availabilityZoneCount:ZoneAwarenessConfig' :: Maybe Int
availabilityZoneCount =
        forall a. Maybe a
Prelude.Nothing
    }

-- | An integer value to indicate the number of availability zones for a
-- domain when zone awareness is enabled. This should be equal to number of
-- subnets if VPC endpoints is enabled
zoneAwarenessConfig_availabilityZoneCount :: Lens.Lens' ZoneAwarenessConfig (Prelude.Maybe Prelude.Int)
zoneAwarenessConfig_availabilityZoneCount :: Lens' ZoneAwarenessConfig (Maybe Int)
zoneAwarenessConfig_availabilityZoneCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZoneAwarenessConfig' {Maybe Int
availabilityZoneCount :: Maybe Int
$sel:availabilityZoneCount:ZoneAwarenessConfig' :: ZoneAwarenessConfig -> Maybe Int
availabilityZoneCount} -> Maybe Int
availabilityZoneCount) (\s :: ZoneAwarenessConfig
s@ZoneAwarenessConfig' {} Maybe Int
a -> ZoneAwarenessConfig
s {$sel:availabilityZoneCount:ZoneAwarenessConfig' :: Maybe Int
availabilityZoneCount = Maybe Int
a} :: ZoneAwarenessConfig)

instance Data.FromJSON ZoneAwarenessConfig where
  parseJSON :: Value -> Parser ZoneAwarenessConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ZoneAwarenessConfig"
      ( \Object
x ->
          Maybe Int -> ZoneAwarenessConfig
ZoneAwarenessConfig'
            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
"AvailabilityZoneCount")
      )

instance Prelude.Hashable ZoneAwarenessConfig where
  hashWithSalt :: Int -> ZoneAwarenessConfig -> Int
hashWithSalt Int
_salt ZoneAwarenessConfig' {Maybe Int
availabilityZoneCount :: Maybe Int
$sel:availabilityZoneCount:ZoneAwarenessConfig' :: ZoneAwarenessConfig -> Maybe Int
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
availabilityZoneCount

instance Prelude.NFData ZoneAwarenessConfig where
  rnf :: ZoneAwarenessConfig -> ()
rnf ZoneAwarenessConfig' {Maybe Int
availabilityZoneCount :: Maybe Int
$sel:availabilityZoneCount:ZoneAwarenessConfig' :: ZoneAwarenessConfig -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
availabilityZoneCount

instance Data.ToJSON ZoneAwarenessConfig where
  toJSON :: ZoneAwarenessConfig -> Value
toJSON ZoneAwarenessConfig' {Maybe Int
availabilityZoneCount :: Maybe Int
$sel:availabilityZoneCount:ZoneAwarenessConfig' :: ZoneAwarenessConfig -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AvailabilityZoneCount" 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 Int
availabilityZoneCount
          ]
      )