{-# 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.PathComponent
-- 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.PathComponent 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.NetworkResourceSummary
import qualified Amazonka.Prelude as Prelude

-- | Describes a path component.
--
-- /See:/ 'newPathComponent' smart constructor.
data PathComponent = PathComponent'
  { -- | The destination CIDR block in the route table.
    PathComponent -> Maybe Text
destinationCidrBlock :: Prelude.Maybe Prelude.Text,
    -- | The resource.
    PathComponent -> Maybe NetworkResourceSummary
resource :: Prelude.Maybe NetworkResourceSummary,
    -- | The sequence number in the path. The destination is 0.
    PathComponent -> Maybe Int
sequence :: Prelude.Maybe Prelude.Int
  }
  deriving (PathComponent -> PathComponent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PathComponent -> PathComponent -> Bool
$c/= :: PathComponent -> PathComponent -> Bool
== :: PathComponent -> PathComponent -> Bool
$c== :: PathComponent -> PathComponent -> Bool
Prelude.Eq, ReadPrec [PathComponent]
ReadPrec PathComponent
Int -> ReadS PathComponent
ReadS [PathComponent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PathComponent]
$creadListPrec :: ReadPrec [PathComponent]
readPrec :: ReadPrec PathComponent
$creadPrec :: ReadPrec PathComponent
readList :: ReadS [PathComponent]
$creadList :: ReadS [PathComponent]
readsPrec :: Int -> ReadS PathComponent
$creadsPrec :: Int -> ReadS PathComponent
Prelude.Read, Int -> PathComponent -> ShowS
[PathComponent] -> ShowS
PathComponent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PathComponent] -> ShowS
$cshowList :: [PathComponent] -> ShowS
show :: PathComponent -> String
$cshow :: PathComponent -> String
showsPrec :: Int -> PathComponent -> ShowS
$cshowsPrec :: Int -> PathComponent -> ShowS
Prelude.Show, forall x. Rep PathComponent x -> PathComponent
forall x. PathComponent -> Rep PathComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PathComponent x -> PathComponent
$cfrom :: forall x. PathComponent -> Rep PathComponent x
Prelude.Generic)

-- |
-- Create a value of 'PathComponent' 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', 'pathComponent_destinationCidrBlock' - The destination CIDR block in the route table.
--
-- 'resource', 'pathComponent_resource' - The resource.
--
-- 'sequence', 'pathComponent_sequence' - The sequence number in the path. The destination is 0.
newPathComponent ::
  PathComponent
newPathComponent :: PathComponent
newPathComponent =
  PathComponent'
    { $sel:destinationCidrBlock:PathComponent' :: Maybe Text
destinationCidrBlock =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resource:PathComponent' :: Maybe NetworkResourceSummary
resource = forall a. Maybe a
Prelude.Nothing,
      $sel:sequence:PathComponent' :: Maybe Int
sequence = forall a. Maybe a
Prelude.Nothing
    }

-- | The destination CIDR block in the route table.
pathComponent_destinationCidrBlock :: Lens.Lens' PathComponent (Prelude.Maybe Prelude.Text)
pathComponent_destinationCidrBlock :: Lens' PathComponent (Maybe Text)
pathComponent_destinationCidrBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathComponent' {Maybe Text
destinationCidrBlock :: Maybe Text
$sel:destinationCidrBlock:PathComponent' :: PathComponent -> Maybe Text
destinationCidrBlock} -> Maybe Text
destinationCidrBlock) (\s :: PathComponent
s@PathComponent' {} Maybe Text
a -> PathComponent
s {$sel:destinationCidrBlock:PathComponent' :: Maybe Text
destinationCidrBlock = Maybe Text
a} :: PathComponent)

-- | The resource.
pathComponent_resource :: Lens.Lens' PathComponent (Prelude.Maybe NetworkResourceSummary)
pathComponent_resource :: Lens' PathComponent (Maybe NetworkResourceSummary)
pathComponent_resource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathComponent' {Maybe NetworkResourceSummary
resource :: Maybe NetworkResourceSummary
$sel:resource:PathComponent' :: PathComponent -> Maybe NetworkResourceSummary
resource} -> Maybe NetworkResourceSummary
resource) (\s :: PathComponent
s@PathComponent' {} Maybe NetworkResourceSummary
a -> PathComponent
s {$sel:resource:PathComponent' :: Maybe NetworkResourceSummary
resource = Maybe NetworkResourceSummary
a} :: PathComponent)

-- | The sequence number in the path. The destination is 0.
pathComponent_sequence :: Lens.Lens' PathComponent (Prelude.Maybe Prelude.Int)
pathComponent_sequence :: Lens' PathComponent (Maybe Int)
pathComponent_sequence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PathComponent' {Maybe Int
sequence :: Maybe Int
$sel:sequence:PathComponent' :: PathComponent -> Maybe Int
sequence} -> Maybe Int
sequence) (\s :: PathComponent
s@PathComponent' {} Maybe Int
a -> PathComponent
s {$sel:sequence:PathComponent' :: Maybe Int
sequence = Maybe Int
a} :: PathComponent)

instance Data.FromJSON PathComponent where
  parseJSON :: Value -> Parser PathComponent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PathComponent"
      ( \Object
x ->
          Maybe Text
-> Maybe NetworkResourceSummary -> Maybe Int -> PathComponent
PathComponent'
            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
"Resource")
            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
"Sequence")
      )

instance Prelude.Hashable PathComponent where
  hashWithSalt :: Int -> PathComponent -> Int
hashWithSalt Int
_salt PathComponent' {Maybe Int
Maybe Text
Maybe NetworkResourceSummary
sequence :: Maybe Int
resource :: Maybe NetworkResourceSummary
destinationCidrBlock :: Maybe Text
$sel:sequence:PathComponent' :: PathComponent -> Maybe Int
$sel:resource:PathComponent' :: PathComponent -> Maybe NetworkResourceSummary
$sel:destinationCidrBlock:PathComponent' :: PathComponent -> 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 NetworkResourceSummary
resource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
sequence

instance Prelude.NFData PathComponent where
  rnf :: PathComponent -> ()
rnf PathComponent' {Maybe Int
Maybe Text
Maybe NetworkResourceSummary
sequence :: Maybe Int
resource :: Maybe NetworkResourceSummary
destinationCidrBlock :: Maybe Text
$sel:sequence:PathComponent' :: PathComponent -> Maybe Int
$sel:resource:PathComponent' :: PathComponent -> Maybe NetworkResourceSummary
$sel:destinationCidrBlock:PathComponent' :: PathComponent -> 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 NetworkResourceSummary
resource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
sequence