{-# 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.MigrationHubReFactorSpaces.Types.UriPathRouteInput
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MigrationHubReFactorSpaces.Types.UriPathRouteInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubReFactorSpaces.Types.HttpMethod
import Amazonka.MigrationHubReFactorSpaces.Types.RouteActivationState
import qualified Amazonka.Prelude as Prelude

-- | The configuration for the URI path route type.
--
-- /See:/ 'newUriPathRouteInput' smart constructor.
data UriPathRouteInput = UriPathRouteInput'
  { -- | Indicates whether to match all subpaths of the given source path. If
    -- this value is @false@, requests must match the source path exactly
    -- before they are forwarded to this route\'s service.
    UriPathRouteInput -> Maybe Bool
includeChildPaths :: Prelude.Maybe Prelude.Bool,
    -- | A list of HTTP methods to match. An empty list matches all values. If a
    -- method is present, only HTTP requests using that method are forwarded to
    -- this route’s service.
    UriPathRouteInput -> Maybe [HttpMethod]
methods :: Prelude.Maybe [HttpMethod],
    -- | If set to @ACTIVE@, traffic is forwarded to this route’s service after
    -- the route is created.
    UriPathRouteInput -> RouteActivationState
activationState :: RouteActivationState,
    -- | The path to use to match traffic. Paths must start with @\/@ and are
    -- relative to the base of the application.
    UriPathRouteInput -> Text
sourcePath :: Prelude.Text
  }
  deriving (UriPathRouteInput -> UriPathRouteInput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UriPathRouteInput -> UriPathRouteInput -> Bool
$c/= :: UriPathRouteInput -> UriPathRouteInput -> Bool
== :: UriPathRouteInput -> UriPathRouteInput -> Bool
$c== :: UriPathRouteInput -> UriPathRouteInput -> Bool
Prelude.Eq, ReadPrec [UriPathRouteInput]
ReadPrec UriPathRouteInput
Int -> ReadS UriPathRouteInput
ReadS [UriPathRouteInput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UriPathRouteInput]
$creadListPrec :: ReadPrec [UriPathRouteInput]
readPrec :: ReadPrec UriPathRouteInput
$creadPrec :: ReadPrec UriPathRouteInput
readList :: ReadS [UriPathRouteInput]
$creadList :: ReadS [UriPathRouteInput]
readsPrec :: Int -> ReadS UriPathRouteInput
$creadsPrec :: Int -> ReadS UriPathRouteInput
Prelude.Read, Int -> UriPathRouteInput -> ShowS
[UriPathRouteInput] -> ShowS
UriPathRouteInput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UriPathRouteInput] -> ShowS
$cshowList :: [UriPathRouteInput] -> ShowS
show :: UriPathRouteInput -> String
$cshow :: UriPathRouteInput -> String
showsPrec :: Int -> UriPathRouteInput -> ShowS
$cshowsPrec :: Int -> UriPathRouteInput -> ShowS
Prelude.Show, forall x. Rep UriPathRouteInput x -> UriPathRouteInput
forall x. UriPathRouteInput -> Rep UriPathRouteInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UriPathRouteInput x -> UriPathRouteInput
$cfrom :: forall x. UriPathRouteInput -> Rep UriPathRouteInput x
Prelude.Generic)

-- |
-- Create a value of 'UriPathRouteInput' 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:
--
-- 'includeChildPaths', 'uriPathRouteInput_includeChildPaths' - Indicates whether to match all subpaths of the given source path. If
-- this value is @false@, requests must match the source path exactly
-- before they are forwarded to this route\'s service.
--
-- 'methods', 'uriPathRouteInput_methods' - A list of HTTP methods to match. An empty list matches all values. If a
-- method is present, only HTTP requests using that method are forwarded to
-- this route’s service.
--
-- 'activationState', 'uriPathRouteInput_activationState' - If set to @ACTIVE@, traffic is forwarded to this route’s service after
-- the route is created.
--
-- 'sourcePath', 'uriPathRouteInput_sourcePath' - The path to use to match traffic. Paths must start with @\/@ and are
-- relative to the base of the application.
newUriPathRouteInput ::
  -- | 'activationState'
  RouteActivationState ->
  -- | 'sourcePath'
  Prelude.Text ->
  UriPathRouteInput
