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

import Amazonka.AppMesh.Types.DefaultGatewayRouteRewrite
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 rewrite.
--
-- /See:/ 'newGatewayRouteHostnameRewrite' smart constructor.
data GatewayRouteHostnameRewrite = GatewayRouteHostnameRewrite'
  { -- | The default target host name to write to.
    GatewayRouteHostnameRewrite -> Maybe DefaultGatewayRouteRewrite
defaultTargetHostname :: Prelude.Maybe DefaultGatewayRouteRewrite
  }
  deriving (GatewayRouteHostnameRewrite -> GatewayRouteHostnameRewrite -> Bool
(GatewayRouteHostnameRewrite
 -> GatewayRouteHostnameRewrite -> Bool)
-> (GatewayRouteHostnameRewrite
    -> GatewayRouteHostnameRewrite -> Bool)
-> Eq GatewayRouteHostnameRewrite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GatewayRouteHostnameRewrite -> GatewayRouteHostnameRewrite -> Bool
$c/= :: GatewayRouteHostnameRewrite -> GatewayRouteHostnameRewrite -> Bool
== :: GatewayRouteHostnameRewrite -> GatewayRouteHostnameRewrite -> Bool
$c== :: GatewayRouteHostnameRewrite -> GatewayRouteHostnameRewrite -> Bool
Prelude.Eq, ReadPrec [GatewayRouteHostnameRewrite]
ReadPrec GatewayRouteHostnameRewrite
Int -> ReadS GatewayRouteHostnameRewrite
ReadS [GatewayRouteHostnameRewrite]
(Int -> ReadS GatewayRouteHostnameRewrite)
-> ReadS [GatewayRouteHostnameRewrite]
-> ReadPrec GatewayRouteHostnameRewrite
-> ReadPrec [GatewayRouteHostnameRewrite]
-> Read GatewayRouteHostnameRewrite
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GatewayRouteHostnameRewrite]
$creadListPrec :: ReadPrec [GatewayRouteHostnameRewrite]
readPrec :: ReadPrec GatewayRouteHostnameRewrite
$creadPrec :: ReadPrec GatewayRouteHostnameRewrite
readList :: ReadS [GatewayRouteHostnameRewrite]
$creadList :: ReadS [GatewayRouteHostnameRewrite]
readsPrec :: Int -> ReadS GatewayRouteHostnameRewrite
$creadsPrec :: Int -> ReadS GatewayRouteHostnameRewrite
Prelude.Read, Int -> GatewayRouteHostnameRewrite -> ShowS
[GatewayRouteHostnameRewrite] -> ShowS
GatewayRouteHostnameRewrite -> String
(Int -> GatewayRouteHostnameRewrite -> ShowS)
-> (GatewayRouteHostnameRewrite -> String)
-> ([GatewayRouteHostnameRewrite] -> ShowS)
-> Show GatewayRouteHostnameRewrite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GatewayRouteHostnameRewrite] -> ShowS
$cshowList :: [GatewayRouteHostnameRewrite] -> ShowS
show :: GatewayRouteHostnameRewrite -> String
$cshow :: GatewayRouteHostnameRewrite -> String
showsPrec :: Int -> GatewayRouteHostnameRewrite -> ShowS
$cshowsPrec :: Int -> GatewayRouteHostnameRewrite -> ShowS
Prelude.Show, (forall x.
 GatewayRouteHostnameRewrite -> Rep GatewayRouteHostnameRewrite x)
-> (forall x.
    Rep GatewayRouteHostnameRewrite x -> GatewayRouteHostnameRewrite)
-> Generic GatewayRouteHostnameRewrite
forall x.
Rep GatewayRouteHostnameRewrite x -> GatewayRouteHostnameRewrite
forall x.
GatewayRouteHostnameRewrite -> Rep GatewayRouteHostnameRewrite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GatewayRouteHostnameRewrite x -> GatewayRouteHostnameRewrite
$cfrom :: forall x.
GatewayRouteHostnameRewrite -> Rep GatewayRouteHostnameRewrite x
Prelude.Generic)

-- |
-- Create a value of 'GatewayRouteHostnameRewrite' 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:
--
-- 'defaultTargetHostname', 'gatewayRouteHostnameRewrite_defaultTargetHostname' - The default target host name to write to.
newGatewayRouteHostnameRewrite ::
  GatewayRouteHostnameRewrite
