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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value for the metric specified by the UsageByAccount.type field in
    -- the response.
    ServiceLimit -> Maybe Integer
value :: Prelude.Maybe Prelude.Integer,
    -- | The unit of measurement for the value specified by the value field.
    ServiceLimit -> Maybe Unit
unit :: Prelude.Maybe Unit
  }
  deriving (ServiceLimit -> ServiceLimit -> Bool
(ServiceLimit -> ServiceLimit -> Bool)
-> (ServiceLimit -> ServiceLimit -> Bool) -> Eq ServiceLimit
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]
(Int -> ReadS ServiceLimit)
-> ReadS [ServiceLimit]
-> ReadPrec ServiceLimit
-> ReadPrec [ServiceLimit]
-> Read 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
(Int -> ServiceLimit -> ShowS)
-> (ServiceLimit -> String)
-> ([ServiceLimit] -> ShowS)
-> Show ServiceLimit
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. ServiceLimit -> Rep ServiceLimit x)
-> (forall x. Rep ServiceLimit x -> ServiceLimit)
-> Generic ServiceLimit
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.
--
-- 'value', 'serviceLimit_value' - The value for 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.
newServiceLimit ::
  ServiceLimit
newServiceLimit :: ServiceLimit
newServiceLimit =
  ServiceLimit' :: Maybe Bool -> Maybe Integer -> Maybe Unit -> ServiceLimit
ServiceLimit'
    { $sel:isServiceLimited:ServiceLimit' :: Maybe Bool
isServiceLimited = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:value:ServiceLimit' :: Maybe Integer
value = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:ServiceLimit' :: Maybe Unit
unit = Maybe Unit
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 :: (Maybe Bool -> f (Maybe Bool)) -> ServiceLimit -> f ServiceLimit
serviceLimit_isServiceLimited = (ServiceLimit -> Maybe Bool)
-> (ServiceLimit -> Maybe Bool -> ServiceLimit)
-> Lens ServiceLimit ServiceLimit (Maybe Bool) (Maybe Bool)
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 value for the metric specified by the UsageByAccount.type field in
-- the response.
serviceLimit_value :: Lens.Lens' ServiceLimit (Prelude.Maybe Prelude.Integer)
serviceLimit_value :: (Maybe Integer -> f (Maybe Integer))
-> ServiceLimit -> f ServiceLimit
serviceLimit_value = (ServiceLimit -> Maybe Integer)
-> (ServiceLimit -> Maybe Integer -> ServiceLimit)
-> Lens ServiceLimit ServiceLimit (Maybe Integer) (Maybe Integer)
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)

-- | The unit of measurement for the value specified by the value field.
serviceLimit_unit :: Lens.Lens' ServiceLimit (Prelude.Maybe Unit)
serviceLimit_unit :: (Maybe Unit -> f (Maybe Unit)) -> ServiceLimit -> f ServiceLimit
serviceLimit_unit = (ServiceLimit -> Maybe Unit)
-> (ServiceLimit -> Maybe Unit -> ServiceLimit)
-> Lens ServiceLimit ServiceLimit (Maybe Unit) (Maybe 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)

instance Core.FromJSON ServiceLimit where
  parseJSON :: Value -> Parser ServiceLimit
parseJSON =
    String
-> (Object -> Parser ServiceLimit) -> Value -> Parser ServiceLimit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceLimit"
      ( \Object
x ->
          Maybe Bool -> Maybe Integer -> Maybe Unit -> ServiceLimit
ServiceLimit'
            (Maybe Bool -> Maybe Integer -> Maybe Unit -> ServiceLimit)
-> Parser (Maybe Bool)
-> Parser (Maybe Integer -> Maybe Unit -> ServiceLimit)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isServiceLimited")
            Parser (Maybe Integer -> Maybe Unit -> ServiceLimit)
-> Parser (Maybe Integer) -> Parser (Maybe Unit -> ServiceLimit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"value")
            Parser (Maybe Unit -> ServiceLimit)
-> Parser (Maybe Unit) -> Parser ServiceLimit
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Unit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unit")
      )

instance Prelude.Hashable ServiceLimit

instance Prelude.NFData ServiceLimit