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

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

-- | Information about a path pattern condition.
--
-- /See:/ 'newPathPatternConditionConfig' smart constructor.
data PathPatternConditionConfig = PathPatternConditionConfig'
  { -- | One or more path patterns to compare against the request URL. The
    -- maximum size of each string is 128 characters. The comparison is case
    -- sensitive. The following wildcard characters are supported: * (matches 0
    -- or more characters) and ? (matches exactly 1 character).
    --
    -- If you specify multiple strings, the condition is satisfied if one of
    -- them matches the request URL. The path pattern is compared only to the
    -- path of the URL, not to its query string. To compare against the query
    -- string, use QueryStringConditionConfig.
    PathPatternConditionConfig -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (PathPatternConditionConfig -> PathPatternConditionConfig -> Bool
(PathPatternConditionConfig -> PathPatternConditionConfig -> Bool)
-> (PathPatternConditionConfig
    -> PathPatternConditionConfig -> Bool)
-> Eq PathPatternConditionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PathPatternConditionConfig -> PathPatternConditionConfig -> Bool
$c/= :: PathPatternConditionConfig -> PathPatternConditionConfig -> Bool
== :: PathPatternConditionConfig -> PathPatternConditionConfig -> Bool
$c== :: PathPatternConditionConfig -> PathPatternConditionConfig -> Bool
Prelude.Eq, ReadPrec [PathPatternConditionConfig]
ReadPrec PathPatternConditionConfig
Int -> ReadS PathPatternConditionConfig
ReadS [PathPatternConditionConfig]
(Int -> ReadS PathPatternConditionConfig)
-> ReadS [PathPatternConditionConfig]
-> ReadPrec PathPatternConditionConfig
-> ReadPrec [PathPatternConditionConfig]
-> Read PathPatternConditionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PathPatternConditionConfig]
$creadListPrec :: ReadPrec [PathPatternConditionConfig]
readPrec :: ReadPrec PathPatternConditionConfig
$creadPrec :: ReadPrec PathPatternConditionConfig
readList :: ReadS [PathPatternConditionConfig]
$creadList :: ReadS [PathPatternConditionConfig]
readsPrec :: Int -> ReadS PathPatternConditionConfig
$creadsPrec :: Int -> ReadS PathPatternConditionConfig
Prelude.Read, Int -> PathPatternConditionConfig -> ShowS
[PathPatternConditionConfig] -> ShowS
PathPatternConditionConfig -> String
(Int -> PathPatternConditionConfig -> ShowS)
-> (PathPatternConditionConfig -> String)
-> ([PathPatternConditionConfig] -> ShowS)
-> Show PathPatternConditionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PathPatternConditionConfig] -> ShowS
$cshowList :: [PathPatternConditionConfig] -> ShowS
show :: PathPatternConditionConfig -> String
$cshow :: PathPatternConditionConfig -> String
showsPrec :: Int -> PathPatternConditionConfig -> ShowS
$cshowsPrec :: Int -> PathPatternConditionConfig -> ShowS
Prelude.Show, (forall x.
 PathPatternConditionConfig -> Rep PathPatternConditionConfig x)
-> (forall x.
    Rep PathPatternConditionConfig x -> PathPatternConditionConfig)
-> Generic PathPatternConditionConfig
forall x.
Rep PathPatternConditionConfig x -> PathPatternConditionConfig
forall x.
PathPatternConditionConfig -> Rep PathPatternConditionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PathPatternConditionConfig x -> PathPatternConditionConfig
$cfrom :: forall x.
PathPatternConditionConfig -> Rep PathPatternConditionConfig x
Prelude.Generic)

-- |
-- Create a value of 'PathPatternConditionConfig' 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:
--
-- 'values', 'pathPatternConditionConfig_values' - One or more path patterns to compare against the request URL. The
-- maximum size of each string is 128 characters. The comparison is case
-- sensitive. The following wildcard characters are supported: * (matches 0
-- or more characters) and ? (matches exactly 1 character).
--
-- If you specify multiple strings, the condition is satisfied if one of
-- them matches the request URL. The path pattern is compared only to the
-- path of the URL, not to its query string. To compare against the query
-- string, use QueryStringConditionConfig.
newPathPatternConditionConfig ::
  PathPatternConditionConfig
newPathPatternConditionConfig :: PathPatternConditionConfig
newPathPatternConditionConfig =
  PathPatternConditionConfig' :: Maybe [Text] -> PathPatternConditionConfig
PathPatternConditionConfig'
    { $sel:values:PathPatternConditionConfig' :: Maybe [Text]
values =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more path patterns to compare against the request URL. The
-- maximum size of each string is 128 characters. The comparison is case
-- sensitive. The following wildcard characters are supported: * (matches 0
-- or more characters) and ? (matches exactly 1 character).
--
-- If you specify multiple strings, the condition is satisfied if one of
-- them matches the request URL. The path pattern is compared only to the
-- path of the URL, not to its query string. To compare against the query
-- string, use QueryStringConditionConfig.
pathPatternConditionConfig_values :: Lens.Lens' PathPatternConditionConfig (Prelude.Maybe [Prelude.Text])
pathPatternConditionConfig_values :: (Maybe [Text] -> f (Maybe [Text]))
-> PathPatternConditionConfig -> f PathPatternConditionConfig
pathPatternConditionConfig_values = (PathPatternConditionConfig -> Maybe [Text])
-> (PathPatternConditionConfig
    -> Maybe [Text] -> PathPatternConditionConfig)
-> Lens
     PathPatternConditionConfig
     PathPatternConditionConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathPatternConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:PathPatternConditionConfig' :: PathPatternConditionConfig -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: PathPatternConditionConfig
s@PathPatternConditionConfig' {} Maybe [Text]
a -> PathPatternConditionConfig
s {$sel:values:PathPatternConditionConfig' :: Maybe [Text]
values = Maybe [Text]
a} :: PathPatternConditionConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> PathPatternConditionConfig -> f PathPatternConditionConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PathPatternConditionConfig
-> f PathPatternConditionConfig
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

instance Core.FromXML PathPatternConditionConfig where
  parseXML :: [Node] -> Either String PathPatternConditionConfig
parseXML [Node]
x =
    Maybe [Text] -> PathPatternConditionConfig
PathPatternConditionConfig'
      (Maybe [Text] -> PathPatternConditionConfig)
-> Either String (Maybe [Text])
-> Either String PathPatternConditionConfig
forall (f :: * -> *) a b. Functor 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")
                  )

instance Prelude.Hashable PathPatternConditionConfig

instance Prelude.NFData PathPatternConditionConfig

instance Core.ToQuery PathPatternConditionConfig where
  toQuery :: PathPatternConditionConfig -> QueryString
toQuery PathPatternConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:PathPatternConditionConfig' :: PathPatternConditionConfig -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ 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)
      ]