{-# 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.HttpGatewayRoutePrefixRewrite
-- 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.HttpGatewayRoutePrefixRewrite 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 beginning characters of the route to rewrite.
--
-- /See:/ 'newHttpGatewayRoutePrefixRewrite' smart constructor.
data HttpGatewayRoutePrefixRewrite = HttpGatewayRoutePrefixRewrite'
  { -- | The value used to replace the incoming route prefix when rewritten.
    HttpGatewayRoutePrefixRewrite -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The default prefix used to replace the incoming route prefix when
    -- rewritten.
    HttpGatewayRoutePrefixRewrite -> Maybe DefaultGatewayRouteRewrite
defaultPrefix :: Prelude.Maybe DefaultGatewayRouteRewrite
  }
  deriving (HttpGatewayRoutePrefixRewrite
-> HttpGatewayRoutePrefixRewrite -> Bool
(HttpGatewayRoutePrefixRewrite
 -> HttpGatewayRoutePrefixRewrite -> Bool)
-> (HttpGatewayRoutePrefixRewrite
    -> HttpGatewayRoutePrefixRewrite -> Bool)
-> Eq HttpGatewayRoutePrefixRewrite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpGatewayRoutePrefixRewrite
-> HttpGatewayRoutePrefixRewrite -> Bool
$c/= :: HttpGatewayRoutePrefixRewrite
-> HttpGatewayRoutePrefixRewrite -> Bool
== :: HttpGatewayRoutePrefixRewrite
-> HttpGatewayRoutePrefixRewrite -> Bool
$c== :: HttpGatewayRoutePrefixRewrite
-> HttpGatewayRoutePrefixRewrite -> Bool
Prelude.Eq, ReadPrec [HttpGatewayRoutePrefixRewrite]
ReadPrec HttpGatewayRoutePrefixRewrite
Int -> ReadS HttpGatewayRoutePrefixRewrite
ReadS [HttpGatewayRoutePrefixRewrite]
(Int -> ReadS HttpGatewayRoutePrefixRewrite)
-> ReadS [HttpGatewayRoutePrefixRewrite]
-> ReadPrec HttpGatewayRoutePrefixRewrite
-> ReadPrec [HttpGatewayRoutePrefixRewrite]
-> Read HttpGatewayRoutePrefixRewrite
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpGatewayRoutePrefixRewrite]
$creadListPrec :: ReadPrec [HttpGatewayRoutePrefixRewrite]
readPrec :: ReadPrec HttpGatewayRoutePrefixRewrite
$creadPrec :: ReadPrec HttpGatewayRoutePrefixRewrite
readList :: ReadS [HttpGatewayRoutePrefixRewrite]
$creadList :: ReadS [HttpGatewayRoutePrefixRewrite]
readsPrec :: Int -> ReadS HttpGatewayRoutePrefixRewrite
$creadsPrec :: Int -> ReadS HttpGatewayRoutePrefixRewrite
Prelude.Read, Int -> HttpGatewayRoutePrefixRewrite -> ShowS
[HttpGatewayRoutePrefixRewrite] -> ShowS
HttpGatewayRoutePrefixRewrite -> String
(Int -> HttpGatewayRoutePrefixRewrite -> ShowS)
-> (HttpGatewayRoutePrefixRewrite -> String)
-> ([HttpGatewayRoutePrefixRewrite] -> ShowS)
-> Show HttpGatewayRoutePrefixRewrite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpGatewayRoutePrefixRewrite] -> ShowS
$cshowList :: [HttpGatewayRoutePrefixRewrite] -> ShowS
show :: HttpGatewayRoutePrefixRewrite -> String
$cshow :: HttpGatewayRoutePrefixRewrite -> String
showsPrec :: Int -> HttpGatewayRoutePrefixRewrite -> ShowS
$cshowsPrec :: Int -> HttpGatewayRoutePrefixRewrite -> ShowS
Prelude.Show, (forall x.
 HttpGatewayRoutePrefixRewrite
 -> Rep HttpGatewayRoutePrefixRewrite x)
-> (forall x.
    Rep HttpGatewayRoutePrefixRewrite x
    -> HttpGatewayRoutePrefixRewrite)
-> Generic HttpGatewayRoutePrefixRewrite
forall x.
Rep HttpGatewayRoutePrefixRewrite x
-> HttpGatewayRoutePrefixRewrite
forall x.
HttpGatewayRoutePrefixRewrite
-> Rep HttpGatewayRoutePrefixRewrite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HttpGatewayRoutePrefixRewrite x
-> HttpGatewayRoutePrefixRewrite
$cfrom :: forall x.
HttpGatewayRoutePrefixRewrite
-> Rep HttpGatewayRoutePrefixRewrite x
Prelude.Generic)

-- |
-- Create a value of 'HttpGatewayRoutePrefixRewrite' 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:
--
-- 'value', 'httpGatewayRoutePrefixRewrite_value' - The value used to replace the incoming route prefix when rewritten.
--
-- 'defaultPrefix', 'httpGatewayRoutePrefixRewrite_defaultPrefix' - The default prefix used to replace the incoming route prefix when
-- rewritten.
newHttpGatewayRoutePrefixRewrite ::
  HttpGatewayRoutePrefixRewrite
newHttpGatewayRoutePrefixRewrite :: HttpGatewayRoutePrefixRewrite
newHttpGatewayRoutePrefixRewrite =
  HttpGatewayRoutePrefixRewrite' :: Maybe Text
