{-# 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.MacieV2.Types.ServiceLimit
-- 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.MacieV2.Types.ServiceLimit where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.Unit
import qualified Amazonka.Prelude as Prelude

-- | Specifies a current quota for an Amazon Macie account.
--
-- /See:/ 'newServiceLimit' smart constructor.
data ServiceLimit = ServiceLimit'
  { -- | Specifies whether the account has met the quota that corresponds to the
    -- metric specified by the UsageByAccount.type field in the response.
    ServiceLimit -> Maybe Bool
isServiceLimited :: Prelude.Maybe Prelude.Bool,
    -- | The unit of measurement for the value specified by the value field.
    ServiceLimit -> Maybe Unit
unit :: Prelude.Maybe Unit,
    -- | The value for the metric specified by the UsageByAccount.type field in
    -- the response.
    ServiceLimit -> Maybe Integer
value :: Prelude.Maybe Prelude.Integer
  }
  deriving (ServiceLimit -> ServiceLimit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceLimit -> ServiceLimit -> Bool
$c/= :: ServiceLimit -> ServiceLimit -> Bool
== :: ServiceLimit -> ServiceLimit -> Bool
$c== :: ServiceLimit -> ServiceLimit -> Bool
Prelude.Eq, ReadPrec [ServiceLimit]
ReadPrec ServiceLimit
Int -> ReadS ServiceLimit
ReadS [ServiceLimit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceLimit]
$creadListPrec :: ReadPrec [ServiceLimit]
readPrec :: ReadPrec ServiceLimit
$creadPrec :: ReadPrec ServiceLimit
readList :: ReadS [ServiceLimit]
$creadList :: ReadS [ServiceLimit]
readsPrec :: Int -> ReadS ServiceLimit
$creadsPrec :: Int -> ReadS ServiceLimit
Prelude.Read, Int -> ServiceLimit -> ShowS
[ServiceLimit] -> ShowS
ServiceLimit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceLimit] -> ShowS
$cshowList :: [ServiceLimit] -> ShowS
show :: ServiceLimit -> String
$cshow :: ServiceLimit -> String
showsPrec :: Int -> ServiceLimit -> ShowS
$cshowsPrec :: Int -> ServiceLimit -> ShowS
Prelude.Show, forall x. Rep ServiceLimit x -> ServiceLimit
forall x. ServiceLimit -> Rep ServiceLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceLimit x -> ServiceLimit
$cfrom :: forall x. ServiceLimit -> Rep ServiceLimit x
Prelude.Generic)

-- |
-- Create a value of 'ServiceLimit' 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:
--
-- 'isServiceLimited', 'serviceLimit_isServiceLimited' - Specifies whether the account has met the quota that corresponds to the
-- metric specified by the UsageByAccount.type field in the response.
--
-- 'unit', 'serviceLimit_unit' - The unit of measurement for the value specified by the value field.
--
-- 'value', 'serviceLimit_value' - The value for the metric specified by the UsageByAccount.type field in
-- the response.
newServiceLimit ::
  ServiceLimit
newServiceLimit :: ServiceLimit
newServiceLimit =
  ServiceLimit'
    { $sel:isServiceLimited:ServiceLimit' :: Maybe Bool
isServiceLimited = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:ServiceLimit' :: Maybe Unit
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ServiceLimit' :: Maybe Integer
value = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the account has met the quota that corresponds to the
-- metric specified by the UsageByAccount.type field in the response.
serviceLimit_isServiceLimited :: Lens.Lens' ServiceLimit (Prelude.Maybe Prelude.Bool)
serviceLimit_isServiceLimited :: Lens' ServiceLimit (Maybe Bool)
serviceLimit_isServiceLimited = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLimit' {Maybe Bool
isServiceLimited :: Maybe Bool
$sel:isServiceLimited:ServiceLimit' :: ServiceLimit -> Maybe Bool
isServiceLimited} -> Maybe Bool
isServiceLimited) (\s :: ServiceLimit
s@ServiceLimit' {} Maybe Bool
a -> ServiceLimit
s {$sel:isServiceLimited:ServiceLimit' :: Maybe Bool
isServiceLimited = Maybe Bool
a} :: ServiceLimit)

-- | The unit of measurement for the value specified by the value field.
serviceLimit_unit :: Lens.Lens' ServiceLimit (Prelude.Maybe Unit)
serviceLimit_unit :: Lens' ServiceLimit (Maybe Unit)
serviceLimit_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLimit' {Maybe Unit
unit :: Maybe Unit
$sel:unit:ServiceLimit' :: ServiceLimit -> Maybe Unit
unit} -> Maybe Unit
unit) (\s :: ServiceLimit
s@ServiceLimit' {} Maybe Unit
a -> ServiceLimit
s {$sel:unit:ServiceLimit' :: Maybe Unit
unit = Maybe Unit
a} :: ServiceLimit)

-- | The value for the metric specified by the UsageByAccount.type field in
-- the response.
serviceLimit_value :: Lens.Lens' ServiceLimit (Prelude.Maybe Prelude.Integer)
serviceLimit_value :: Lens' ServiceLimit (Maybe Integer)
serviceLimit_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceLimit' {Maybe Integer
value :: Maybe Integer
$sel:value:ServiceLimit' :: ServiceLimit -> Maybe Integer
value} -> Maybe Integer
value) (\s :: ServiceLimit
s@ServiceLimit' {} Maybe Integer
a -> ServiceLimit
s {$sel:value:ServiceLimit' :: Maybe Integer
value = Maybe Integer
a} :: ServiceLimit)

instance Data.FromJSON ServiceLimit where
  parseJSON :: Value -> Parser ServiceLimit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceLimit"
      ( \Object
x ->
          Maybe Bool -> Maybe Unit -> Maybe Integer -> ServiceLimit
ServiceLimit'
            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
"isServiceLimited")
            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
"unit")
            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
"value")
      )

instance Prelude.Hashable ServiceLimit where
  hashWithSalt :: Int -> ServiceLimit -> Int
hashWithSalt Int
_salt ServiceLimit' {Maybe Bool
Maybe Integer
Maybe Unit
value :: Maybe Integer
unit :: Maybe Unit
isServiceLimited :: Maybe Bool
$sel:value:ServiceLimit' :: ServiceLimit -> Maybe Integer
$sel:unit:ServiceLimit' :: ServiceLimit -> Maybe Unit
$sel:isServiceLimited:ServiceLimit' :: ServiceLimit -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isServiceLimited
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Unit
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
value

instance Prelude.NFData ServiceLimit where
  rnf :: ServiceLimit -> ()
rnf ServiceLimit' {Maybe Bool
Maybe Integer
Maybe Unit
value :: Maybe Integer
unit :: Maybe Unit
isServiceLimited :: Maybe Bool
$sel:value:ServiceLimit' :: ServiceLimit -> Maybe Integer
$sel:unit:ServiceLimit' :: ServiceLimit -> Maybe Unit
$sel:isServiceLimited:ServiceLimit' :: ServiceLimit -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isServiceLimited
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Unit
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
value