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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | 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
(ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool)
-> (ZoneAwarenessConfig -> ZoneAwarenessConfig -> Bool)
-> Eq ZoneAwarenessConfig
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]
(Int -> ReadS ZoneAwarenessConfig)
-> ReadS [ZoneAwarenessConfig]
-> ReadPrec ZoneAwarenessConfig
-> ReadPrec [ZoneAwarenessConfig]
-> Read 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
(Int -> ZoneAwarenessConfig -> ShowS)
-> (ZoneAwarenessConfig -> String)
-> ([ZoneAwarenessConfig] -> ShowS)
-> Show ZoneAwarenessConfig
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. ZoneAwarenessConfig -> Rep ZoneAwarenessConfig x)
-> (forall x. Rep ZoneAwarenessConfig x -> ZoneAwarenessConfig)
-> Generic ZoneAwarenessConfig
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' :: Maybe Int -> ZoneAwarenessConfig
ZoneAwarenessConfig'
    { $sel:availabilityZoneCount:ZoneAwarenessConfig' :: Maybe Int
availabilityZoneCount =
        Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> ZoneAwarenessConfig -> f ZoneAwarenessConfig
zoneAwarenessConfig_availabilityZoneCount = (ZoneAwarenessConfig -> Maybe Int)
-> (ZoneAwarenessConfig -> Maybe Int -> ZoneAwarenessConfig)
-> Lens
     ZoneAwarenessConfig ZoneAwarenessConfig (Maybe Int) (Maybe Int)
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 Core.FromJSON ZoneAwarenessConfig where
  parseJSON :: Value -> Parser ZoneAwarenessConfig
parseJSON =
    String
-> (Object -> Parser ZoneAwarenessConfig)
-> Value
-> Parser ZoneAwarenessConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ZoneAwarenessConfig"
      ( \Object
x ->
          Maybe Int -> ZoneAwarenessConfig
ZoneAwarenessConfig'
            (Maybe Int -> ZoneAwarenessConfig)
-> Parser (Maybe Int) -> Parser ZoneAwarenessConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AvailabilityZoneCount")
      )

instance Prelude.Hashable ZoneAwarenessConfig

instance Prelude.NFData ZoneAwarenessConfig

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