{-# 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.SecurityHub.Types.AwsS3BucketWebsiteConfigurationRoutingRule
-- 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.SecurityHub.Types.AwsS3BucketWebsiteConfigurationRoutingRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsS3BucketWebsiteConfigurationRoutingRuleCondition
import Amazonka.SecurityHub.Types.AwsS3BucketWebsiteConfigurationRoutingRuleRedirect

-- | A rule for redirecting requests to the website.
--
-- /See:/ 'newAwsS3BucketWebsiteConfigurationRoutingRule' smart constructor.
data AwsS3BucketWebsiteConfigurationRoutingRule = AwsS3BucketWebsiteConfigurationRoutingRule'
  { -- | Provides the rules to redirect the request if the condition in
    -- @Condition@ is met.
    AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect :: Prelude.Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect,
    -- | Provides the condition that must be met in order to apply the routing
    -- rule.
    AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition :: Prelude.Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
  }
  deriving (AwsS3BucketWebsiteConfigurationRoutingRule
-> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool
(AwsS3BucketWebsiteConfigurationRoutingRule
 -> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool)
-> (AwsS3BucketWebsiteConfigurationRoutingRule
    -> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool)
-> Eq AwsS3BucketWebsiteConfigurationRoutingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketWebsiteConfigurationRoutingRule
-> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool
$c/= :: AwsS3BucketWebsiteConfigurationRoutingRule
-> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool
== :: AwsS3BucketWebsiteConfigurationRoutingRule
-> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool
$c== :: AwsS3BucketWebsiteConfigurationRoutingRule
-> AwsS3BucketWebsiteConfigurationRoutingRule -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRule]
ReadPrec AwsS3BucketWebsiteConfigurationRoutingRule
Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRule
ReadS [AwsS3BucketWebsiteConfigurationRoutingRule]
(Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRule)
-> ReadS [AwsS3BucketWebsiteConfigurationRoutingRule]
-> ReadPrec AwsS3BucketWebsiteConfigurationRoutingRule
-> ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRule]
-> Read AwsS3BucketWebsiteConfigurationRoutingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRule]
$creadListPrec :: ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRule]
readPrec :: ReadPrec AwsS3BucketWebsiteConfigurationRoutingRule
$creadPrec :: ReadPrec AwsS3BucketWebsiteConfigurationRoutingRule
readList :: ReadS [AwsS3BucketWebsiteConfigurationRoutingRule]
$creadList :: ReadS [AwsS3BucketWebsiteConfigurationRoutingRule]
readsPrec :: Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRule
$creadsPrec :: Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRule
Prelude.Read, Int -> AwsS3BucketWebsiteConfigurationRoutingRule -> ShowS
[AwsS3BucketWebsiteConfigurationRoutingRule] -> ShowS
AwsS3BucketWebsiteConfigurationRoutingRule -> String
(Int -> AwsS3BucketWebsiteConfigurationRoutingRule -> ShowS)
-> (AwsS3BucketWebsiteConfigurationRoutingRule -> String)
-> ([AwsS3BucketWebsiteConfigurationRoutingRule] -> ShowS)
-> Show AwsS3BucketWebsiteConfigurationRoutingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketWebsiteConfigurationRoutingRule] -> ShowS
$cshowList :: [AwsS3BucketWebsiteConfigurationRoutingRule] -> ShowS
show :: AwsS3BucketWebsiteConfigurationRoutingRule -> String
$cshow :: AwsS3BucketWebsiteConfigurationRoutingRule -> String
showsPrec :: Int -> AwsS3BucketWebsiteConfigurationRoutingRule -> ShowS
$cshowsPrec :: Int -> AwsS3BucketWebsiteConfigurationRoutingRule -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketWebsiteConfigurationRoutingRule
 -> Rep AwsS3BucketWebsiteConfigurationRoutingRule x)
-> (forall x.
    Rep AwsS3BucketWebsiteConfigurationRoutingRule x
    -> AwsS3BucketWebsiteConfigurationRoutingRule)
-> Generic AwsS3BucketWebsiteConfigurationRoutingRule
forall x.
Rep AwsS3BucketWebsiteConfigurationRoutingRule x
-> AwsS3BucketWebsiteConfigurationRoutingRule
forall x.
AwsS3BucketWebsiteConfigurationRoutingRule
-> Rep AwsS3BucketWebsiteConfigurationRoutingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketWebsiteConfigurationRoutingRule x
-> AwsS3BucketWebsiteConfigurationRoutingRule
$cfrom :: forall x.
AwsS3BucketWebsiteConfigurationRoutingRule
-> Rep AwsS3BucketWebsiteConfigurationRoutingRule x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketWebsiteConfigurationRoutingRule' 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:
--
-- 'redirect', 'awsS3BucketWebsiteConfigurationRoutingRule_redirect' - Provides the rules to redirect the request if the condition in
-- @Condition@ is met.
--
-- 'condition', 'awsS3BucketWebsiteConfigurationRoutingRule_condition' - Provides the condition that must be met in order to apply the routing
-- rule.
newAwsS3BucketWebsiteConfigurationRoutingRule ::
  AwsS3BucketWebsiteConfigurationRoutingRule
newAwsS3BucketWebsiteConfigurationRoutingRule :: AwsS3BucketWebsiteConfigurationRoutingRule
newAwsS3BucketWebsiteConfigurationRoutingRule =
  AwsS3BucketWebsiteConfigurationRoutingRule' :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRule
