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

-- | Information about a host header condition.
--
-- /See:/ 'newHostHeaderConditionConfig' smart constructor.
data HostHeaderConditionConfig = HostHeaderConditionConfig'
  { -- | The host names. The maximum size of each name is 128 characters. The
    -- comparison is case insensitive. 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
    -- the strings matches the host name.
    HostHeaderConditionConfig -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text]
  }
  deriving (HostHeaderConditionConfig -> HostHeaderConditionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HostHeaderConditionConfig -> HostHeaderConditionConfig -> Bool
$c/= :: HostHeaderConditionConfig -> HostHeaderConditionConfig -> Bool
== :: HostHeaderConditionConfig -> HostHeaderConditionConfig -> Bool
$c== :: HostHeaderConditionConfig -> HostHeaderConditionConfig -> Bool
Prelude.Eq, ReadPrec [HostHeaderConditionConfig]
ReadPrec HostHeaderConditionConfig
Int -> ReadS HostHeaderConditionConfig
ReadS [HostHeaderConditionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HostHeaderConditionConfig]
$creadListPrec :: ReadPrec [HostHeaderConditionConfig]
readPrec :: ReadPrec HostHeaderConditionConfig
$creadPrec :: ReadPrec HostHeaderConditionConfig
readList :: ReadS [HostHeaderConditionConfig]
$creadList :: ReadS [HostHeaderConditionConfig]
readsPrec :: Int -> ReadS HostHeaderConditionConfig
$creadsPrec :: Int -> ReadS HostHeaderConditionConfig
Prelude.Read, Int -> HostHeaderConditionConfig -> ShowS
[HostHeaderConditionConfig] -> ShowS
HostHeaderConditionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HostHeaderConditionConfig] -> ShowS
$cshowList :: [HostHeaderConditionConfig] -> ShowS
show :: HostHeaderConditionConfig -> String
$cshow :: HostHeaderConditionConfig -> String
showsPrec :: Int -> HostHeaderConditionConfig -> ShowS
$cshowsPrec :: Int -> HostHeaderConditionConfig -> ShowS
Prelude.Show, forall x.
Rep HostHeaderConditionConfig x -> HostHeaderConditionConfig
forall x.
HostHeaderConditionConfig -> Rep HostHeaderConditionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HostHeaderConditionConfig x -> HostHeaderConditionConfig
$cfrom :: forall x.
HostHeaderConditionConfig -> Rep HostHeaderConditionConfig x
Prelude.Generic)

-- |
-- Create a value of 'HostHeaderConditionConfig' 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', 'hostHeaderConditionConfig_values' - The host names. The maximum size of each name is 128 characters. The
-- comparison is case insensitive. 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
-- the strings matches the host name.
newHostHeaderConditionConfig ::
  HostHeaderConditionConfig
newHostHeaderConditionConfig :: HostHeaderConditionConfig
newHostHeaderConditionConfig =
  HostHeaderConditionConfig'
    { $sel:values:HostHeaderConditionConfig' :: Maybe [Text]
values =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The host names. The maximum size of each name is 128 characters. The
-- comparison is case insensitive. 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
-- the strings matches the host name.
hostHeaderConditionConfig_values :: Lens.Lens' HostHeaderConditionConfig (Prelude.Maybe [Prelude.Text])
hostHeaderConditionConfig_values :: Lens' HostHeaderConditionConfig (Maybe [Text])
hostHeaderConditionConfig_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostHeaderConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:HostHeaderConditionConfig' :: HostHeaderConditionConfig -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: HostHeaderConditionConfig
s@HostHeaderConditionConfig' {} Maybe [Text]
a -> HostHeaderConditionConfig
s {$sel:values:HostHeaderConditionConfig' :: Maybe [Text]
values = Maybe [Text]
a} :: HostHeaderConditionConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML HostHeaderConditionConfig where
  parseXML :: [Node] -> Either String HostHeaderConditionConfig
parseXML [Node]
x =
    Maybe [Text] -> HostHeaderConditionConfig
HostHeaderConditionConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Values"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                  )

instance Prelude.Hashable HostHeaderConditionConfig where
  hashWithSalt :: Int -> HostHeaderConditionConfig -> Int
hashWithSalt Int
_salt HostHeaderConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:HostHeaderConditionConfig' :: HostHeaderConditionConfig -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values

instance Prelude.NFData HostHeaderConditionConfig where
  rnf :: HostHeaderConditionConfig -> ()
rnf HostHeaderConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:HostHeaderConditionConfig' :: HostHeaderConditionConfig -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values

instance Data.ToQuery HostHeaderConditionConfig where
  toQuery :: HostHeaderConditionConfig -> QueryString
toQuery HostHeaderConditionConfig' {Maybe [Text]
values :: Maybe [Text]
$sel:values:HostHeaderConditionConfig' :: HostHeaderConditionConfig -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Values"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
values)
      ]