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

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

-- | The condition that must be met in order to apply the routing rule.
--
-- /See:/ 'newAwsS3BucketWebsiteConfigurationRoutingRuleCondition' smart constructor.
data AwsS3BucketWebsiteConfigurationRoutingRuleCondition = AwsS3BucketWebsiteConfigurationRoutingRuleCondition'
  { -- | Indicates to redirect the request if the key prefix matches this value.
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
keyPrefixEquals :: Prelude.Maybe Prelude.Text,
    -- | Indicates to redirect the request if the HTTP error code matches this
    -- value.
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
httpErrorCodeReturnedEquals :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool
(AwsS3BucketWebsiteConfigurationRoutingRuleCondition
 -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool)
-> (AwsS3BucketWebsiteConfigurationRoutingRuleCondition
    -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool)
-> Eq AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool
$c/= :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool
== :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool
$c== :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
ReadPrec AwsS3BucketWebsiteConfigurationRoutingRuleCondition
Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRuleCondition
ReadS [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
(Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> ReadS [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
-> ReadPrec AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
-> Read AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
$creadListPrec :: ReadPrec [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
readPrec :: ReadPrec AwsS3BucketWebsiteConfigurationRoutingRuleCondition
$creadPrec :: ReadPrec AwsS3BucketWebsiteConfigurationRoutingRuleCondition
readList :: ReadS [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
$creadList :: ReadS [AwsS3BucketWebsiteConfigurationRoutingRuleCondition]
readsPrec :: Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRuleCondition
$creadsPrec :: Int -> ReadS AwsS3BucketWebsiteConfigurationRoutingRuleCondition
Prelude.Read, Int -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> ShowS
[AwsS3BucketWebsiteConfigurationRoutingRuleCondition] -> ShowS
AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> String
(Int
 -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> ShowS)
-> (AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> String)
-> ([AwsS3BucketWebsiteConfigurationRoutingRuleCondition] -> ShowS)
-> Show AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketWebsiteConfigurationRoutingRuleCondition] -> ShowS
$cshowList :: [AwsS3BucketWebsiteConfigurationRoutingRuleCondition] -> ShowS
show :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> String
$cshow :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> String
showsPrec :: Int -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> ShowS
$cshowsPrec :: Int -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketWebsiteConfigurationRoutingRuleCondition
 -> Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x)
-> (forall x.
    Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x
    -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Generic AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall x.
Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall x.
AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
$cfrom :: forall x.
AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> Rep AwsS3BucketWebsiteConfigurationRoutingRuleCondition x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketWebsiteConfigurationRoutingRuleCondition' 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:
--
-- 'keyPrefixEquals', 'awsS3BucketWebsiteConfigurationRoutingRuleCondition_keyPrefixEquals' - Indicates to redirect the request if the key prefix matches this value.
--
-- 'httpErrorCodeReturnedEquals', 'awsS3BucketWebsiteConfigurationRoutingRuleCondition_httpErrorCodeReturnedEquals' - Indicates to redirect the request if the HTTP error code matches this
-- value.
newAwsS3BucketWebsiteConfigurationRoutingRuleCondition ::
  AwsS3BucketWebsiteConfigurationRoutingRuleCondition
newAwsS3BucketWebsiteConfigurationRoutingRuleCondition :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
newAwsS3BucketWebsiteConfigurationRoutingRuleCondition =
  AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: Maybe Text
-> Maybe Text
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
AwsS3BucketWebsiteConfigurationRoutingRuleCondition'
    { $sel:keyPrefixEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: Maybe Text
keyPrefixEquals =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpErrorCodeReturnedEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: Maybe Text
httpErrorCodeReturnedEquals =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates to redirect the request if the key prefix matches this value.
awsS3BucketWebsiteConfigurationRoutingRuleCondition_keyPrefixEquals :: Lens.Lens' AwsS3BucketWebsiteConfigurationRoutingRuleCondition (Prelude.Maybe Prelude.Text)
awsS3BucketWebsiteConfigurationRoutingRuleCondition_keyPrefixEquals :: (Maybe Text -> f (Maybe Text))
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> f AwsS3BucketWebsiteConfigurationRoutingRuleCondition
awsS3BucketWebsiteConfigurationRoutingRuleCondition_keyPrefixEquals = (AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text)
-> (AwsS3BucketWebsiteConfigurationRoutingRuleCondition
    -> Maybe Text
    -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Lens
     AwsS3BucketWebsiteConfigurationRoutingRuleCondition
     AwsS3BucketWebsiteConfigurationRoutingRuleCondition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketWebsiteConfigurationRoutingRuleCondition' {Maybe Text
keyPrefixEquals :: Maybe Text
$sel:keyPrefixEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
keyPrefixEquals} -> Maybe Text
keyPrefixEquals) (\s :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
s@AwsS3BucketWebsiteConfigurationRoutingRuleCondition' {} Maybe Text
a -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
s {$sel:keyPrefixEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: Maybe Text
keyPrefixEquals = Maybe Text
a} :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition)

-- | Indicates to redirect the request if the HTTP error code matches this
-- value.
awsS3BucketWebsiteConfigurationRoutingRuleCondition_httpErrorCodeReturnedEquals :: Lens.Lens' AwsS3BucketWebsiteConfigurationRoutingRuleCondition (Prelude.Maybe Prelude.Text)
awsS3BucketWebsiteConfigurationRoutingRuleCondition_httpErrorCodeReturnedEquals :: (Maybe Text -> f (Maybe Text))
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
-> f AwsS3BucketWebsiteConfigurationRoutingRuleCondition
awsS3BucketWebsiteConfigurationRoutingRuleCondition_httpErrorCodeReturnedEquals = (AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text)
-> (AwsS3BucketWebsiteConfigurationRoutingRuleCondition
    -> Maybe Text
    -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Lens
     AwsS3BucketWebsiteConfigurationRoutingRuleCondition
     AwsS3BucketWebsiteConfigurationRoutingRuleCondition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketWebsiteConfigurationRoutingRuleCondition' {Maybe Text
httpErrorCodeReturnedEquals :: Maybe Text
$sel:httpErrorCodeReturnedEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
httpErrorCodeReturnedEquals} -> Maybe Text
httpErrorCodeReturnedEquals) (\s :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition
s@AwsS3BucketWebsiteConfigurationRoutingRuleCondition' {} Maybe Text
a -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
s {$sel:httpErrorCodeReturnedEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: Maybe Text
httpErrorCodeReturnedEquals = Maybe Text
a} :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition)

instance
  Core.FromJSON
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition
  where
  parseJSON :: Value -> Parser AwsS3BucketWebsiteConfigurationRoutingRuleCondition
parseJSON =
    String
-> (Object
    -> Parser AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Value
-> Parser AwsS3BucketWebsiteConfigurationRoutingRuleCondition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsS3BucketWebsiteConfigurationRoutingRuleCondition"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> AwsS3BucketWebsiteConfigurationRoutingRuleCondition
AwsS3BucketWebsiteConfigurationRoutingRuleCondition'
            (Maybe Text
 -> Maybe Text
 -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
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
"KeyPrefixEquals")
              Parser
  (Maybe Text -> AwsS3BucketWebsiteConfigurationRoutingRuleCondition)
-> Parser (Maybe Text)
-> Parser AwsS3BucketWebsiteConfigurationRoutingRuleCondition
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
"HttpErrorCodeReturnedEquals")
      )

instance
  Prelude.Hashable
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition

instance
  Prelude.NFData
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition

instance
  Core.ToJSON
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition
  where
  toJSON :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Value
toJSON
    AwsS3BucketWebsiteConfigurationRoutingRuleCondition' {Maybe Text
httpErrorCodeReturnedEquals :: Maybe Text
keyPrefixEquals :: Maybe Text
$sel:httpErrorCodeReturnedEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
$sel:keyPrefixEquals:AwsS3BucketWebsiteConfigurationRoutingRuleCondition' :: AwsS3BucketWebsiteConfigurationRoutingRuleCondition -> Maybe Text
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"KeyPrefixEquals" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
                (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keyPrefixEquals,
              (Text
"HttpErrorCodeReturnedEquals" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
                (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
httpErrorCodeReturnedEquals
            ]
        )