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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Limit -> Limit -> Bool) -> (Limit -> Limit -> Bool) -> Eq Limit
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]
(Int -> ReadS Limit)
-> ReadS [Limit]
-> ReadPrec Limit
-> ReadPrec [Limit]
-> Read 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
(Int -> Limit -> ShowS)
-> (Limit -> String) -> ([Limit] -> ShowS) -> Show Limit
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. Limit -> Rep Limit x)
-> (forall x. Rep Limit x -> Limit) -> Generic Limit
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' :: Maybe Integer -> Maybe Text -> Limit
Limit'
    { $sel:max:Limit' :: Maybe Integer
max = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Limit' :: Maybe Text
type' = Maybe Text
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 :: (Maybe Integer -> f (Maybe Integer)) -> Limit -> f Limit
limit_max = (Limit -> Maybe Integer)
-> (Limit -> Maybe Integer -> Limit)
-> Lens Limit Limit (Maybe Integer) (Maybe Integer)
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 :: (Maybe Text -> f (Maybe Text)) -> Limit -> f Limit
limit_type = (Limit -> Maybe Text)
-> (Limit -> Maybe Text -> Limit)
-> Lens Limit Limit (Maybe Text) (Maybe Text)
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 Core.FromJSON Limit where
  parseJSON :: Value -> Parser Limit
parseJSON =
    String -> (Object -> Parser Limit) -> Value -> Parser Limit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Limit"
      ( \Object
x ->
          Maybe Integer -> Maybe Text -> Limit
Limit'
            (Maybe Integer -> Maybe Text -> Limit)
-> Parser (Maybe Integer) -> Parser (Maybe Text -> Limit)
forall (f :: * -> *) a b. Functor 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
"Max") Parser (Maybe Text -> Limit) -> Parser (Maybe Text) -> Parser Limit
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable Limit

instance Prelude.NFData Limit