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

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

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

-- |
-- Create a value of 'GrpcGatewayRouteRewrite' 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', 'grpcGatewayRouteRewrite_hostname' - The host name of the gateway route to rewrite.
newGrpcGatewayRouteRewrite ::
  GrpcGatewayRouteRewrite
newGrpcGatewayRouteRewrite :: GrpcGatewayRouteRewrite
newGrpcGatewayRouteRewrite =
  GrpcGatewayRouteRewrite' :: Maybe GatewayRouteHostnameRewrite -> GrpcGatewayRouteRewrite
GrpcGatewayRouteRewrite'
    { $sel:hostname:GrpcGatewayRouteRewrite' :: Maybe GatewayRouteHostnameRewrite
hostname =
        Maybe GatewayRouteHostnameRewrite
forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Prelude.Hashable GrpcGatewayRouteRewrite

instance Prelude.NFData GrpcGatewayRouteRewrite

instance Core.ToJSON GrpcGatewayRouteRewrite where
  toJSON :: GrpcGatewayRouteRewrite -> Value
toJSON GrpcGatewayRouteRewrite' {Maybe GatewayRouteHostnameRewrite
hostname :: Maybe GatewayRouteHostnameRewrite
$sel:hostname:GrpcGatewayRouteRewrite' :: GrpcGatewayRouteRewrite -> 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]
      )