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

import Amazonka.AppMesh.Types.GatewayRouteHostnameRewrite
import Amazonka.AppMesh.Types.HttpGatewayRoutePathRewrite
import Amazonka.AppMesh.Types.HttpGatewayRoutePrefixRewrite
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing the gateway route to rewrite.
--
-- /See:/ 'newHttpGatewayRouteRewrite' smart constructor.
data HttpGatewayRouteRewrite = HttpGatewayRouteRewrite'
  { -- | The host name to rewrite.
    HttpGatewayRouteRewrite -> Maybe GatewayRouteHostnameRewrite
hostname :: Prelude.Maybe GatewayRouteHostnameRewrite,
    -- | The path to rewrite.
    HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePathRewrite
path :: Prelude.Maybe HttpGatewayRoutePathRewrite,
    -- | The specified beginning characters to rewrite.
    HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePrefixRewrite
prefix :: Prelude.Maybe HttpGatewayRoutePrefixRewrite
  }
  deriving (HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool
(HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool)
-> (HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool)
-> Eq HttpGatewayRouteRewrite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool
$c/= :: HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool
== :: HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool
$c== :: HttpGatewayRouteRewrite -> HttpGatewayRouteRewrite -> Bool
Prelude.Eq, ReadPrec [HttpGatewayRouteRewrite]
ReadPrec HttpGatewayRouteRewrite
Int -> ReadS HttpGatewayRouteRewrite
ReadS [HttpGatewayRouteRewrite]
(Int -> ReadS HttpGatewayRouteRewrite)
-> ReadS [HttpGatewayRouteRewrite]
-> ReadPrec HttpGatewayRouteRewrite
-> ReadPrec [HttpGatewayRouteRewrite]
-> Read HttpGatewayRouteRewrite
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpGatewayRouteRewrite]
$creadListPrec :: ReadPrec [HttpGatewayRouteRewrite]
readPrec :: ReadPrec HttpGatewayRouteRewrite
$creadPrec :: ReadPrec HttpGatewayRouteRewrite
readList :: ReadS [HttpGatewayRouteRewrite]
$creadList :: ReadS [HttpGatewayRouteRewrite]
readsPrec :: Int -> ReadS HttpGatewayRouteRewrite
$creadsPrec :: Int -> ReadS HttpGatewayRouteRewrite
Prelude.Read, Int -> HttpGatewayRouteRewrite -> ShowS
[HttpGatewayRouteRewrite] -> ShowS
HttpGatewayRouteRewrite -> String
(Int -> HttpGatewayRouteRewrite -> ShowS)
-> (HttpGatewayRouteRewrite -> String)
-> ([HttpGatewayRouteRewrite] -> ShowS)
-> Show HttpGatewayRouteRewrite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpGatewayRouteRewrite] -> ShowS
$cshowList :: [HttpGatewayRouteRewrite] -> ShowS
show :: HttpGatewayRouteRewrite -> String
$cshow :: HttpGatewayRouteRewrite -> String
showsPrec :: Int -> HttpGatewayRouteRewrite -> ShowS
$cshowsPrec :: Int -> HttpGatewayRouteRewrite -> ShowS
Prelude.Show, (forall x.
 HttpGatewayRouteRewrite -> Rep HttpGatewayRouteRewrite x)
-> (forall x.
    Rep HttpGatewayRouteRewrite x -> HttpGatewayRouteRewrite)
-> Generic HttpGatewayRouteRewrite
forall x. Rep HttpGatewayRouteRewrite x -> HttpGatewayRouteRewrite
forall x. HttpGatewayRouteRewrite -> Rep HttpGatewayRouteRewrite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpGatewayRouteRewrite x -> HttpGatewayRouteRewrite
$cfrom :: forall x. HttpGatewayRouteRewrite -> Rep HttpGatewayRouteRewrite x
Prelude.Generic)

-- |
-- Create a value of 'HttpGatewayRouteRewrite' 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:
--
-- 'hostname', 'httpGatewayRouteRewrite_hostname' - The host name to rewrite.
--
-- 'path', 'httpGatewayRouteRewrite_path' - The path to rewrite.
--
-- 'prefix', 'httpGatewayRouteRewrite_prefix' - The specified beginning characters to rewrite.
newHttpGatewayRouteRewrite ::
  HttpGatewayRouteRewrite
