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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.AdditionalLimit
import Amazonka.OpenSearch.Types.InstanceLimits
import Amazonka.OpenSearch.Types.StorageType
import qualified Amazonka.Prelude as Prelude

-- | Limits for a given InstanceType and for each of its roles.
-- Limits contains the following: @ StorageTypes @, @ InstanceLimits @, and
-- @ AdditionalLimits @
--
-- /See:/ 'newLimits' smart constructor.
data Limits = Limits'
  { Limits -> Maybe InstanceLimits
instanceLimits :: Prelude.Maybe InstanceLimits,
    -- | List of additional limits that are specific to a given InstanceType and
    -- for each of its @ InstanceRole @ .
    Limits -> Maybe [AdditionalLimit]
additionalLimits :: Prelude.Maybe [AdditionalLimit],
    -- | Storage-related types and attributes that are available for a given
    -- InstanceType.
    Limits -> Maybe [StorageType]
storageTypes :: Prelude.Maybe [StorageType]
  }
  deriving (Limits -> Limits -> Bool
(Limits -> Limits -> Bool)
-> (Limits -> Limits -> Bool) -> Eq Limits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Limits -> Limits -> Bool
$c/= :: Limits -> Limits -> Bool
== :: Limits -> Limits -> Bool
$c== :: Limits -> Limits -> Bool
Prelude.Eq, ReadPrec [Limits]
ReadPrec Limits
Int -> ReadS Limits
ReadS [Limits]
(Int -> ReadS Limits)
-> ReadS [Limits]
-> ReadPrec Limits
-> ReadPrec [Limits]
-> Read Limits
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Limits]
$creadListPrec :: ReadPrec [Limits]
readPrec :: ReadPrec Limits
$creadPrec :: ReadPrec Limits
readList :: ReadS [Limits]
$creadList :: ReadS [Limits]
readsPrec :: Int -> ReadS Limits
$creadsPrec :: Int -> ReadS Limits
Prelude.Read, Int -> Limits -> ShowS
[Limits] -> ShowS
Limits -> String
(Int -> Limits -> ShowS)
-> (Limits -> String) -> ([Limits] -> ShowS) -> Show Limits
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Limits] -> ShowS
$cshowList :: [Limits] -> ShowS
show :: Limits -> String
$cshow :: Limits -> String
showsPrec :: Int -> Limits -> ShowS
$cshowsPrec :: Int -> Limits -> ShowS
Prelude.Show, (forall x. Limits -> Rep Limits x)
-> (forall x. Rep Limits x -> Limits) -> Generic Limits
forall x. Rep Limits x -> Limits
forall x. Limits -> Rep Limits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Limits x -> Limits
$cfrom :: forall x. Limits -> Rep Limits x
Prelude.Generic)

-- |
-- Create a value of 'Limits' 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:
--
-- 'instanceLimits', 'limits_instanceLimits' - Undocumented member.
--
-- 'additionalLimits', 'limits_additionalLimits' - List of additional limits that are specific to a given InstanceType and
-- for each of its @ InstanceRole @ .
--
-- 'storageTypes', 'limits_storageTypes' - Storage-related types and attributes that are available for a given
-- InstanceType.
newLimits ::
  Limits
newLimits :: Limits
newLimits =
  Limits' :: Maybe InstanceLimits
-> Maybe [AdditionalLimit] -> Maybe [StorageType] -> Limits
Limits'
    { $sel:instanceLimits:Limits' :: Maybe InstanceLimits
instanceLimits = Maybe InstanceLimits
forall a. Maybe a
Prelude.Nothing,
      $sel:additionalLimits:Limits' :: Maybe [AdditionalLimit]
additionalLimits = Maybe [AdditionalLimit]
forall a. Maybe a
Prelude.Nothing,
      $sel:storageTypes:Limits' :: Maybe [StorageType]
storageTypes = Maybe [StorageType]
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
limits_instanceLimits :: Lens.Lens' Limits (Prelude.Maybe InstanceLimits)
limits_instanceLimits :: (Maybe InstanceLimits -> f (Maybe InstanceLimits))
-> Limits -> f Limits
limits_instanceLimits = (Limits -> Maybe InstanceLimits)
-> (Limits -> Maybe InstanceLimits -> Limits)
-> Lens Limits Limits (Maybe InstanceLimits) (Maybe InstanceLimits)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Limits' {Maybe InstanceLimits
instanceLimits :: Maybe InstanceLimits
$sel:instanceLimits:Limits' :: Limits -> Maybe InstanceLimits
instanceLimits} -> Maybe InstanceLimits
instanceLimits) (\s :: Limits
s@Limits' {} Maybe InstanceLimits
a -> Limits
s {$sel:instanceLimits:Limits' :: Maybe InstanceLimits
instanceLimits = Maybe InstanceLimits
a} :: Limits)

