{-# 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.Protection
-- 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.Protection 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
import Amazonka.Shield.Types.ApplicationLayerAutomaticResponseConfiguration

-- | An object that represents a resource that is under DDoS protection.
--
-- /See:/ 'newProtection' smart constructor.
data Protection = Protection'
  { -- | The automatic application layer DDoS mitigation settings for the
    -- protection. This configuration determines whether Shield Advanced
    -- automatically manages rules in the web ACL in order to respond to
    -- application layer events that Shield Advanced determines to be DDoS
    -- attacks.
    Protection -> Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration :: Prelude.Maybe ApplicationLayerAutomaticResponseConfiguration,
    -- | The unique identifier (ID) for the Route 53 health check that\'s
    -- associated with the protection.
    Protection -> Maybe [Text]
healthCheckIds :: Prelude.Maybe [Prelude.Text],
    -- | The unique identifier (ID) of the protection.
    Protection -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name of the protection. For example, @My CloudFront distributions@.
    Protection -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ARN (Amazon Resource Name) of the protection.
    Protection -> Maybe Text
protectionArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN (Amazon Resource Name) of the Amazon Web Services resource that
    -- is protected.
    Protection -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Protection -> Protection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Protection -> Protection -> Bool
$c/= :: Protection -> Protection -> Bool
== :: Protection -> Protection -> Bool
$c== :: Protection -> Protection -> Bool
Prelude.Eq, ReadPrec [Protection]
ReadPrec Protection
Int -> ReadS Protection
ReadS [Protection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Protection]
$creadListPrec :: ReadPrec [Protection]
readPrec :: ReadPrec Protection
$creadPrec :: ReadPrec Protection
readList :: ReadS [Protection]
$creadList :: ReadS [Protection]
readsPrec :: Int -> ReadS Protection
$creadsPrec :: Int -> ReadS Protection
Prelude.Read, Int -> Protection -> ShowS
[Protection] -> ShowS
Protection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Protection] -> ShowS
$cshowList :: [Protection] -> ShowS
show :: Protection -> String
$cshow :: Protection -> String
showsPrec :: Int -> Protection -> ShowS
$cshowsPrec :: Int -> Protection -> ShowS
Prelude.Show, forall x. Rep Protection x -> Protection
forall x. Protection -> Rep Protection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Protection x -> Protection
$cfrom :: forall x. Protection -> Rep Protection x
Prelude.Generic)

-- |
-- Create a value of 'Protection' 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:
--
-- 'applicationLayerAutomaticResponseConfiguration', 'protection_applicationLayerAutomaticResponseConfiguration' - The automatic application layer DDoS mitigation settings for the
-- protection. This configuration determines whether Shield Advanced
-- automatically manages rules in the web ACL in order to respond to
-- application layer events that Shield Advanced determines to be DDoS
-- attacks.
--
-- 'healthCheckIds', 'protection_healthCheckIds' - The unique identifier (ID) for the Route 53 health check that\'s
-- associated with the protection.
--
-- 'id', 'protection_id' - The unique identifier (ID) of the protection.
--
-- 'name', 'protection_name' - The name of the protection. For example, @My CloudFront distributions@.
--
-- 'protectionArn', 'protection_protectionArn' - The ARN (Amazon Resource Name) of the protection.
--
-- 'resourceArn', 'protection_resourceArn' - The ARN (Amazon Resource Name) of the Amazon Web Services resource that
-- is protected.
newProtection ::
  Protection
newProtection :: Protection
newProtection =
  Protection'
    { $sel:applicationLayerAutomaticResponseConfiguration:Protection' :: Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheckIds:Protection' :: Maybe [Text]
healthCheckIds = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Protection' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Protection' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:protectionArn:Protection' :: Maybe Text
protectionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:Protection' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The automatic application layer DDoS mitigation settings for the
-- protection. This configuration determines whether Shield Advanced
-- automatically manages rules in the web ACL in order to respond to
-- application layer events that Shield Advanced determines to be DDoS
-- attacks.
protection_applicationLayerAutomaticResponseConfiguration :: Lens.Lens' Protection (Prelude.Maybe ApplicationLayerAutomaticResponseConfiguration)
protection_applicationLayerAutomaticResponseConfiguration :: Lens'
  Protection (Maybe ApplicationLayerAutomaticResponseConfiguration)
protection_applicationLayerAutomaticResponseConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration :: Maybe ApplicationLayerAutomaticResponseConfiguration
$sel:applicationLayerAutomaticResponseConfiguration:Protection' :: Protection -> Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration} -> Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration) (\s :: Protection
s@Protection' {} Maybe ApplicationLayerAutomaticResponseConfiguration
a -> Protection
s {$sel:applicationLayerAutomaticResponseConfiguration:Protection' :: Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration = Maybe ApplicationLayerAutomaticResponseConfiguration
a} :: Protection)