newHttpGatewayRouteRewrite :: HttpGatewayRouteRewrite
newHttpGatewayRouteRewrite =
  HttpGatewayRouteRewrite' :: Maybe GatewayRouteHostnameRewrite
-> Maybe HttpGatewayRoutePathRewrite
-> Maybe HttpGatewayRoutePrefixRewrite
-> HttpGatewayRouteRewrite
HttpGatewayRouteRewrite'
    { $sel:hostname:HttpGatewayRouteRewrite' :: Maybe GatewayRouteHostnameRewrite
hostname =
        Maybe GatewayRouteHostnameRewrite
forall a. Maybe a
Prelude.Nothing,
      $sel:path:HttpGatewayRouteRewrite' :: Maybe HttpGatewayRoutePathRewrite
path = Maybe HttpGatewayRoutePathRewrite
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:HttpGatewayRouteRewrite' :: Maybe HttpGatewayRoutePrefixRewrite
prefix = Maybe HttpGatewayRoutePrefixRewrite
forall a. Maybe a
Prelude.Nothing
    }

-- | The host name to rewrite.
httpGatewayRouteRewrite_hostname :: Lens.Lens' HttpGatewayRouteRewrite (Prelude.Maybe GatewayRouteHostnameRewrite)
httpGatewayRouteRewrite_hostname :: (Maybe GatewayRouteHostnameRewrite
 -> f (Maybe GatewayRouteHostnameRewrite))
-> HttpGatewayRouteRewrite -> f HttpGatewayRouteRewrite
httpGatewayRouteRewrite_hostname = (HttpGatewayRouteRewrite -> Maybe GatewayRouteHostnameRewrite)
-> (HttpGatewayRouteRewrite
    -> Maybe GatewayRouteHostnameRewrite -> HttpGatewayRouteRewrite)
-> Lens
     HttpGatewayRouteRewrite
     HttpGatewayRouteRewrite
     (Maybe GatewayRouteHostnameRewrite)
     (Maybe GatewayRouteHostnameRewrite)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteRewrite' {Maybe GatewayRouteHostnameRewrite
hostname :: Maybe GatewayRouteHostnameRewrite
$sel:hostname:HttpGatewayRouteRewrite' :: HttpGatewayRouteRewrite -> Maybe GatewayRouteHostnameRewrite
hostname} -> Maybe GatewayRouteHostnameRewrite
hostname) (\s :: HttpGatewayRouteRewrite
s@HttpGatewayRouteRewrite' {} Maybe GatewayRouteHostnameRewrite
a -> HttpGatewayRouteRewrite
s {$sel:hostname:HttpGatewayRouteRewrite' :: Maybe GatewayRouteHostnameRewrite
hostname = Maybe GatewayRouteHostnameRewrite
a} :: HttpGatewayRouteRewrite)

-- | The path to rewrite.
httpGatewayRouteRewrite_path :: Lens.Lens' HttpGatewayRouteRewrite (Prelude.Maybe HttpGatewayRoutePathRewrite)
httpGatewayRouteRewrite_path :: (Maybe HttpGatewayRoutePathRewrite
 -> f (Maybe HttpGatewayRoutePathRewrite))
-> HttpGatewayRouteRewrite -> f HttpGatewayRouteRewrite
httpGatewayRouteRewrite_path = (HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePathRewrite)
-> (HttpGatewayRouteRewrite
    -> Maybe HttpGatewayRoutePathRewrite -> HttpGatewayRouteRewrite)
-> Lens
     HttpGatewayRouteRewrite
     HttpGatewayRouteRewrite
     (Maybe HttpGatewayRoutePathRewrite)
     (Maybe HttpGatewayRoutePathRewrite)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteRewrite' {Maybe HttpGatewayRoutePathRewrite