-> Maybe DefaultGatewayRouteRewrite
-> HttpGatewayRoutePrefixRewrite
HttpGatewayRoutePrefixRewrite'
    { $sel:value:HttpGatewayRoutePrefixRewrite' :: Maybe Text
value =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultPrefix:HttpGatewayRoutePrefixRewrite' :: Maybe DefaultGatewayRouteRewrite
defaultPrefix = Maybe DefaultGatewayRouteRewrite
forall a. Maybe a
Prelude.Nothing
    }

-- | The value used to replace the incoming route prefix when rewritten.
httpGatewayRoutePrefixRewrite_value :: Lens.Lens' HttpGatewayRoutePrefixRewrite (Prelude.Maybe Prelude.Text)
httpGatewayRoutePrefixRewrite_value :: (Maybe Text -> f (Maybe Text))
-> HttpGatewayRoutePrefixRewrite -> f HttpGatewayRoutePrefixRewrite
httpGatewayRoutePrefixRewrite_value = (HttpGatewayRoutePrefixRewrite -> Maybe Text)
-> (HttpGatewayRoutePrefixRewrite
    -> Maybe Text -> HttpGatewayRoutePrefixRewrite)
-> Lens
     HttpGatewayRoutePrefixRewrite
     HttpGatewayRoutePrefixRewrite
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRoutePrefixRewrite' {Maybe Text
value :: Maybe Text
$sel:value:HttpGatewayRoutePrefixRewrite' :: HttpGatewayRoutePrefixRewrite -> Maybe Text
value} -> Maybe Text
value) (\s :: HttpGatewayRoutePrefixRewrite
s@HttpGatewayRoutePrefixRewrite' {} Maybe Text
a -> HttpGatewayRoutePrefixRewrite
s {$sel:value:HttpGatewayRoutePrefixRewrite' :: Maybe Text
value = Maybe Text
a} :: HttpGatewayRoutePrefixRewrite)

-- | The default prefix used to replace the incoming route prefix when
-- rewritten.
httpGatewayRoutePrefixRewrite_defaultPrefix :: Lens.Lens' HttpGatewayRoutePrefixRewrite (Prelude.Maybe DefaultGatewayRouteRewrite)
httpGatewayRoutePrefixRewrite_defaultPrefix :: (Maybe DefaultGatewayRouteRewrite
 -> f (Maybe DefaultGatewayRouteRewrite))
-> HttpGatewayRoutePrefixRewrite -> f HttpGatewayRoutePrefixRewrite
httpGatewayRoutePrefixRewrite_defaultPrefix = (HttpGatewayRoutePrefixRewrite -> Maybe DefaultGatewayRouteRewrite)
-> (HttpGatewayRoutePrefixRewrite
    -> Maybe DefaultGatewayRouteRewrite
    -> HttpGatewayRoutePrefixRewrite)
-> Lens
     HttpGatewayRoutePrefixRewrite
     HttpGatewayRoutePrefixRewrite
     (Maybe DefaultGatewayRouteRewrite)
     (Maybe DefaultGatewayRouteRewrite)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpGatewayRoutePrefixRewrite' {Maybe DefaultGatewayRouteRewrite
defaultPrefix :: Maybe DefaultGatewayRouteRewrite
$sel:defaultPrefix:HttpGatewayRoutePrefixRewrite' :: HttpGatewayRoutePrefixRewrite -> Maybe DefaultGatewayRouteRewrite
defaultPrefix} -> Maybe DefaultGatewayRouteRewrite
defaultPrefix) (\s :: HttpGatewayRoutePrefixRewrite
s@HttpGatewayRoutePrefixRewrite' {} Maybe DefaultGatewayRouteRewrite
a -> HttpGatewayRoutePrefixRewrite
s {$sel:defaultPrefix:HttpGatewayRoutePrefixRewrite' :: Maybe DefaultGatewayRouteRewrite
defaultPrefix = Maybe DefaultGatewayRouteRewrite
a} :: HttpGatewayRoutePrefixRewrite)

instance Core.FromJSON HttpGatewayRoutePrefixRewrite where
  parseJSON :: Value -> Parser HttpGatewayRoutePrefixRewrite
parseJSON =
    String
-> (Object -> Parser HttpGatewayRoutePrefixRewrite)
-> Value
-> Parser HttpGatewayRoutePrefixRewrite
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HttpGatewayRoutePrefixRewrite"
      ( \Object
x ->
          Maybe Text
-> Maybe DefaultGatewayRouteRewrite
-> HttpGatewayRoutePrefixRewrite
HttpGatewayRoutePrefixRewrite'
            (Maybe Text
 -> Maybe DefaultGatewayRouteRewrite
 -> HttpGatewayRoutePrefixRewrite)
-> Parser (Maybe Text)
-> Parser
     (Maybe DefaultGatewayRouteRewrite -> HttpGatewayRoutePrefixRewrite)
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
"value")
            Parser
  (Maybe DefaultGatewayRouteRewrite -> HttpGatewayRoutePrefixRewrite)
-> Parser (Maybe DefaultGatewayRouteRewrite)
-> Parser HttpGatewayRoutePrefixRewrite
forall (f :: * -> *) a b. Applicative f => 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
"defaultPrefix")
      )

instance
  Prelude.Hashable
    HttpGatewayRoutePrefixRewrite

instance Prelude.NFData HttpGatewayRoutePrefixRewrite

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