{-# 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.WAFV2.Types.OrStatement
-- 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.WAFV2.Types.OrStatement 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 {-# SOURCE #-} Amazonka.WAFV2.Types.Statement

-- | A logical rule statement used to combine other rule statements with OR
-- logic. You provide more than one Statement within the @OrStatement@.
--
-- /See:/ 'newOrStatement' smart constructor.
data OrStatement = OrStatement'
  { -- | The statements to combine with OR logic. You can use any statements that
    -- can be nested.
    OrStatement -> [Statement]
statements :: [Statement]
  }
  deriving (OrStatement -> OrStatement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrStatement -> OrStatement -> Bool
$c/= :: OrStatement -> OrStatement -> Bool
== :: OrStatement -> OrStatement -> Bool
$c== :: OrStatement -> OrStatement -> Bool
Prelude.Eq, ReadPrec [OrStatement]
ReadPrec OrStatement
Int -> ReadS OrStatement
ReadS [OrStatement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrStatement]
$creadListPrec :: ReadPrec [OrStatement]
readPrec :: ReadPrec OrStatement
$creadPrec :: ReadPrec OrStatement
readList :: ReadS [OrStatement]
$creadList :: ReadS [OrStatement]
readsPrec :: Int -> ReadS OrStatement
$creadsPrec :: Int -> ReadS OrStatement
Prelude.Read, Int -> OrStatement -> ShowS
[OrStatement] -> ShowS
OrStatement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrStatement] -> ShowS
$cshowList :: [OrStatement] -> ShowS
show :: OrStatement -> String
$cshow :: OrStatement -> String
showsPrec :: Int -> OrStatement -> ShowS
$cshowsPrec :: Int -> OrStatement -> ShowS
Prelude.Show, forall x. Rep OrStatement x -> OrStatement
forall x. OrStatement -> Rep OrStatement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OrStatement x -> OrStatement
$cfrom :: forall x. OrStatement -> Rep OrStatement x
Prelude.Generic)

-- |
-- Create a value of 'OrStatement' 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:
--
-- 'statements', 'orStatement_statements' - The statements to combine with OR logic. You can use any statements that
-- can be nested.
newOrStatement ::
  OrStatement
newOrStatement :: OrStatement
newOrStatement =
  OrStatement' {$sel:statements:OrStatement' :: [Statement]
statements = forall a. Monoid a => a
Prelude.mempty}

-- | The statements to combine with OR logic. You can use any statements that
-- can be nested.
orStatement_statements :: Lens.Lens' OrStatement [Statement]
orStatement_statements :: Lens' OrStatement [Statement]
orStatement_statements = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrStatement' {[Statement]
statements :: [Statement]
$sel:statements:OrStatement' :: OrStatement -> [Statement]
statements} -> [Statement]
statements) (\s :: OrStatement
s@OrStatement' {} [Statement]
a -> OrStatement
s {$sel:statements:OrStatement' :: [Statement]
statements = [Statement]
a} :: OrStatement) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON OrStatement where
  parseJSON :: Value -> Parser OrStatement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OrStatement"
      ( \Object
x ->
          [Statement] -> OrStatement
OrStatement'
            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
"Statements" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable OrStatement where
  hashWithSalt :: Int -> OrStatement -> Int
hashWithSalt Int
_salt OrStatement' {[Statement]
statements :: [Statement]
$sel:statements:OrStatement' :: OrStatement -> [Statement]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Statement]
statements

instance Prelude.NFData OrStatement where
  rnf :: OrStatement -> ()
rnf OrStatement' {[Statement]
statements :: [Statement]
$sel:statements:OrStatement' :: OrStatement -> [Statement]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Statement]
statements

instance Data.ToJSON OrStatement where
  toJSON :: OrStatement -> Value
toJSON OrStatement' {[Statement]
statements :: [Statement]
$sel:statements:OrStatement' :: OrStatement -> [Statement]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Statements" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Statement]
statements)]
      )