{-# 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.NetworkManager.Types.NetworkRoute
-- 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.NetworkManager.Types.NetworkRoute where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkManager.Types.NetworkRouteDestination
import Amazonka.NetworkManager.Types.RouteState
import Amazonka.NetworkManager.Types.RouteType
import qualified Amazonka.Prelude as Prelude

-- | Describes a network route.
--
-- /See:/ 'newNetworkRoute' smart constructor.
data NetworkRoute = NetworkRoute'
  { -- | A unique identifier for the route, such as a CIDR block.
    NetworkRoute -> Maybe Text
destinationCidrBlock :: Prelude.Maybe Prelude.Text,
    -- | The destinations.
    NetworkRoute -> Maybe [NetworkRouteDestination]
destinations :: Prelude.Maybe [NetworkRouteDestination],
    -- | The ID of the prefix list.
    NetworkRoute -> Maybe Text
prefixListId :: Prelude.Maybe Prelude.Text,
    -- | The route state. The possible values are @active@ and @blackhole@.
    NetworkRoute -> Maybe RouteState
state :: Prelude.Maybe RouteState,
    -- | The route type. The possible values are @propagated@ and @static@.
    NetworkRoute -> Maybe RouteType
type' :: Prelude.Maybe RouteType
  }
  deriving (NetworkRoute -> NetworkRoute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkRoute -> NetworkRoute -> Bool
$c/= :: NetworkRoute -> NetworkRoute -> Bool
== :: NetworkRoute -> NetworkRoute -> Bool
$c== :: NetworkRoute -> NetworkRoute -> Bool
Prelude.Eq, ReadPrec [NetworkRoute]
ReadPrec NetworkRoute
Int -> ReadS NetworkRoute
ReadS [NetworkRoute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkRoute]
$creadListPrec :: ReadPrec [NetworkRoute]
readPrec :: ReadPrec NetworkRoute
$creadPrec :: ReadPrec NetworkRoute
readList :: ReadS [NetworkRoute]
$creadList :: ReadS [NetworkRoute]
readsPrec :: Int -> ReadS NetworkRoute
$creadsPrec :: Int -> ReadS NetworkRoute
Prelude.Read, Int -> NetworkRoute -> ShowS
[NetworkRoute] -> ShowS
NetworkRoute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkRoute] -> ShowS
$cshowList :: [NetworkRoute] -> ShowS
show :: NetworkRoute -> String
$cshow :: NetworkRoute -> String
showsPrec :: Int -> NetworkRoute -> ShowS
$cshowsPrec :: Int -> NetworkRoute -> ShowS
Prelude.Show, forall x. Rep NetworkRoute x -> NetworkRoute
forall x. NetworkRoute -> Rep NetworkRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkRoute x -> NetworkRoute
$cfrom :: forall x. NetworkRoute -> Rep NetworkRoute x
Prelude.Generic)

-- |
-- Create a value of 'NetworkRoute' 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:
--
-- 'destinationCidrBlock', 'networkRoute_destinationCidrBlock' - A unique identifier for the route, such as a CIDR block.
--
-- 'destinations', 'networkRoute_destinations' - The destinations.
--
-- 'prefixListId', 'networkRoute_prefixListId' - The ID of the prefix list.
--
-- 'state', 'networkRoute_state' - The route state. The possible values are @active@ and @blackhole@.
--
-- 'type'', 'networkRoute_type' - The route type. The possible values are @propagated@ and @static@.
newNetworkRoute ::
  NetworkRoute
newNetworkRoute :: NetworkRoute
newNetworkRoute =
  NetworkRoute'
    { $sel:destinationCidrBlock:NetworkRoute' :: Maybe Text
destinationCidrBlock =
        forall a. Maybe a
Prelude.Nothing,
      $sel:destinations:NetworkRoute' :: Maybe [NetworkRouteDestination]
destinations = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListId:NetworkRoute' :: Maybe Text
prefixListId = forall a. Maybe a
Prelude.Nothing,
      $sel:state:NetworkRoute' :: Maybe RouteState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:type':NetworkRoute' :: Maybe RouteType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | A unique identifier for the route, such as a CIDR block.
networkRoute_destinationCidrBlock :: Lens.Lens' NetworkRoute (Prelude.Maybe Prelude.Text)
networkRoute_destinationCidrBlock :: Lens' NetworkRoute (Maybe Text)
networkRoute_destinationCidrBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkRoute' {Maybe Text
destinationCidrBlock :: Maybe Text
$sel:destinationCidrBlock:NetworkRoute' :: NetworkRoute -> Maybe Text
destinationCidrBlock} -> Maybe Text
destinationCidrBlock) (\s :: NetworkRoute
s@NetworkRoute' {} Maybe Text
a -> NetworkRoute
s {$sel:destinationCidrBlock:NetworkRoute' :: Maybe Text
destinationCidrBlock = Maybe Text
a} :: NetworkRoute)