newGatewayRouteHostnameRewrite :: GatewayRouteHostnameRewrite
newGatewayRouteHostnameRewrite =
  GatewayRouteHostnameRewrite' :: Maybe DefaultGatewayRouteRewrite -> GatewayRouteHostnameRewrite
GatewayRouteHostnameRewrite'
    { $sel:defaultTargetHostname:GatewayRouteHostnameRewrite' :: Maybe DefaultGatewayRouteRewrite
defaultTargetHostname =
        Maybe DefaultGatewayRouteRewrite
forall a. Maybe a
Prelude.Nothing
    }

-- | The default target host name to write to.
gatewayRouteHostnameRewrite_defaultTargetHostname :: Lens.Lens' GatewayRouteHostnameRewrite (Prelude.Maybe DefaultGatewayRouteRewrite)
gatewayRouteHostnameRewrite_defaultTargetHostname :: (Maybe DefaultGatewayRouteRewrite
 -> f (Maybe DefaultGatewayRouteRewrite))
-> GatewayRouteHostnameRewrite -> f GatewayRouteHostnameRewrite
gatewayRouteHostnameRewrite_defaultTargetHostname = (GatewayRouteHostnameRewrite -> Maybe DefaultGatewayRouteRewrite)
-> (GatewayRouteHostnameRewrite
    -> Maybe DefaultGatewayRouteRewrite -> GatewayRouteHostnameRewrite)
-> Lens
     GatewayRouteHostnameRewrite
     GatewayRouteHostnameRewrite
     (Maybe DefaultGatewayRouteRewrite)
     (Maybe DefaultGatewayRouteRewrite)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayRouteHostnameRewrite' {Maybe DefaultGatewayRouteRewrite
defaultTargetHostname :: Maybe DefaultGatewayRouteRewrite
$sel:defaultTargetHostname:GatewayRouteHostnameRewrite' :: GatewayRouteHostnameRewrite -> Maybe DefaultGatewayRouteRewrite
defaultTargetHostname} -> Maybe DefaultGatewayRouteRewrite
defaultTargetHostname) (\s :: GatewayRouteHostnameRewrite
s@GatewayRouteHostnameRewrite' {} Maybe DefaultGatewayRouteRewrite
a -> GatewayRouteHostnameRewrite
s {$sel:defaultTargetHostname:GatewayRouteHostnameRewrite' :: Maybe DefaultGatewayRouteRewrite
defaultTargetHostname = Maybe DefaultGatewayRouteRewrite
a} :: GatewayRouteHostnameRewrite)

instance Core.FromJSON GatewayRouteHostnameRewrite where
  parseJSON :: Value -> Parser GatewayRouteHostnameRewrite
parseJSON =
    String
-> (Object -> Parser GatewayRouteHostnameRewrite)
-> Value
-> Parser GatewayRouteHostnameRewrite
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GatewayRouteHostnameRewrite"
      ( \Object
x ->
          Maybe DefaultGatewayRouteRewrite -> GatewayRouteHostnameRewrite
GatewayRouteHostnameRewrite'
            (Maybe DefaultGatewayRouteRewrite -> GatewayRouteHostnameRewrite)
-> Parser (Maybe DefaultGatewayRouteRewrite)
-> Parser GatewayRouteHostnameRewrite
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DefaultGatewayRouteRewrite)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"defaultTargetHostname")
      )

instance Prelude.Hashable GatewayRouteHostnameRewrite

instance Prelude.NFData GatewayRouteHostnameRewrite

instance Core.ToJSON GatewayRouteHostnameRewrite where
  toJSON :: GatewayRouteHostnameRewrite -> Value
toJSON GatewayRouteHostnameRewrite' {Maybe DefaultGatewayRouteRewrite
defaultTargetHostname :: Maybe DefaultGatewayRouteRewrite
$sel:defaultTargetHostname:GatewayRouteHostnameRewrite' :: GatewayRouteHostnameRewrite -> Maybe DefaultGatewayRouteRewrite
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"defaultTargetHostname" Text -> DefaultGatewayRouteRewrite -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DefaultGatewayRouteRewrite -> Pair)
-> Maybe DefaultGatewayRouteRewrite -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DefaultGatewayRouteRewrite
defaultTargetHostname
          ]
      )