-- | The unique identifier (ID) for the Route 53 health check that\'s
-- associated with the protection.
protection_healthCheckIds :: Lens.Lens' Protection (Prelude.Maybe [Prelude.Text])
protection_healthCheckIds :: Lens' Protection (Maybe [Text])
protection_healthCheckIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe [Text]
healthCheckIds :: Maybe [Text]
$sel:healthCheckIds:Protection' :: Protection -> Maybe [Text]
healthCheckIds} -> Maybe [Text]
healthCheckIds) (\s :: Protection
s@Protection' {} Maybe [Text]
a -> Protection
s {$sel:healthCheckIds:Protection' :: Maybe [Text]
healthCheckIds = Maybe [Text]
a} :: Protection) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier (ID) of the protection.
protection_id :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_id :: Lens' Protection (Maybe Text)
protection_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe Text
id :: Maybe Text
$sel:id:Protection' :: Protection -> Maybe Text
id} -> Maybe Text
id) (\s :: Protection
s@Protection' {} Maybe Text
a -> Protection
s {$sel:id:Protection' :: Maybe Text
id = Maybe Text
a} :: Protection)

-- | The name of the protection. For example, @My CloudFront distributions@.
protection_name :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_name :: Lens' Protection (Maybe Text)
protection_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe Text
name :: Maybe Text
$sel:name:Protection' :: Protection -> Maybe Text
name} -> Maybe Text
name) (\s :: Protection
s@Protection' {} Maybe Text
a -> Protection
s {$sel:name:Protection' :: Maybe Text
name = Maybe Text
a} :: Protection)

-- | The ARN (Amazon Resource Name) of the protection.
protection_protectionArn :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_protectionArn :: Lens' Protection (Maybe Text)
protection_protectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe Text
protectionArn :: Maybe Text
$sel:protectionArn:Protection' :: Protection -> Maybe Text
protectionArn} -> Maybe Text
protectionArn) (\s :: Protection
s@Protection' {} Maybe Text
a -> Protection
s {$sel:protectionArn:Protection' :: Maybe Text
protectionArn = Maybe Text
a} :: Protection)

-- | The ARN (Amazon Resource Name) of the Amazon Web Services resource that
-- is protected.
protection_resourceArn :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_resourceArn :: Lens' Protection (Maybe Text)
protection_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Protection' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:Protection' :: Protection -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: Protection
s@Protection' {} Maybe Text
a -> Protection
s {$sel:resourceArn:Protection' :: Maybe Text
resourceArn = Maybe Text
a} :: Protection)

instance Data.FromJSON Protection where
  parseJSON :: Value -> Parser Protection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Protection"
      ( \Object
x ->
          Maybe ApplicationLayerAutomaticResponseConfiguration
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Protection
Protection'
            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
"ApplicationLayerAutomaticResponseConfiguration"
                        )
            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
"HealthCheckIds" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Id")
            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
"Name")
            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
"ProtectionArn")
            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
"ResourceArn")
      )

instance Prelude.Hashable Protection where
  hashWithSalt :: Int -> Protection -> Int
hashWithSalt Int
_salt Protection' {Maybe [Text]
Maybe Text
Maybe ApplicationLayerAutomaticResponseConfiguration
resourceArn :: Maybe Text
protectionArn :: Maybe Text
name :: Maybe Text
id :: Maybe Text
healthCheckIds :: Maybe [Text]
applicationLayerAutomaticResponseConfiguration :: Maybe ApplicationLayerAutomaticResponseConfiguration
$sel:resourceArn:Protection' :: Protection -> Maybe Text
$sel:protectionArn:Protection' :: Protection -> Maybe Text
$sel:name:Protection' :: Protection -> Maybe Text
$sel:id:Protection' :: Protection -> Maybe Text
$sel:healthCheckIds:Protection' :: Protection -> Maybe [Text]
$sel:applicationLayerAutomaticResponseConfiguration:Protection' :: Protection -> Maybe ApplicationLayerAutomaticResponseConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
healthCheckIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protectionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceArn

instance Prelude.NFData Protection where
  rnf :: Protection -> ()
rnf Protection' {Maybe [Text]
Maybe Text
Maybe ApplicationLayerAutomaticResponseConfiguration
resourceArn :: Maybe Text
protectionArn :: Maybe Text
name :: Maybe Text
id :: Maybe Text
healthCheckIds :: Maybe [Text]
applicationLayerAutomaticResponseConfiguration :: Maybe ApplicationLayerAutomaticResponseConfiguration
$sel:resourceArn:Protection' :: Protection -> Maybe Text
$sel:protectionArn:Protection' :: Protection -> Maybe Text
$sel:name:Protection' :: Protection -> Maybe Text
$sel:id:Protection' :: Protection -> Maybe Text
$sel:healthCheckIds:Protection' :: Protection -> Maybe [Text]
$sel:applicationLayerAutomaticResponseConfiguration:Protection' :: Protection -> Maybe ApplicationLayerAutomaticResponseConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf
      Maybe ApplicationLayerAutomaticResponseConfiguration
applicationLayerAutomaticResponseConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
healthCheckIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protectionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn