{-# 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.Kafka.Types.ProvisionedThroughput
-- 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.Kafka.Types.ProvisionedThroughput 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

-- | Contains information about provisioned throughput for EBS storage
-- volumes attached to kafka broker nodes.
--
-- /See:/ 'newProvisionedThroughput' smart constructor.
data ProvisionedThroughput = ProvisionedThroughput'
  { -- | Provisioned throughput is enabled or not.
    ProvisionedThroughput -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Throughput value of the EBS volumes for the data drive on each kafka
    -- broker node in MiB per second.
    ProvisionedThroughput -> Maybe Int
volumeThroughput :: Prelude.Maybe Prelude.Int
  }
  deriving (ProvisionedThroughput -> ProvisionedThroughput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProvisionedThroughput -> ProvisionedThroughput -> Bool
$c/= :: ProvisionedThroughput -> ProvisionedThroughput -> Bool
== :: ProvisionedThroughput -> ProvisionedThroughput -> Bool
$c== :: ProvisionedThroughput -> ProvisionedThroughput -> Bool
Prelude.Eq, ReadPrec [ProvisionedThroughput]
ReadPrec ProvisionedThroughput
Int -> ReadS ProvisionedThroughput
ReadS [ProvisionedThroughput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProvisionedThroughput]
$creadListPrec :: ReadPrec [ProvisionedThroughput]
readPrec :: ReadPrec ProvisionedThroughput
$creadPrec :: ReadPrec ProvisionedThroughput
readList :: ReadS [ProvisionedThroughput]
$creadList :: ReadS [ProvisionedThroughput]
readsPrec :: Int -> ReadS ProvisionedThroughput
$creadsPrec :: Int -> ReadS ProvisionedThroughput
Prelude.Read, Int -> ProvisionedThroughput -> ShowS
[ProvisionedThroughput] -> ShowS
ProvisionedThroughput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProvisionedThroughput] -> ShowS
$cshowList :: [ProvisionedThroughput] -> ShowS
show :: ProvisionedThroughput -> String
$cshow :: ProvisionedThroughput -> String
showsPrec :: Int -> ProvisionedThroughput -> ShowS
$cshowsPrec :: Int -> ProvisionedThroughput -> ShowS
Prelude.Show, forall x. Rep ProvisionedThroughput x -> ProvisionedThroughput
forall x. ProvisionedThroughput -> Rep ProvisionedThroughput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProvisionedThroughput x -> ProvisionedThroughput
$cfrom :: forall x. ProvisionedThroughput -> Rep ProvisionedThroughput x
Prelude.Generic)

-- |
-- Create a value of 'ProvisionedThroughput' 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:
--
-- 'enabled', 'provisionedThroughput_enabled' - Provisioned throughput is enabled or not.
--
-- 'volumeThroughput', 'provisionedThroughput_volumeThroughput' - Throughput value of the EBS volumes for the data drive on each kafka
-- broker node in MiB per second.
newProvisionedThroughput ::
  ProvisionedThroughput
newProvisionedThroughput :: ProvisionedThroughput
newProvisionedThroughput =
  ProvisionedThroughput'
    { $sel:enabled:ProvisionedThroughput' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeThroughput:ProvisionedThroughput' :: Maybe Int
volumeThroughput = forall a. Maybe a
Prelude.Nothing
    }

-- | Provisioned throughput is enabled or not.
provisionedThroughput_enabled :: Lens.Lens' ProvisionedThroughput (Prelude.Maybe Prelude.Bool)
provisionedThroughput_enabled :: Lens' ProvisionedThroughput (Maybe Bool)
provisionedThroughput_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughput' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: ProvisionedThroughput
s@ProvisionedThroughput' {} Maybe Bool
a -> ProvisionedThroughput
s {$sel:enabled:ProvisionedThroughput' :: Maybe Bool
enabled = Maybe Bool
a} :: ProvisionedThroughput)

-- | Throughput value of the EBS volumes for the data drive on each kafka
-- broker node in MiB per second.
provisionedThroughput_volumeThroughput :: Lens.Lens' ProvisionedThroughput (Prelude.Maybe Prelude.Int)
provisionedThroughput_volumeThroughput :: Lens' ProvisionedThroughput (Maybe Int)
provisionedThroughput_volumeThroughput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProvisionedThroughput' {Maybe Int
volumeThroughput :: Maybe Int
$sel:volumeThroughput:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Int
volumeThroughput} -> Maybe Int
volumeThroughput) (\s :: ProvisionedThroughput
s@ProvisionedThroughput' {} Maybe Int
a -> ProvisionedThroughput
s {$sel:volumeThroughput:ProvisionedThroughput' :: Maybe Int
volumeThroughput = Maybe Int
a} :: ProvisionedThroughput)

instance Data.FromJSON ProvisionedThroughput where
  parseJSON :: Value -> Parser ProvisionedThroughput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProvisionedThroughput"
      ( \Object
x ->
          Maybe Bool -> Maybe Int -> ProvisionedThroughput
ProvisionedThroughput'
            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
"enabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"volumeThroughput")
      )

instance Prelude.Hashable ProvisionedThroughput where
  hashWithSalt :: Int -> ProvisionedThroughput -> Int
hashWithSalt Int
_salt ProvisionedThroughput' {Maybe Bool
Maybe Int
volumeThroughput :: Maybe Int
enabled :: Maybe Bool
$sel:volumeThroughput:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Int
$sel:enabled:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
volumeThroughput

instance Prelude.NFData ProvisionedThroughput where
  rnf :: ProvisionedThroughput -> ()
rnf ProvisionedThroughput' {Maybe Bool
Maybe Int
volumeThroughput :: Maybe Int
enabled :: Maybe Bool
$sel:volumeThroughput:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Int
$sel:enabled:ProvisionedThroughput' :: ProvisionedThroughput -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
volumeThroughput

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