newUriPathRouteInput :: RouteActivationState -> Text -> UriPathRouteInput
newUriPathRouteInput RouteActivationState
pActivationState_ Text
pSourcePath_ =
  UriPathRouteInput'
    { $sel:includeChildPaths:UriPathRouteInput' :: Maybe Bool
includeChildPaths =
        forall a. Maybe a
Prelude.Nothing,
      $sel:methods:UriPathRouteInput' :: Maybe [HttpMethod]
methods = forall a. Maybe a
Prelude.Nothing,
      $sel:activationState:UriPathRouteInput' :: RouteActivationState
activationState = RouteActivationState
pActivationState_,
      $sel:sourcePath:UriPathRouteInput' :: Text
sourcePath = Text
pSourcePath_
    }

-- | Indicates whether to match all subpaths of the given source path. If
-- this value is @false@, requests must match the source path exactly
-- before they are forwarded to this route\'s service.
uriPathRouteInput_includeChildPaths :: Lens.Lens' UriPathRouteInput (Prelude.Maybe Prelude.Bool)
uriPathRouteInput_includeChildPaths :: Lens' UriPathRouteInput (Maybe Bool)
uriPathRouteInput_includeChildPaths = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UriPathRouteInput' {Maybe Bool
includeChildPaths :: Maybe Bool
$sel:includeChildPaths:UriPathRouteInput' :: UriPathRouteInput -> Maybe Bool
includeChildPaths} -> Maybe Bool
includeChildPaths) (\s :: UriPathRouteInput
s@UriPathRouteInput' {} Maybe Bool
a -> UriPathRouteInput
s {$sel:includeChildPaths:UriPathRouteInput' :: Maybe Bool
includeChildPaths = Maybe Bool
a} :: UriPathRouteInput)

-- | A list of HTTP methods to match. An empty list matches all values. If a
-- method is present, only HTTP requests using that method are forwarded to
-- this route’s service.
uriPathRouteInput_methods :: Lens.Lens' UriPathRouteInput (Prelude.Maybe [HttpMethod])
uriPathRouteInput_methods :: Lens' UriPathRouteInput (Maybe [HttpMethod])
uriPathRouteInput_methods = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UriPathRouteInput' {Maybe [HttpMethod]
methods :: Maybe [HttpMethod]
$sel:methods:UriPathRouteInput' :: UriPathRouteInput -> Maybe [HttpMethod]
methods} -> Maybe [HttpMethod]
methods) (\s :: UriPathRouteInput
s@UriPathRouteInput' {} Maybe [HttpMethod]
a -> UriPathRouteInput
s {$sel:methods:UriPathRouteInput' :: Maybe [HttpMethod]
methods = Maybe [HttpMethod]
a} :: UriPathRouteInput) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If set to @ACTIVE@, traffic is forwarded to this route’s service after
-- the route is created.
uriPathRouteInput_activationState :: Lens.Lens' UriPathRouteInput RouteActivationState
uriPathRouteInput_activationState :: Lens' UriPathRouteInput RouteActivationState
uriPathRouteInput_activationState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UriPathRouteInput' {RouteActivationState
activationState :: RouteActivationState
$sel:activationState:UriPathRouteInput' :: UriPathRouteInput -> RouteActivationState
activationState} -> RouteActivationState
activationState) (\s :: UriPathRouteInput
s@UriPathRouteInput' {} RouteActivationState
a -> UriPathRouteInput
s {$sel:activationState:UriPathRouteInput' :: RouteActivationState
activationState = RouteActivationState
a} :: UriPathRouteInput)