-- | List of additional limits that are specific to a given InstanceType and
-- for each of its @ InstanceRole @ .
limits_additionalLimits :: Lens.Lens' Limits (Prelude.Maybe [AdditionalLimit])
limits_additionalLimits :: (Maybe [AdditionalLimit] -> f (Maybe [AdditionalLimit]))
-> Limits -> f Limits
limits_additionalLimits = (Limits -> Maybe [AdditionalLimit])
-> (Limits -> Maybe [AdditionalLimit] -> Limits)
-> Lens
     Limits Limits (Maybe [AdditionalLimit]) (Maybe [AdditionalLimit])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Limits' {Maybe [AdditionalLimit]
additionalLimits :: Maybe [AdditionalLimit]
$sel:additionalLimits:Limits' :: Limits -> Maybe [AdditionalLimit]
additionalLimits} -> Maybe [AdditionalLimit]
additionalLimits) (\s :: Limits
s@Limits' {} Maybe [AdditionalLimit]
a -> Limits
s {$sel:additionalLimits:Limits' :: Maybe [AdditionalLimit]
additionalLimits = Maybe [AdditionalLimit]
a} :: Limits) ((Maybe [AdditionalLimit] -> f (Maybe [AdditionalLimit]))
 -> Limits -> f Limits)
-> ((Maybe [AdditionalLimit] -> f (Maybe [AdditionalLimit]))
    -> Maybe [AdditionalLimit] -> f (Maybe [AdditionalLimit]))
-> (Maybe [AdditionalLimit] -> f (Maybe [AdditionalLimit]))
-> Limits
-> f Limits
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AdditionalLimit]
  [AdditionalLimit]
  [AdditionalLimit]
  [AdditionalLimit]
-> Iso
     (Maybe [AdditionalLimit])
     (Maybe [AdditionalLimit])
     (Maybe [AdditionalLimit])
     (Maybe [AdditionalLimit])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AdditionalLimit]
  [AdditionalLimit]
  [AdditionalLimit]
  [AdditionalLimit]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Storage-related types and attributes that are available for a given
-- InstanceType.
limits_storageTypes :: Lens.Lens' Limits (Prelude.Maybe [StorageType])
limits_storageTypes :: (Maybe [StorageType] -> f (Maybe [StorageType]))
-> Limits -> f Limits
limits_storageTypes = (Limits -> Maybe [StorageType])
-> (Limits -> Maybe [StorageType] -> Limits)
-> Lens Limits Limits (Maybe [StorageType]) (Maybe [StorageType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Limits' {Maybe [StorageType]
storageTypes :: Maybe [StorageType]
$sel:storageTypes:Limits' :: Limits -> Maybe [StorageType]
storageTypes} -> Maybe [StorageType]
storageTypes) (\s :: Limits
s@Limits' {} Maybe [StorageType]
a -> Limits
s {$sel:storageTypes:Limits' :: Maybe [StorageType]
storageTypes = Maybe [StorageType]
a} :: Limits) ((Maybe [StorageType] -> f (Maybe [StorageType]))
 -> Limits -> f Limits)
-> ((Maybe [StorageType] -> f (Maybe [StorageType]))
    -> Maybe [StorageType] -> f (Maybe [StorageType]))
-> (Maybe [StorageType] -> f (Maybe [StorageType]))
-> Limits
-> f Limits
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [StorageType] [StorageType] [StorageType] [StorageType]
-> Iso
     (Maybe [StorageType])
     (Maybe [StorageType])
     (Maybe [StorageType])
     (Maybe [StorageType])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [StorageType] [StorageType] [StorageType] [StorageType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Limits where
  parseJSON :: Value -> Parser Limits
parseJSON =
    String -> (Object -> Parser Limits) -> Value -> Parser Limits
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Limits"
      ( \Object
x ->
          Maybe InstanceLimits
-> Maybe [AdditionalLimit] -> Maybe [StorageType] -> Limits
Limits'
            (Maybe InstanceLimits
 -> Maybe [AdditionalLimit] -> Maybe [StorageType] -> Limits)
-> Parser (Maybe InstanceLimits)
-> Parser
     (Maybe [AdditionalLimit] -> Maybe [StorageType] -> Limits)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InstanceLimits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceLimits")
            Parser (Maybe [AdditionalLimit] -> Maybe [StorageType] -> Limits)
-> Parser (Maybe [AdditionalLimit])
-> Parser (Maybe [StorageType] -> Limits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [AdditionalLimit]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AdditionalLimits"
                            Parser (Maybe (Maybe [AdditionalLimit]))
-> Maybe [AdditionalLimit] -> Parser (Maybe [AdditionalLimit])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AdditionalLimit]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [StorageType] -> Limits)
-> Parser (Maybe [StorageType]) -> Parser Limits
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [StorageType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StorageTypes" Parser (Maybe (Maybe [StorageType]))
-> Maybe [StorageType] -> Parser (Maybe [StorageType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [StorageType]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Limits

instance Prelude.NFData Limits