path :: Maybe HttpGatewayRoutePathRewrite
$sel:path:HttpGatewayRouteRewrite' :: HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePathRewrite
path} -> Maybe HttpGatewayRoutePathRewrite
path) (\s :: HttpGatewayRouteRewrite
s@HttpGatewayRouteRewrite' {} Maybe HttpGatewayRoutePathRewrite
a -> HttpGatewayRouteRewrite
s {$sel:path:HttpGatewayRouteRewrite' :: Maybe HttpGatewayRoutePathRewrite
path = Maybe HttpGatewayRoutePathRewrite
a} :: HttpGatewayRouteRewrite)

-- | The specified beginning characters to rewrite.
httpGatewayRouteRewrite_prefix :: Lens.Lens' HttpGatewayRouteRewrite (Prelude.Maybe HttpGatewayRoutePrefixRewrite)
httpGatewayRouteRewrite_prefix :: (Maybe HttpGatewayRoutePrefixRewrite
 -> f (Maybe HttpGatewayRoutePrefixRewrite))
-> HttpGatewayRouteRewrite -> f HttpGatewayRouteRewrite
httpGatewayRouteRewrite_prefix = (HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePrefixRewrite)
-> (HttpGatewayRouteRewrite
    -> Maybe HttpGatewayRoutePrefixRewrite -> HttpGatewayRouteRewrite)
-> Lens
     HttpGatewayRouteRewrite
     HttpGatewayRouteRewrite
     (Maybe HttpGatewayRoutePrefixRewrite)
     (Maybe HttpGatewayRoutePrefixRewrite)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRouteRewrite' {Maybe HttpGatewayRoutePrefixRewrite
prefix :: Maybe HttpGatewayRoutePrefixRewrite
$sel:prefix:HttpGatewayRouteRewrite' :: HttpGatewayRouteRewrite -> Maybe HttpGatewayRoutePrefixRewrite
prefix} -> Maybe HttpGatewayRoutePrefixRewrite
prefix) (\s :: HttpGatewayRouteRewrite
s@HttpGatewayRouteRewrite' {} Maybe HttpGatewayRoutePrefixRewrite
a -> HttpGatewayRouteRewrite
s {$sel:prefix:HttpGatewayRouteRewrite' :: Maybe HttpGatewayRoutePrefixRewrite
prefix = Maybe HttpGatewayRoutePrefixRewrite
a} :: HttpGatewayRouteRewrite)

instance Core.FromJSON HttpGatewayRouteRewrite where
  parseJSON :: Value -> Parser HttpGatewayRouteRewrite
parseJSON =
    String
-> (Object -> Parser HttpGatewayRouteRewrite)
-> Value
-> Parser HttpGatewayRouteRewrite
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpGatewayRouteRewrite"
      ( \Object
x ->
          Maybe GatewayRouteHostnameRewrite
-> Maybe HttpGatewayRoutePathRewrite
-> Maybe HttpGatewayRoutePrefixRewrite
-> HttpGatewayRouteRewrite
HttpGatewayRouteRewrite'
            (Maybe GatewayRouteHostnameRewrite
 -> Maybe HttpGatewayRoutePathRewrite
 -> Maybe HttpGatewayRoutePrefixRewrite
 -> HttpGatewayRouteRewrite)
-> Parser (Maybe GatewayRouteHostnameRewrite)
-> Parser
     (Maybe HttpGatewayRoutePathRewrite
      -> Maybe HttpGatewayRoutePrefixRewrite -> HttpGatewayRouteRewrite)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GatewayRouteHostnameRewrite)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hostname")
            Parser
  (Maybe HttpGatewayRoutePathRewrite
   -> Maybe HttpGatewayRoutePrefixRewrite -> HttpGatewayRouteRewrite)
-> Parser (Maybe HttpGatewayRoutePathRewrite)
-> Parser
     (Maybe HttpGatewayRoutePrefixRewrite -> HttpGatewayRouteRewrite)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpGatewayRoutePathRewrite)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"path")
            Parser
  (Maybe HttpGatewayRoutePrefixRewrite -> HttpGatewayRouteRewrite)
-> Parser (Maybe HttpGatewayRoutePrefixRewrite)
-> Parser HttpGatewayRouteRewrite
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe HttpGatewayRoutePrefixRewrite)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"prefix")
      )

instance Prelude.Hashable HttpGatewayRouteRewrite

instance Prelude.NFData HttpGatewayRouteRewrite

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