-- | The path to use to match traffic. Paths must start with @\/@ and are
-- relative to the base of the application.
uriPathRouteInput_sourcePath :: Lens.Lens' UriPathRouteInput Prelude.Text
uriPathRouteInput_sourcePath :: Lens' UriPathRouteInput Text
uriPathRouteInput_sourcePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UriPathRouteInput' {Text
sourcePath :: Text
$sel:sourcePath:UriPathRouteInput' :: UriPathRouteInput -> Text
sourcePath} -> Text
sourcePath) (\s :: UriPathRouteInput
s@UriPathRouteInput' {} Text
a -> UriPathRouteInput
s {$sel:sourcePath:UriPathRouteInput' :: Text
sourcePath = Text
a} :: UriPathRouteInput)

instance Data.FromJSON UriPathRouteInput where
  parseJSON :: Value -> Parser UriPathRouteInput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UriPathRouteInput"
      ( \Object
x ->
          Maybe Bool
-> Maybe [HttpMethod]
-> RouteActivationState
-> Text
-> UriPathRouteInput
UriPathRouteInput'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IncludeChildPaths")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Methods" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActivationState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SourcePath")
      )

instance Prelude.Hashable UriPathRouteInput where
  hashWithSalt :: Int -> UriPathRouteInput -> Int
hashWithSalt Int
_salt UriPathRouteInput' {Maybe Bool
Maybe [HttpMethod]
Text
RouteActivationState
sourcePath :: Text
activationState :: RouteActivationState
methods :: Maybe [HttpMethod]
includeChildPaths :: Maybe Bool
$sel:sourcePath:UriPathRouteInput' :: UriPathRouteInput -> Text
$sel:activationState:UriPathRouteInput' :: UriPathRouteInput -> RouteActivationState
$sel:methods:UriPathRouteInput' :: UriPathRouteInput -> Maybe [HttpMethod]
$sel:includeChildPaths:UriPathRouteInput' :: UriPathRouteInput -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeChildPaths
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [HttpMethod]
methods
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RouteActivationState
activationState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourcePath

instance Prelude.NFData UriPathRouteInput where
  rnf :: UriPathRouteInput -> ()
rnf UriPathRouteInput' {Maybe Bool
Maybe [HttpMethod]
Text
RouteActivationState
sourcePath :: Text
activationState :: RouteActivationState
methods :: Maybe [HttpMethod]
includeChildPaths :: Maybe Bool
$sel:sourcePath:UriPathRouteInput' :: UriPathRouteInput -> Text
$sel:activationState:UriPathRouteInput' :: UriPathRouteInput -> RouteActivationState
$sel:methods:UriPathRouteInput' :: UriPathRouteInput -> Maybe [HttpMethod]
$sel:includeChildPaths:UriPathRouteInput' :: UriPathRouteInput -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeChildPaths
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [HttpMethod]
methods
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RouteActivationState
activationState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourcePath

instance Data.ToJSON UriPathRouteInput where
  toJSON :: UriPathRouteInput -> Value
toJSON UriPathRouteInput' {Maybe Bool
Maybe [HttpMethod]
Text
RouteActivationState
sourcePath :: Text
activationState :: RouteActivationState
methods :: Maybe [HttpMethod]
includeChildPaths :: Maybe Bool
$sel:sourcePath:UriPathRouteInput' :: UriPathRouteInput -> Text
$sel:activationState:UriPathRouteInput' :: UriPathRouteInput -> RouteActivationState
$sel:methods:UriPathRouteInput' :: UriPathRouteInput -> Maybe [HttpMethod]
$sel:includeChildPaths:UriPathRouteInput' :: UriPathRouteInput -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IncludeChildPaths" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeChildPaths,
            (Key
"Methods" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [HttpMethod]
methods,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ActivationState" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RouteActivationState
activationState),
            forall a. a -> Maybe a
Prelude.Just (Key
"SourcePath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourcePath)
          ]
      )