AwsS3BucketWebsiteConfigurationRoutingRule'
    { $sel:redirect:AwsS3BucketWebsiteConfigurationRoutingRule' :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect =
        Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
forall a. Maybe a
Prelude.Nothing,
      $sel:condition:AwsS3BucketWebsiteConfigurationRoutingRule' :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition = Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall a. Maybe a
Prelude.Nothing
    }

-- | Provides the rules to redirect the request if the condition in
-- @Condition@ is met.
awsS3BucketWebsiteConfigurationRoutingRule_redirect :: Lens.Lens' AwsS3BucketWebsiteConfigurationRoutingRule (Prelude.Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
awsS3BucketWebsiteConfigurationRoutingRule_redirect :: (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
 -> f (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect))
-> AwsS3BucketWebsiteConfigurationRoutingRule
-> f AwsS3BucketWebsiteConfigurationRoutingRule
awsS3BucketWebsiteConfigurationRoutingRule_redirect = (AwsS3BucketWebsiteConfigurationRoutingRule
 -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
-> (AwsS3BucketWebsiteConfigurationRoutingRule
    -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
    -> AwsS3BucketWebsiteConfigurationRoutingRule)
-> Lens
     AwsS3BucketWebsiteConfigurationRoutingRule
     AwsS3BucketWebsiteConfigurationRoutingRule
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketWebsiteConfigurationRoutingRule' {Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
$sel:redirect:AwsS3BucketWebsiteConfigurationRoutingRule' :: AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect} -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect) (\s :: AwsS3BucketWebsiteConfigurationRoutingRule
s@AwsS3BucketWebsiteConfigurationRoutingRule' {} Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
a -> AwsS3BucketWebsiteConfigurationRoutingRule
s {$sel:redirect:AwsS3BucketWebsiteConfigurationRoutingRule' :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect = Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
a} :: AwsS3BucketWebsiteConfigurationRoutingRule)

-- | Provides the condition that must be met in order to apply the routing
-- rule.
awsS3BucketWebsiteConfigurationRoutingRule_condition :: Lens.Lens' AwsS3BucketWebsiteConfigurationRoutingRule (Prelude.Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
awsS3BucketWebsiteConfigurationRoutingRule_condition :: (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
 -> f (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition))
-> AwsS3BucketWebsiteConfigurationRoutingRule
-> f AwsS3BucketWebsiteConfigurationRoutingRule
awsS3BucketWebsiteConfigurationRoutingRule_condition = (AwsS3BucketWebsiteConfigurationRoutingRule
 -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> (AwsS3BucketWebsiteConfigurationRoutingRule
    -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
    -> AwsS3BucketWebsiteConfigurationRoutingRule)
-> Lens
     AwsS3BucketWebsiteConfigurationRoutingRule
     AwsS3BucketWebsiteConfigurationRoutingRule
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketWebsiteConfigurationRoutingRule' {Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
$sel:condition:AwsS3BucketWebsiteConfigurationRoutingRule' :: AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition} -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition) (\s :: AwsS3BucketWebsiteConfigurationRoutingRule
s@AwsS3BucketWebsiteConfigurationRoutingRule' {} Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
a -> AwsS3BucketWebsiteConfigurationRoutingRule
s {$sel:condition:AwsS3BucketWebsiteConfigurationRoutingRule' :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition = Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
a} :: AwsS3BucketWebsiteConfigurationRoutingRule)

instance
  Core.FromJSON
    AwsS3BucketWebsiteConfigurationRoutingRule
  where
  parseJSON :: Value -> Parser AwsS3BucketWebsiteConfigurationRoutingRule
parseJSON =
    String
-> (Object -> Parser AwsS3BucketWebsiteConfigurationRoutingRule)
-> Value
-> Parser AwsS3BucketWebsiteConfigurationRoutingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsS3BucketWebsiteConfigurationRoutingRule"
      ( \Object
x ->
          Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRule
AwsS3BucketWebsiteConfigurationRoutingRule'
            (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
 -> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
 -> AwsS3BucketWebsiteConfigurationRoutingRule)
-> Parser
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
-> Parser
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
      -> AwsS3BucketWebsiteConfigurationRoutingRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Redirect")
              Parser
  (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
   -> AwsS3BucketWebsiteConfigurationRoutingRule)
-> Parser
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Parser AwsS3BucketWebsiteConfigurationRoutingRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text
-> Parser
     (Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Condition")
      )

instance
  Prelude.Hashable
    AwsS3BucketWebsiteConfigurationRoutingRule

instance
  Prelude.NFData
    AwsS3BucketWebsiteConfigurationRoutingRule

instance
  Core.ToJSON
    AwsS3BucketWebsiteConfigurationRoutingRule
  where
  toJSON :: AwsS3BucketWebsiteConfigurationRoutingRule -> Value
toJSON
    AwsS3BucketWebsiteConfigurationRoutingRule' {Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
condition :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
redirect :: Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
$sel:condition:AwsS3BucketWebsiteConfigurationRoutingRule' :: AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
$sel:redirect:AwsS3BucketWebsiteConfigurationRoutingRule' :: AwsS3BucketWebsiteConfigurationRoutingRule
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"Redirect" Text -> AwsS3BucketWebsiteConfigurationRoutingRuleRedirect -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsS3BucketWebsiteConfigurationRoutingRuleRedirect -> Pair)
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleRedirect
redirect,
              (Text
"Condition" Text -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Pair)
-> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsS3BucketWebsiteConfigurationRoutingRuleCondition
condition
            ]
        )