{-# 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.FMS.Types.Route
-- 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.FMS.Types.Route where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types.DestinationType
import Amazonka.FMS.Types.TargetType
import qualified Amazonka.Prelude as Prelude

-- | Describes a route in a route table.
--
-- /See:/ 'newRoute' smart constructor.
data Route = Route'
  { -- | The destination of the route.
    Route -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | The type of destination for the route.
    Route -> Maybe DestinationType
destinationType :: Prelude.Maybe DestinationType,
    -- | The route\'s target.
    Route -> Maybe Text
target :: Prelude.Maybe Prelude.Text,
    -- | The type of target for the route.
    Route -> Maybe TargetType
targetType :: Prelude.Maybe TargetType
  }
  deriving (Route -> Route -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Route -> Route -> Bool
$c/= :: Route -> Route -> Bool
== :: Route -> Route -> Bool
$c== :: Route -> Route -> Bool
Prelude.Eq, ReadPrec [Route]
ReadPrec Route
Int -> ReadS Route
ReadS [Route]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Route]
$creadListPrec :: ReadPrec [Route]
readPrec :: ReadPrec Route
$creadPrec :: ReadPrec Route
readList :: ReadS [Route]
$creadList :: ReadS [Route]
readsPrec :: Int -> ReadS Route
$creadsPrec :: Int -> ReadS Route
Prelude.Read, Int -> Route -> ShowS
[Route] -> ShowS
Route -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Route] -> ShowS
$cshowList :: [Route] -> ShowS
show :: Route -> String
$cshow :: Route -> String
showsPrec :: Int -> Route -> ShowS
$cshowsPrec :: Int -> Route -> ShowS
Prelude.Show, forall x. Rep Route x -> Route
forall x. Route -> Rep Route x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Route x -> Route
$cfrom :: forall x. Route -> Rep Route x
Prelude.Generic)

-- |
-- Create a value of 'Route' 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:
--
-- 'destination', 'route_destination' - The destination of the route.
--
-- 'destinationType', 'route_destinationType' - The type of destination for the route.
--
-- 'target', 'route_target' - The route\'s target.
--
-- 'targetType', 'route_targetType' - The type of target for the route.
newRoute ::
  Route
newRoute :: Route
newRoute =
  Route'
    { $sel:destination:Route' :: Maybe Text
destination = forall a. Maybe a
Prelude.Nothing,
      $sel:destinationType:Route' :: Maybe DestinationType
destinationType = forall a. Maybe a
Prelude.Nothing,
      $sel:target:Route' :: Maybe Text
target = forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:Route' :: Maybe TargetType
targetType = forall a. Maybe a
Prelude.Nothing
    }

-- | The destination of the route.
route_destination :: Lens.Lens' Route (Prelude.Maybe Prelude.Text)
route_destination :: Lens' Route (Maybe Text)
route_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Route' {Maybe Text
destination :: Maybe Text
$sel:destination:Route' :: Route -> Maybe Text
destination} -> Maybe Text
destination) (\s :: Route
s@Route' {} Maybe Text
a -> Route
s {$sel:destination:Route' :: Maybe Text
destination = Maybe Text
a} :: Route)

-- | The type of destination for the route.
route_destinationType :: Lens.Lens' Route (Prelude.Maybe DestinationType)
route_destinationType :: Lens' Route (Maybe DestinationType)
route_destinationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Route' {Maybe DestinationType
destinationType :: Maybe DestinationType
$sel:destinationType:Route' :: Route -> Maybe DestinationType
destinationType} -> Maybe DestinationType
destinationType) (\s :: Route
s@Route' {} Maybe DestinationType
a -> Route
s {$sel:destinationType:Route' :: Maybe DestinationType
destinationType = Maybe DestinationType
a} :: Route)

-- | The route\'s target.
route_target :: Lens.Lens' Route (Prelude.Maybe Prelude.Text)
route_target :: Lens' Route (Maybe Text)
route_target = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Route' {Maybe Text
target :: Maybe Text
$sel:target:Route' :: Route -> Maybe Text
target} -> Maybe Text
target) (\s :: Route
s@Route' {} Maybe Text
a -> Route
s {$sel:target:Route' :: Maybe Text
target = Maybe Text
a} :: Route)

-- | The type of target for the route.
route_targetType :: Lens.Lens' Route (Prelude.Maybe TargetType)
route_targetType :: Lens' Route (Maybe TargetType)
route_targetType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Route' {Maybe TargetType
targetType :: Maybe TargetType
$sel:targetType:Route' :: Route -> Maybe TargetType
targetType} -> Maybe TargetType
targetType) (\s :: Route
s@Route' {} Maybe TargetType
a -> Route
s {$sel:targetType:Route' :: Maybe TargetType
targetType = Maybe TargetType
a} :: Route)

instance Data.FromJSON Route where
  parseJSON :: Value -> Parser Route
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Route"
      ( \Object
x ->
          Maybe Text
-> Maybe DestinationType -> Maybe Text -> Maybe TargetType -> Route
Route'
            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
"Destination")
            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
"DestinationType")
            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
"Target")
            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
"TargetType")
      )

instance Prelude.Hashable Route where
  hashWithSalt :: Int -> Route -> Int
hashWithSalt Int
_salt Route' {Maybe Text
Maybe DestinationType
Maybe TargetType
targetType :: Maybe TargetType
target :: Maybe Text
destinationType :: Maybe DestinationType
destination :: Maybe Text
$sel:targetType:Route' :: Route -> Maybe TargetType
$sel:target:Route' :: Route -> Maybe Text
$sel:destinationType:Route' :: Route -> Maybe DestinationType
$sel:destination:Route' :: Route -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DestinationType
destinationType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
target
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetType
targetType

instance Prelude.NFData Route where
  rnf :: Route -> ()
rnf Route' {Maybe Text
Maybe DestinationType
Maybe TargetType
targetType :: Maybe TargetType
target :: Maybe Text
destinationType :: Maybe DestinationType
destination :: Maybe Text
$sel:targetType:Route' :: Route -> Maybe TargetType
$sel:target:Route' :: Route -> Maybe Text
$sel:destinationType:Route' :: Route -> Maybe DestinationType
$sel:destination:Route' :: Route -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DestinationType
destinationType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
target
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetType
targetType