{-# 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.ELBV2.Types.RuleCondition
-- 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.ELBV2.Types.RuleCondition where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types.HostHeaderConditionConfig
import Amazonka.ELBV2.Types.HttpHeaderConditionConfig
import Amazonka.ELBV2.Types.HttpRequestMethodConditionConfig
import Amazonka.ELBV2.Types.PathPatternConditionConfig
import Amazonka.ELBV2.Types.QueryStringConditionConfig
import Amazonka.ELBV2.Types.SourceIpConditionConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a condition for a rule.
--
-- Each rule can optionally include up to one of each of the following
-- conditions: @http-request-method@, @host-header@, @path-pattern@, and
-- @source-ip@. Each rule can also optionally include one or more of each
-- of the following conditions: @http-header@ and @query-string@.
--
-- /See:/ 'newRuleCondition' smart constructor.
data RuleCondition = RuleCondition'
  { -- | The field in the HTTP request. The following are the possible values:
    --
    -- -   @http-header@
    --
    -- -   @http-request-method@
    --
    -- -   @host-header@
    --
    -- -   @path-pattern@
    --
    -- -   @query-string@
    --
    -- -   @source-ip@
    RuleCondition -> Maybe Text
field :: Prelude.Maybe Prelude.Text,
    -- | Information for an HTTP header condition. Specify only when @Field@ is
    -- @http-header@.
    RuleCondition -> Maybe HttpHeaderConditionConfig
httpHeaderConfig :: Prelude.Maybe HttpHeaderConditionConfig,
    -- | Information for a host header condition. Specify only when @Field@ is
    -- @host-header@.
    RuleCondition -> Maybe HostHeaderConditionConfig
hostHeaderConfig :: Prelude.Maybe HostHeaderConditionConfig,
    -- | The condition value. Specify only when @Field@ is @host-header@ or
    -- @path-pattern@. Alternatively, to specify multiple host names or
    -- multiple path patterns, use @HostHeaderConfig@ or @PathPatternConfig@.
    --
    -- If @Field@ is @host-header@ and you are not using @HostHeaderConfig@,
    -- you can specify a single host name (for example, my.example.com) in
    -- @Values@. A host name is case insensitive, can be up to 128 characters
    -- in length, and can contain any of the following characters.
    --
    -- -   A-Z, a-z, 0-9
    --
    -- -   - .
    --
    -- -   * (matches 0 or more characters)
    --
    -- -   ? (matches exactly 1 character)
    --
    -- If @Field@ is @path-pattern@ and you are not using @PathPatternConfig@,
    -- you can specify a single path pattern (for example, \/img\/*) in
    -- @Values@. A path pattern is case-sensitive, can be up to 128 characters
    -- in length, and can contain any of the following characters.
    --
    -- -   A-Z, a-z, 0-9
    --
    -- -   _ - . $ \/ ~ \" \' \@ : +
    --
    -- -   & (using &amp;)
    --
    -- -   * (matches 0 or more characters)
    --
    -- -   ? (matches exactly 1 character)
    RuleCondition -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | Information for a source IP condition. Specify only when @Field@ is
    -- @source-ip@.
    RuleCondition -> Maybe SourceIpConditionConfig
sourceIpConfig :: Prelude.Maybe SourceIpConditionConfig,
    -- | Information for an HTTP method condition. Specify only when @Field@ is
    -- @http-request-method@.
    RuleCondition -> Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig :: Prelude.Maybe HttpRequestMethodConditionConfig,
    -- | Information for a path pattern condition. Specify only when @Field@ is
    -- @path-pattern@.
    RuleCondition -> Maybe PathPatternConditionConfig
pathPatternConfig :: Prelude.Maybe PathPatternConditionConfig,
    -- | Information for a query string condition. Specify only when @Field@ is
    -- @query-string@.
    RuleCondition -> Maybe QueryStringConditionConfig
queryStringConfig :: Prelude.Maybe QueryStringConditionConfig
  }
  deriving (RuleCondition -> RuleCondition -> Bool
(RuleCondition -> RuleCondition -> Bool)
-> (RuleCondition -> RuleCondition -> Bool) -> Eq RuleCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleCondition -> RuleCondition -> Bool
$c/= :: RuleCondition -> RuleCondition -> Bool
== :: RuleCondition -> RuleCondition -> Bool
$c== :: RuleCondition -> RuleCondition -> Bool
Prelude.Eq, ReadPrec [RuleCondition]
ReadPrec RuleCondition
Int -> ReadS RuleCondition
ReadS [RuleCondition]
(Int -> ReadS RuleCondition)
-> ReadS [RuleCondition]
-> ReadPrec RuleCondition
-> ReadPrec [RuleCondition]
-> Read RuleCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleCondition]
$creadListPrec :: ReadPrec [RuleCondition]
readPrec :: ReadPrec RuleCondition
$creadPrec :: ReadPrec RuleCondition
readList :: ReadS [RuleCondition]
$creadList :: ReadS [RuleCondition]
readsPrec :: Int -> ReadS RuleCondition
$creadsPrec :: Int -> ReadS RuleCondition
Prelude.Read, Int -> RuleCondition -> ShowS
[RuleCondition] -> ShowS
RuleCondition -> String
(Int -> RuleCondition -> ShowS)
-> (RuleCondition -> String)
-> ([RuleCondition] -> ShowS)
-> Show RuleCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleCondition] -> ShowS
$cshowList :: [RuleCondition] -> ShowS
show :: RuleCondition -> String
$cshow :: RuleCondition -> String
showsPrec :: Int -> RuleCondition -> ShowS
$cshowsPrec :: Int -> RuleCondition -> ShowS
Prelude.Show, (forall x. RuleCondition -> Rep RuleCondition x)
-> (forall x. Rep RuleCondition x -> RuleCondition)
-> Generic RuleCondition
forall x. Rep RuleCondition x -> RuleCondition
forall x. RuleCondition -> Rep RuleCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleCondition x -> RuleCondition
$cfrom :: forall x. RuleCondition -> Rep RuleCondition x
Prelude.Generic)

-- |
-- Create a value of 'RuleCondition' 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:
--
-- 'field', 'ruleCondition_field' - The field in the HTTP request. The following are the possible values:
--
-- -   @http-header@
--
-- -   @http-request-method@
--
-- -   @host-header@
--
-- -   @path-pattern@
--
-- -   @query-string@
--
-- -   @source-ip@
--
-- 'httpHeaderConfig', 'ruleCondition_httpHeaderConfig' - Information for an HTTP header condition. Specify only when @Field@ is
-- @http-header@.
--
-- 'hostHeaderConfig', 'ruleCondition_hostHeaderConfig' - Information for a host header condition. Specify only when @Field@ is
-- @host-header@.
--
-- 'values', 'ruleCondition_values' - The condition value. Specify only when @Field@ is @host-header@ or
-- @path-pattern@. Alternatively, to specify multiple host names or
-- multiple path patterns, use @HostHeaderConfig@ or @PathPatternConfig@.
--
-- If @Field@ is @host-header@ and you are not using @HostHeaderConfig@,
-- you can specify a single host name (for example, my.example.com) in
-- @Values@. A host name is case insensitive, can be up to 128 characters
-- in length, and can contain any of the following characters.
--
-- -   A-Z, a-z, 0-9
--
-- -   - .
--
-- -   * (matches 0 or more characters)
--
-- -   ? (matches exactly 1 character)
--
-- If @Field@ is @path-pattern@ and you are not using @PathPatternConfig@,
-- you can specify a single path pattern (for example, \/img\/*) in
-- @Values@. A path pattern is case-sensitive, can be up to 128 characters
-- in length, and can contain any of the following characters.
--
-- -   A-Z, a-z, 0-9
--
-- -   _ - . $ \/ ~ \" \' \@ : +
--
-- -   & (using &amp;)
--
-- -   * (matches 0 or more characters)
--
-- -   ? (matches exactly 1 character)
--
-- 'sourceIpConfig', 'ruleCondition_sourceIpConfig' - Information for a source IP condition. Specify only when @Field@ is
-- @source-ip@.
--
-- 'httpRequestMethodConfig', 'ruleCondition_httpRequestMethodConfig' - Information for an HTTP method condition. Specify only when @Field@ is
-- @http-request-method@.
--
-- 'pathPatternConfig', 'ruleCondition_pathPatternConfig' - Information for a path pattern condition. Specify only when @Field@ is
-- @path-pattern@.
--
-- 'queryStringConfig', 'ruleCondition_queryStringConfig' - Information for a query string condition. Specify only when @Field@ is
-- @query-string@.
newRuleCondition ::
  RuleCondition
newRuleCondition :: RuleCondition
newRuleCondition =
  RuleCondition' :: Maybe Text
-> Maybe HttpHeaderConditionConfig
-> Maybe HostHeaderConditionConfig
-> Maybe [Text]
-> Maybe SourceIpConditionConfig
-> Maybe HttpRequestMethodConditionConfig
-> Maybe PathPatternConditionConfig
-> Maybe QueryStringConditionConfig
-> RuleCondition
RuleCondition'
    { $sel:field:RuleCondition' :: Maybe Text
field = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpHeaderConfig:RuleCondition' :: Maybe HttpHeaderConditionConfig
httpHeaderConfig = Maybe HttpHeaderConditionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:hostHeaderConfig:RuleCondition' :: Maybe HostHeaderConditionConfig
hostHeaderConfig = Maybe HostHeaderConditionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:values:RuleCondition' :: Maybe [Text]
values = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceIpConfig:RuleCondition' :: Maybe SourceIpConditionConfig
sourceIpConfig = Maybe SourceIpConditionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:httpRequestMethodConfig:RuleCondition' :: Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig = Maybe HttpRequestMethodConditionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:pathPatternConfig:RuleCondition' :: Maybe PathPatternConditionConfig
pathPatternConfig = Maybe PathPatternConditionConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:queryStringConfig:RuleCondition' :: Maybe QueryStringConditionConfig
queryStringConfig = Maybe QueryStringConditionConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | The field in the HTTP request. The following are the possible values:
--
-- -   @http-header@
--
-- -   @http-request-method@
--
-- -   @host-header@
--
-- -   @path-pattern@
--
-- -   @query-string@
--
-- -   @source-ip@
ruleCondition_field :: Lens.Lens' RuleCondition (Prelude.Maybe Prelude.Text)
ruleCondition_field :: (Maybe Text -> f (Maybe Text)) -> RuleCondition -> f RuleCondition
ruleCondition_field = (RuleCondition -> Maybe Text)
-> (RuleCondition -> Maybe Text -> RuleCondition)
-> Lens RuleCondition RuleCondition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe Text
field :: Maybe Text
$sel:field:RuleCondition' :: RuleCondition -> Maybe Text
field} -> Maybe Text
field) (\s :: RuleCondition
s@RuleCondition' {} Maybe Text
a -> RuleCondition
s {$sel:field:RuleCondition' :: Maybe Text
field = Maybe Text
a} :: RuleCondition)

-- | Information for an HTTP header condition. Specify only when @Field@ is
-- @http-header@.
ruleCondition_httpHeaderConfig :: Lens.Lens' RuleCondition (Prelude.Maybe HttpHeaderConditionConfig)
ruleCondition_httpHeaderConfig :: (Maybe HttpHeaderConditionConfig
 -> f (Maybe HttpHeaderConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_httpHeaderConfig = (RuleCondition -> Maybe HttpHeaderConditionConfig)
-> (RuleCondition
    -> Maybe HttpHeaderConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe HttpHeaderConditionConfig)
     (Maybe HttpHeaderConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe HttpHeaderConditionConfig
httpHeaderConfig :: Maybe HttpHeaderConditionConfig
$sel:httpHeaderConfig:RuleCondition' :: RuleCondition -> Maybe HttpHeaderConditionConfig
httpHeaderConfig} -> Maybe HttpHeaderConditionConfig
httpHeaderConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe HttpHeaderConditionConfig
a -> RuleCondition
s {$sel:httpHeaderConfig:RuleCondition' :: Maybe HttpHeaderConditionConfig
httpHeaderConfig = Maybe HttpHeaderConditionConfig
a} :: RuleCondition)

-- | Information for a host header condition. Specify only when @Field@ is
-- @host-header@.
ruleCondition_hostHeaderConfig :: Lens.Lens' RuleCondition (Prelude.Maybe HostHeaderConditionConfig)
ruleCondition_hostHeaderConfig :: (Maybe HostHeaderConditionConfig
 -> f (Maybe HostHeaderConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_hostHeaderConfig = (RuleCondition -> Maybe HostHeaderConditionConfig)
-> (RuleCondition
    -> Maybe HostHeaderConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe HostHeaderConditionConfig)
     (Maybe HostHeaderConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe HostHeaderConditionConfig
hostHeaderConfig :: Maybe HostHeaderConditionConfig
$sel:hostHeaderConfig:RuleCondition' :: RuleCondition -> Maybe HostHeaderConditionConfig
hostHeaderConfig} -> Maybe HostHeaderConditionConfig
hostHeaderConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe HostHeaderConditionConfig
a -> RuleCondition
s {$sel:hostHeaderConfig:RuleCondition' :: Maybe HostHeaderConditionConfig
hostHeaderConfig = Maybe HostHeaderConditionConfig
a} :: RuleCondition)

-- | The condition value. Specify only when @Field@ is @host-header@ or
-- @path-pattern@. Alternatively, to specify multiple host names or
-- multiple path patterns, use @HostHeaderConfig@ or @PathPatternConfig@.
--
-- If @Field@ is @host-header@ and you are not using @HostHeaderConfig@,
-- you can specify a single host name (for example, my.example.com) in
-- @Values@. A host name is case insensitive, can be up to 128 characters
-- in length, and can contain any of the following characters.
--
-- -   A-Z, a-z, 0-9
--
-- -   - .
--
-- -   * (matches 0 or more characters)
--
-- -   ? (matches exactly 1 character)
--
-- If @Field@ is @path-pattern@ and you are not using @PathPatternConfig@,
-- you can specify a single path pattern (for example, \/img\/*) in
-- @Values@. A path pattern is case-sensitive, can be up to 128 characters
-- in length, and can contain any of the following characters.
--
-- -   A-Z, a-z, 0-9
--
-- -   _ - . $ \/ ~ \" \' \@ : +
--
-- -   & (using &amp;)
--
-- -   * (matches 0 or more characters)
--
-- -   ? (matches exactly 1 character)
ruleCondition_values :: Lens.Lens' RuleCondition (Prelude.Maybe [Prelude.Text])
ruleCondition_values :: (Maybe [Text] -> f (Maybe [Text]))
-> RuleCondition -> f RuleCondition
ruleCondition_values = (RuleCondition -> Maybe [Text])
-> (RuleCondition -> Maybe [Text] -> RuleCondition)
-> Lens RuleCondition RuleCondition (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe [Text]
values :: Maybe [Text]
$sel:values:RuleCondition' :: RuleCondition -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: RuleCondition
s@RuleCondition' {} Maybe [Text]
a -> RuleCondition
s {$sel:values:RuleCondition' :: Maybe [Text]
values = Maybe [Text]
a} :: RuleCondition) ((Maybe [Text] -> f (Maybe [Text]))
 -> RuleCondition -> f RuleCondition)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RuleCondition
-> f RuleCondition
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

-- | Information for a source IP condition. Specify only when @Field@ is
-- @source-ip@.
ruleCondition_sourceIpConfig :: Lens.Lens' RuleCondition (Prelude.Maybe SourceIpConditionConfig)
ruleCondition_sourceIpConfig :: (Maybe SourceIpConditionConfig
 -> f (Maybe SourceIpConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_sourceIpConfig = (RuleCondition -> Maybe SourceIpConditionConfig)
-> (RuleCondition
    -> Maybe SourceIpConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe SourceIpConditionConfig)
     (Maybe SourceIpConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe SourceIpConditionConfig
sourceIpConfig :: Maybe SourceIpConditionConfig
$sel:sourceIpConfig:RuleCondition' :: RuleCondition -> Maybe SourceIpConditionConfig
sourceIpConfig} -> Maybe SourceIpConditionConfig
sourceIpConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe SourceIpConditionConfig
a -> RuleCondition
s {$sel:sourceIpConfig:RuleCondition' :: Maybe SourceIpConditionConfig
sourceIpConfig = Maybe SourceIpConditionConfig
a} :: RuleCondition)

-- | Information for an HTTP method condition. Specify only when @Field@ is
-- @http-request-method@.
ruleCondition_httpRequestMethodConfig :: Lens.Lens' RuleCondition (Prelude.Maybe HttpRequestMethodConditionConfig)
ruleCondition_httpRequestMethodConfig :: (Maybe HttpRequestMethodConditionConfig
 -> f (Maybe HttpRequestMethodConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_httpRequestMethodConfig = (RuleCondition -> Maybe HttpRequestMethodConditionConfig)
-> (RuleCondition
    -> Maybe HttpRequestMethodConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe HttpRequestMethodConditionConfig)
     (Maybe HttpRequestMethodConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig :: Maybe HttpRequestMethodConditionConfig
$sel:httpRequestMethodConfig:RuleCondition' :: RuleCondition -> Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig} -> Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe HttpRequestMethodConditionConfig
a -> RuleCondition
s {$sel:httpRequestMethodConfig:RuleCondition' :: Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig = Maybe HttpRequestMethodConditionConfig
a} :: RuleCondition)

-- | Information for a path pattern condition. Specify only when @Field@ is
-- @path-pattern@.
ruleCondition_pathPatternConfig :: Lens.Lens' RuleCondition (Prelude.Maybe PathPatternConditionConfig)
ruleCondition_pathPatternConfig :: (Maybe PathPatternConditionConfig
 -> f (Maybe PathPatternConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_pathPatternConfig = (RuleCondition -> Maybe PathPatternConditionConfig)
-> (RuleCondition
    -> Maybe PathPatternConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe PathPatternConditionConfig)
     (Maybe PathPatternConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe PathPatternConditionConfig
pathPatternConfig :: Maybe PathPatternConditionConfig
$sel:pathPatternConfig:RuleCondition' :: RuleCondition -> Maybe PathPatternConditionConfig
pathPatternConfig} -> Maybe PathPatternConditionConfig
pathPatternConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe PathPatternConditionConfig
a -> RuleCondition
s {$sel:pathPatternConfig:RuleCondition' :: Maybe PathPatternConditionConfig
pathPatternConfig = Maybe PathPatternConditionConfig
a} :: RuleCondition)

-- | Information for a query string condition. Specify only when @Field@ is
-- @query-string@.
ruleCondition_queryStringConfig :: Lens.Lens' RuleCondition (Prelude.Maybe QueryStringConditionConfig)
ruleCondition_queryStringConfig :: (Maybe QueryStringConditionConfig
 -> f (Maybe QueryStringConditionConfig))
-> RuleCondition -> f RuleCondition
ruleCondition_queryStringConfig = (RuleCondition -> Maybe QueryStringConditionConfig)
-> (RuleCondition
    -> Maybe QueryStringConditionConfig -> RuleCondition)
-> Lens
     RuleCondition
     RuleCondition
     (Maybe QueryStringConditionConfig)
     (Maybe QueryStringConditionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleCondition' {Maybe QueryStringConditionConfig
queryStringConfig :: Maybe QueryStringConditionConfig
$sel:queryStringConfig:RuleCondition' :: RuleCondition -> Maybe QueryStringConditionConfig
queryStringConfig} -> Maybe QueryStringConditionConfig
queryStringConfig) (\s :: RuleCondition
s@RuleCondition' {} Maybe QueryStringConditionConfig
a -> RuleCondition
s {$sel:queryStringConfig:RuleCondition' :: Maybe QueryStringConditionConfig
queryStringConfig = Maybe QueryStringConditionConfig
a} :: RuleCondition)

instance Core.FromXML RuleCondition where
  parseXML :: [Node] -> Either String RuleCondition
parseXML [Node]
x =
    Maybe Text
-> Maybe HttpHeaderConditionConfig
-> Maybe HostHeaderConditionConfig
-> Maybe [Text]
-> Maybe SourceIpConditionConfig
-> Maybe HttpRequestMethodConditionConfig
-> Maybe PathPatternConditionConfig
-> Maybe QueryStringConditionConfig
-> RuleCondition
RuleCondition'
      (Maybe Text
 -> Maybe HttpHeaderConditionConfig
 -> Maybe HostHeaderConditionConfig
 -> Maybe [Text]
 -> Maybe SourceIpConditionConfig
 -> Maybe HttpRequestMethodConditionConfig
 -> Maybe PathPatternConditionConfig
 -> Maybe QueryStringConditionConfig
 -> RuleCondition)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe HttpHeaderConditionConfig
      -> Maybe HostHeaderConditionConfig
      -> Maybe [Text]
      -> Maybe SourceIpConditionConfig
      -> Maybe HttpRequestMethodConditionConfig
      -> Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig
      -> RuleCondition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Field")
      Either
  String
  (Maybe HttpHeaderConditionConfig
   -> Maybe HostHeaderConditionConfig
   -> Maybe [Text]
   -> Maybe SourceIpConditionConfig
   -> Maybe HttpRequestMethodConditionConfig
   -> Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig
   -> RuleCondition)
-> Either String (Maybe HttpHeaderConditionConfig)
-> Either
     String
     (Maybe HostHeaderConditionConfig
      -> Maybe [Text]
      -> Maybe SourceIpConditionConfig
      -> Maybe HttpRequestMethodConditionConfig
      -> Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig
      -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe HttpHeaderConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HttpHeaderConfig")
      Either
  String
  (Maybe HostHeaderConditionConfig
   -> Maybe [Text]
   -> Maybe SourceIpConditionConfig
   -> Maybe HttpRequestMethodConditionConfig
   -> Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig
   -> RuleCondition)
-> Either String (Maybe HostHeaderConditionConfig)
-> Either
     String
     (Maybe [Text]
      -> Maybe SourceIpConditionConfig
      -> Maybe HttpRequestMethodConditionConfig
      -> Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig
      -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe HostHeaderConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HostHeaderConfig")
      Either
  String
  (Maybe [Text]
   -> Maybe SourceIpConditionConfig
   -> Maybe HttpRequestMethodConditionConfig
   -> Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig
   -> RuleCondition)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe SourceIpConditionConfig
      -> Maybe HttpRequestMethodConditionConfig
      -> Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig
      -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Values" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String
  (Maybe SourceIpConditionConfig
   -> Maybe HttpRequestMethodConditionConfig
   -> Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig
   -> RuleCondition)
-> Either String (Maybe SourceIpConditionConfig)
-> Either
     String
     (Maybe HttpRequestMethodConditionConfig
      -> Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig
      -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe SourceIpConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceIpConfig")
      Either
  String
  (Maybe HttpRequestMethodConditionConfig
   -> Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig
   -> RuleCondition)
-> Either String (Maybe HttpRequestMethodConditionConfig)
-> Either
     String
     (Maybe PathPatternConditionConfig
      -> Maybe QueryStringConditionConfig -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String (Maybe HttpRequestMethodConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HttpRequestMethodConfig")
      Either
  String
  (Maybe PathPatternConditionConfig
   -> Maybe QueryStringConditionConfig -> RuleCondition)
-> Either String (Maybe PathPatternConditionConfig)
-> Either
     String (Maybe QueryStringConditionConfig -> RuleCondition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe PathPatternConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PathPatternConfig")
      Either String (Maybe QueryStringConditionConfig -> RuleCondition)
-> Either String (Maybe QueryStringConditionConfig)
-> Either String RuleCondition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe QueryStringConditionConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"QueryStringConfig")

instance Prelude.Hashable RuleCondition

instance Prelude.NFData RuleCondition

instance Core.ToQuery RuleCondition where
  toQuery :: RuleCondition -> QueryString
toQuery RuleCondition' {Maybe [Text]
Maybe Text
Maybe HostHeaderConditionConfig
Maybe HttpHeaderConditionConfig
Maybe HttpRequestMethodConditionConfig
Maybe PathPatternConditionConfig
Maybe QueryStringConditionConfig
Maybe SourceIpConditionConfig
queryStringConfig :: Maybe QueryStringConditionConfig
pathPatternConfig :: Maybe PathPatternConditionConfig
httpRequestMethodConfig :: Maybe HttpRequestMethodConditionConfig
sourceIpConfig :: Maybe SourceIpConditionConfig
values :: Maybe [Text]
hostHeaderConfig :: Maybe HostHeaderConditionConfig
httpHeaderConfig :: Maybe HttpHeaderConditionConfig
field :: Maybe Text
$sel:queryStringConfig:RuleCondition' :: RuleCondition -> Maybe QueryStringConditionConfig
$sel:pathPatternConfig:RuleCondition' :: RuleCondition -> Maybe PathPatternConditionConfig
$sel:httpRequestMethodConfig:RuleCondition' :: RuleCondition -> Maybe HttpRequestMethodConditionConfig
$sel:sourceIpConfig:RuleCondition' :: RuleCondition -> Maybe SourceIpConditionConfig
$sel:values:RuleCondition' :: RuleCondition -> Maybe [Text]
$sel:hostHeaderConfig:RuleCondition' :: RuleCondition -> Maybe HostHeaderConditionConfig
$sel:httpHeaderConfig:RuleCondition' :: RuleCondition -> Maybe HttpHeaderConditionConfig
$sel:field:RuleCondition' :: RuleCondition -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Field" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
field,
        ByteString
"HttpHeaderConfig" ByteString -> Maybe HttpHeaderConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe HttpHeaderConditionConfig
httpHeaderConfig,
        ByteString
"HostHeaderConfig" ByteString -> Maybe HostHeaderConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe HostHeaderConditionConfig
hostHeaderConfig,
        ByteString
"Values"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
values),
        ByteString
"SourceIpConfig" ByteString -> Maybe SourceIpConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe SourceIpConditionConfig
sourceIpConfig,
        ByteString
"HttpRequestMethodConfig"
          ByteString -> Maybe HttpRequestMethodConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe HttpRequestMethodConditionConfig
httpRequestMethodConfig,
        ByteString
"PathPatternConfig" ByteString -> Maybe PathPatternConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PathPatternConditionConfig
pathPatternConfig,
        ByteString
"QueryStringConfig" ByteString -> Maybe QueryStringConditionConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryStringConditionConfig
queryStringConfig
      ]