-- | The destinations.
networkRoute_destinations :: Lens.Lens' NetworkRoute (Prelude.Maybe [NetworkRouteDestination])
networkRoute_destinations :: Lens' NetworkRoute (Maybe [NetworkRouteDestination])
networkRoute_destinations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkRoute' {Maybe [NetworkRouteDestination]
destinations :: Maybe [NetworkRouteDestination]
$sel:destinations:NetworkRoute' :: NetworkRoute -> Maybe [NetworkRouteDestination]
destinations} -> Maybe [NetworkRouteDestination]
destinations) (\s :: NetworkRoute
s@NetworkRoute' {} Maybe [NetworkRouteDestination]
a -> NetworkRoute
s {$sel:destinations:NetworkRoute' :: Maybe [NetworkRouteDestination]
destinations = Maybe [NetworkRouteDestination]
a} :: NetworkRoute) 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

-- | The ID of the prefix list.
networkRoute_prefixListId :: Lens.Lens' NetworkRoute (Prelude.Maybe Prelude.Text)
networkRoute_prefixListId :: Lens' NetworkRoute (Maybe Text)
networkRoute_prefixListId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkRoute' {Maybe Text
prefixListId :: Maybe Text
$sel:prefixListId:NetworkRoute' :: NetworkRoute -> Maybe Text
prefixListId} -> Maybe Text
prefixListId) (\s :: NetworkRoute
s@NetworkRoute' {} Maybe Text
a -> NetworkRoute
s {$sel:prefixListId:NetworkRoute' :: Maybe Text
prefixListId = Maybe Text
a} :: NetworkRoute)

-- | The route state. The possible values are @active@ and @blackhole@.
networkRoute_state :: Lens.Lens' NetworkRoute (Prelude.Maybe RouteState)
networkRoute_state :: Lens' NetworkRoute (Maybe RouteState)
networkRoute_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkRoute' {Maybe RouteState
state :: Maybe RouteState
$sel:state:NetworkRoute' :: NetworkRoute -> Maybe RouteState
state} -> Maybe RouteState
state) (\s :: NetworkRoute
s@NetworkRoute' {} Maybe RouteState
a -> NetworkRoute
s {$sel:state:NetworkRoute' :: Maybe RouteState
state = Maybe RouteState
a} :: NetworkRoute)

-- | The route type. The possible values are @propagated@ and @static@.
networkRoute_type :: Lens.Lens' NetworkRoute (Prelude.Maybe RouteType)
networkRoute_type :: Lens' NetworkRoute (Maybe RouteType)
networkRoute_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkRoute' {Maybe RouteType
type' :: Maybe RouteType
$sel:type':NetworkRoute' :: NetworkRoute -> Maybe RouteType
type'} -> Maybe RouteType
type') (\s :: NetworkRoute
s@NetworkRoute' {} Maybe RouteType
a -> NetworkRoute
s {$sel:type':NetworkRoute' :: Maybe RouteType
type' = Maybe RouteType
a} :: NetworkRoute)

instance Data.FromJSON NetworkRoute where
  parseJSON :: Value -> Parser NetworkRoute
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NetworkRoute"
      ( \Object
x ->
          Maybe Text
-> Maybe [NetworkRouteDestination]
-> Maybe Text
-> Maybe RouteState
-> Maybe RouteType
-> NetworkRoute
NetworkRoute'
            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
"DestinationCidrBlock")
            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
"Destinations" 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 (Maybe a)
Data..:? Key
"PrefixListId")
            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
"State")
            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
"Type")
      )

instance Prelude.Hashable NetworkRoute where
  hashWithSalt :: Int -> NetworkRoute -> Int
hashWithSalt Int
_salt NetworkRoute' {Maybe [NetworkRouteDestination]
Maybe Text
Maybe RouteState
Maybe RouteType
type' :: Maybe RouteType
state :: Maybe RouteState
prefixListId :: Maybe Text
destinations :: Maybe [NetworkRouteDestination]
destinationCidrBlock :: Maybe Text
$sel:type':NetworkRoute' :: NetworkRoute -> Maybe RouteType
$sel:state:NetworkRoute' :: NetworkRoute -> Maybe RouteState
$sel:prefixListId:NetworkRoute' :: NetworkRoute -> Maybe Text
$sel:destinations:NetworkRoute' :: NetworkRoute -> Maybe [NetworkRouteDestination]
$sel:destinationCidrBlock:NetworkRoute' :: NetworkRoute -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationCidrBlock
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [NetworkRouteDestination]
destinations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefixListId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteType
type'

instance Prelude.NFData NetworkRoute where
  rnf :: NetworkRoute -> ()
rnf NetworkRoute' {Maybe [NetworkRouteDestination]
Maybe Text
Maybe RouteState
Maybe RouteType
type' :: Maybe RouteType
state :: Maybe RouteState
prefixListId :: Maybe Text
destinations :: Maybe [NetworkRouteDestination]
destinationCidrBlock :: Maybe Text
$sel:type':NetworkRoute' :: NetworkRoute -> Maybe RouteType
$sel:state:NetworkRoute' :: NetworkRoute -> Maybe RouteState
$sel:prefixListId:NetworkRoute' :: NetworkRoute -> Maybe Text
$sel:destinations:NetworkRoute' :: NetworkRoute -> Maybe [NetworkRouteDestination]
$sel:destinationCidrBlock:NetworkRoute' :: NetworkRoute -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationCidrBlock
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [NetworkRouteDestination]
destinations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefixListId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteType
type'