{-# 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.Shield.Types.Limit
-- 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.Shield.Types.Limit 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

-- | Specifies how many protections of a given type you can create.
--
-- /See:/ 'newLimit' smart constructor.
data Limit = Limit'
  { -- | The maximum number of protections that can be created for the specified
    -- @Type@.
    Limit -> Maybe Integer
max :: Prelude.Maybe Prelude.Integer,
    -- | The type of protection.
    Limit -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Limit -> Limit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Limit -> Limit -> Bool
$c/= :: Limit -> Limit -> Bool
== :: Limit -> Limit -> Bool
$c== :: Limit -> Limit -> Bool
Prelude.Eq, ReadPrec [Limit]
ReadPrec Limit
Int -> ReadS Limit
ReadS [Limit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Limit]
$creadListPrec :: ReadPrec [Limit]
readPrec :: ReadPrec Limit
$creadPrec :: ReadPrec Limit
readList :: ReadS [Limit]
$creadList :: ReadS [Limit]
readsPrec :: Int -> ReadS Limit
$creadsPrec :: Int -> ReadS Limit
Prelude.Read, Int -> Limit -> ShowS
[Limit] -> ShowS
Limit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Limit] -> ShowS
$cshowList :: [Limit] -> ShowS
show :: Limit -> String
$cshow :: Limit -> String
showsPrec :: Int -> Limit -> ShowS
$cshowsPrec :: Int -> Limit -> ShowS
Prelude.Show, forall x. Rep Limit x -> Limit
forall x. Limit -> Rep Limit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Limit x -> Limit
$cfrom :: forall x. Limit -> Rep Limit x
Prelude.Generic)

-- |
-- Create a value of 'Limit' 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:
--
-- 'max', 'limit_max' - The maximum number of protections that can be created for the specified
-- @Type@.
--
-- 'type'', 'limit_type' - The type of protection.
newLimit ::
  Limit
newLimit :: Limit
newLimit =
  Limit'
    { $sel:max:Limit' :: Maybe Integer
max = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Limit' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of protections that can be created for the specified
-- @Type@.
limit_max :: Lens.Lens' Limit (Prelude.Maybe Prelude.Integer)
limit_max :: Lens' Limit (Maybe Integer)
limit_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Limit' {Maybe Integer
max :: Maybe Integer
$sel:max:Limit' :: Limit -> Maybe Integer
max} -> Maybe Integer
max) (\s :: Limit
s@Limit' {} Maybe Integer
a -> Limit
s {$sel:max:Limit' :: Maybe Integer
max = Maybe Integer
a} :: Limit)

-- | The type of protection.
limit_type :: Lens.Lens' Limit (Prelude.Maybe Prelude.Text)
limit_type :: Lens' Limit (Maybe Text)
limit_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Limit' {Maybe Text
type' :: Maybe Text
$sel:type':Limit' :: Limit -> Maybe Text
type'} -> Maybe Text
type') (\s :: Limit
s@Limit' {} Maybe Text
a -> Limit
s {$sel:type':Limit' :: Maybe Text
type' = Maybe Text
a} :: Limit)

instance Data.FromJSON Limit where
  parseJSON :: Value -> Parser Limit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Limit"
      ( \Object
x ->
          Maybe Integer -> Maybe Text -> Limit
Limit'
            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
"Max")
            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
"Type")
      )

instance Prelude.Hashable Limit where
  hashWithSalt :: Int -> Limit -> Int
hashWithSalt Int
_salt Limit' {Maybe Integer
Maybe Text
type' :: Maybe Text
max :: Maybe Integer
$sel:type':Limit' :: Limit -> Maybe Text
$sel:max:Limit' :: Limit -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Limit where
  rnf :: Limit -> ()
rnf Limit' {Maybe Integer
Maybe Text
type' :: Maybe Text
max :: Maybe Integer
$sel:type':Limit' :: Limit -> Maybe Text
$sel:max:Limit' :: Limit -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
max seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'