{-# 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-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.Protection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a resource that is under DDoS protection.
--
-- /See:/ 'newProtection' smart constructor.
data Protection = Protection'
  { -- | The ARN (Amazon Resource Name) of the protection.
    Protection -> Maybe Text
protectionArn :: Prelude.Maybe Prelude.Text,
    -- | 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 ARN (Amazon Resource Name) of the Amazon Web Services resource that
    -- is protected.
    Protection -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the protection. For example, @My CloudFront distributions@.
    Protection -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier (ID) of the protection.
    Protection -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (Protection -> Protection -> Bool
(Protection -> Protection -> Bool)
-> (Protection -> Protection -> Bool) -> Eq Protection
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]
(Int -> ReadS Protection)
-> ReadS [Protection]
-> ReadPrec Protection
-> ReadPrec [Protection]
-> Read 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
(Int -> Protection -> ShowS)
-> (Protection -> String)
-> ([Protection] -> ShowS)
-> Show Protection
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. Protection -> Rep Protection x)
-> (forall x. Rep Protection x -> Protection) -> Generic Protection
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:
--
-- 'protectionArn', 'protection_protectionArn' - The ARN (Amazon Resource Name) of the protection.
--
-- 'healthCheckIds', 'protection_healthCheckIds' - The unique identifier (ID) for the Route 53 health check that\'s
-- associated with the protection.
--
-- 'resourceArn', 'protection_resourceArn' - The ARN (Amazon Resource Name) of the Amazon Web Services resource that
-- is protected.
--
-- 'name', 'protection_name' - The name of the protection. For example, @My CloudFront distributions@.
--
-- 'id', 'protection_id' - The unique identifier (ID) of the protection.
newProtection ::
  Protection
newProtection :: Protection
newProtection =
  Protection' :: Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Protection
Protection'
    { $sel:protectionArn:Protection' :: Maybe Text
protectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheckIds:Protection' :: Maybe [Text]
healthCheckIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:Protection' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Protection' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Protection' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN (Amazon Resource Name) of the protection.
protection_protectionArn :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_protectionArn :: (Maybe Text -> f (Maybe Text)) -> Protection -> f Protection
protection_protectionArn = (Protection -> Maybe Text)
-> (Protection -> Maybe Text -> Protection)
-> Lens Protection Protection (Maybe Text) (Maybe Text)
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 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 :: (Maybe [Text] -> f (Maybe [Text])) -> Protection -> f Protection
protection_healthCheckIds = (Protection -> Maybe [Text])
-> (Protection -> Maybe [Text] -> Protection)
-> Lens Protection Protection (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> Protection -> f Protection)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Protection
-> f Protection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Protection -> f Protection
protection_resourceArn = (Protection -> Maybe Text)
-> (Protection -> Maybe Text -> Protection)
-> Lens Protection Protection (Maybe Text) (Maybe Text)
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)

-- | The name of the protection. For example, @My CloudFront distributions@.
protection_name :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_name :: (Maybe Text -> f (Maybe Text)) -> Protection -> f Protection
protection_name = (Protection -> Maybe Text)
-> (Protection -> Maybe Text -> Protection)
-> Lens Protection Protection (Maybe Text) (Maybe Text)
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 unique identifier (ID) of the protection.
protection_id :: Lens.Lens' Protection (Prelude.Maybe Prelude.Text)
protection_id :: (Maybe Text -> f (Maybe Text)) -> Protection -> f Protection
protection_id = (Protection -> Maybe Text)
-> (Protection -> Maybe Text -> Protection)
-> Lens Protection Protection (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Protection

instance Prelude.NFData Protection