{-# 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.AppMesh.Types.GatewayRouteHostnameMatch
-- 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.AppMesh.Types.GatewayRouteHostnameMatch where

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

-- | An object representing the gateway route host name to match.
--
-- /See:/ 'newGatewayRouteHostnameMatch' smart constructor.
data GatewayRouteHostnameMatch = GatewayRouteHostnameMatch'
  { -- | The specified ending characters of the host name to match on.
    GatewayRouteHostnameMatch -> Maybe Text
suffix :: Prelude.Maybe Prelude.Text,
    -- | The exact host name to match on.
    GatewayRouteHostnameMatch -> Maybe Text
exact :: Prelude.Maybe Prelude.Text
  }
  deriving (GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool
(GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool)
-> (GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool)
-> Eq GatewayRouteHostnameMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool
$c/= :: GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool
== :: GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool
$c== :: GatewayRouteHostnameMatch -> GatewayRouteHostnameMatch -> Bool
Prelude.Eq, ReadPrec [GatewayRouteHostnameMatch]
ReadPrec GatewayRouteHostnameMatch
Int -> ReadS GatewayRouteHostnameMatch
ReadS [GatewayRouteHostnameMatch]
(Int -> ReadS GatewayRouteHostnameMatch)
-> ReadS [GatewayRouteHostnameMatch]
-> ReadPrec GatewayRouteHostnameMatch
-> ReadPrec [GatewayRouteHostnameMatch]
-> Read GatewayRouteHostnameMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GatewayRouteHostnameMatch]
$creadListPrec :: ReadPrec [GatewayRouteHostnameMatch]
readPrec :: ReadPrec GatewayRouteHostnameMatch
$creadPrec :: ReadPrec GatewayRouteHostnameMatch
readList :: ReadS [GatewayRouteHostnameMatch]
$creadList :: ReadS [GatewayRouteHostnameMatch]
readsPrec :: Int -> ReadS GatewayRouteHostnameMatch
$creadsPrec :: Int -> ReadS GatewayRouteHostnameMatch
Prelude.Read, Int -> GatewayRouteHostnameMatch -> ShowS
[GatewayRouteHostnameMatch] -> ShowS
GatewayRouteHostnameMatch -> String
(Int -> GatewayRouteHostnameMatch -> ShowS)
-> (GatewayRouteHostnameMatch -> String)
-> ([GatewayRouteHostnameMatch] -> ShowS)
-> Show GatewayRouteHostnameMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GatewayRouteHostnameMatch] -> ShowS
$cshowList :: [GatewayRouteHostnameMatch] -> ShowS
show :: GatewayRouteHostnameMatch -> String
$cshow :: GatewayRouteHostnameMatch -> String
showsPrec :: Int -> GatewayRouteHostnameMatch -> ShowS
$cshowsPrec :: Int -> GatewayRouteHostnameMatch -> ShowS
Prelude.Show, (forall x.
 GatewayRouteHostnameMatch -> Rep GatewayRouteHostnameMatch x)
-> (forall x.
    Rep GatewayRouteHostnameMatch x -> GatewayRouteHostnameMatch)
-> Generic GatewayRouteHostnameMatch
forall x.
Rep GatewayRouteHostnameMatch x -> GatewayRouteHostnameMatch
forall x.
GatewayRouteHostnameMatch -> Rep GatewayRouteHostnameMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GatewayRouteHostnameMatch x -> GatewayRouteHostnameMatch
$cfrom :: forall x.
GatewayRouteHostnameMatch -> Rep GatewayRouteHostnameMatch x
Prelude.Generic)

-- |
-- Create a value of 'GatewayRouteHostnameMatch' 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:
--
-- 'suffix', 'gatewayRouteHostnameMatch_suffix' - The specified ending characters of the host name to match on.
--
-- 'exact', 'gatewayRouteHostnameMatch_exact' - The exact host name to match on.
newGatewayRouteHostnameMatch ::
  GatewayRouteHostnameMatch
newGatewayRouteHostnameMatch :: GatewayRouteHostnameMatch
newGatewayRouteHostnameMatch =
  GatewayRouteHostnameMatch' :: Maybe Text -> Maybe Text -> GatewayRouteHostnameMatch
GatewayRouteHostnameMatch'
    { $sel:suffix:GatewayRouteHostnameMatch' :: Maybe Text
suffix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exact:GatewayRouteHostnameMatch' :: Maybe Text
exact = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The specified ending characters of the host name to match on.
gatewayRouteHostnameMatch_suffix :: Lens.Lens' GatewayRouteHostnameMatch (Prelude.Maybe Prelude.Text)
gatewayRouteHostnameMatch_suffix :: (Maybe Text -> f (Maybe Text))
-> GatewayRouteHostnameMatch -> f GatewayRouteHostnameMatch
gatewayRouteHostnameMatch_suffix = (GatewayRouteHostnameMatch -> Maybe Text)
-> (GatewayRouteHostnameMatch
    -> Maybe Text -> GatewayRouteHostnameMatch)
-> Lens
     GatewayRouteHostnameMatch
     GatewayRouteHostnameMatch
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayRouteHostnameMatch' {Maybe Text
suffix :: Maybe Text
$sel:suffix:GatewayRouteHostnameMatch' :: GatewayRouteHostnameMatch -> Maybe Text
suffix} -> Maybe Text
suffix) (\s :: GatewayRouteHostnameMatch
s@GatewayRouteHostnameMatch' {} Maybe Text
a -> GatewayRouteHostnameMatch
s {$sel:suffix:GatewayRouteHostnameMatch' :: Maybe Text
suffix = Maybe Text
a} :: GatewayRouteHostnameMatch)

-- | The exact host name to match on.
gatewayRouteHostnameMatch_exact :: Lens.Lens' GatewayRouteHostnameMatch (Prelude.Maybe Prelude.Text)
gatewayRouteHostnameMatch_exact :: (Maybe Text -> f (Maybe Text))
-> GatewayRouteHostnameMatch -> f GatewayRouteHostnameMatch
gatewayRouteHostnameMatch_exact = (GatewayRouteHostnameMatch -> Maybe Text)
-> (GatewayRouteHostnameMatch
    -> Maybe Text -> GatewayRouteHostnameMatch)
-> Lens
     GatewayRouteHostnameMatch
     GatewayRouteHostnameMatch
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayRouteHostnameMatch' {Maybe Text
exact :: Maybe Text
$sel:exact:GatewayRouteHostnameMatch' :: GatewayRouteHostnameMatch -> Maybe Text
exact} -> Maybe Text
exact) (\s :: GatewayRouteHostnameMatch
s@GatewayRouteHostnameMatch' {} Maybe Text
a -> GatewayRouteHostnameMatch
s {$sel:exact:GatewayRouteHostnameMatch' :: Maybe Text
exact = Maybe Text
a} :: GatewayRouteHostnameMatch)

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

instance Prelude.Hashable GatewayRouteHostnameMatch

instance Prelude.NFData GatewayRouteHostnameMatch

instance Core.ToJSON GatewayRouteHostnameMatch where
  toJSON :: GatewayRouteHostnameMatch -> Value
toJSON GatewayRouteHostnameMatch' {Maybe Text
exact :: Maybe Text
suffix :: Maybe Text
$sel:exact:GatewayRouteHostnameMatch' :: GatewayRouteHostnameMatch -> Maybe Text
$sel:suffix:GatewayRouteHostnameMatch' :: GatewayRouteHostnameMatch -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"suffix" 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
suffix,
            (Text
"exact" 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
exact
          ]
      )