{-# 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.RouteAnalysisCompletion
-- 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.RouteAnalysisCompletion 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.RouteAnalysisCompletionReasonCode
import Amazonka.NetworkManager.Types.RouteAnalysisCompletionResultCode
import qualified Amazonka.Prelude as Prelude

-- | Describes the status of an analysis at completion.
--
-- /See:/ 'newRouteAnalysisCompletion' smart constructor.
data RouteAnalysisCompletion = RouteAnalysisCompletion'
  { -- | The reason code. Available only if a connection is not found.
    --
    -- -   @BLACKHOLE_ROUTE_FOR_DESTINATION_FOUND@ - Found a black hole route
    --     with the destination CIDR block.
    --
    -- -   @CYCLIC_PATH_DETECTED@ - Found the same resource multiple times
    --     while traversing the path.
    --
    -- -   @INACTIVE_ROUTE_FOR_DESTINATION_FOUND@ - Found an inactive route
    --     with the destination CIDR block.
    --
    -- -   @MAX_HOPS_EXCEEDED@ - Analysis exceeded 64 hops without finding the
    --     destination.
    --
    -- -   @ROUTE_NOT_FOUND@ - Cannot find a route table with the destination
    --     CIDR block.
    --
    -- -   @TGW_ATTACH_ARN_NO_MATCH@ - Found an attachment, but not with the
    --     correct destination ARN.
    --
    -- -   @TGW_ATTACH_NOT_FOUND@ - Cannot find an attachment.
    --
    -- -   @TGW_ATTACH_NOT_IN_TGW@ - Found an attachment, but not to the
    --     correct transit gateway.
    --
    -- -   @TGW_ATTACH_STABLE_ROUTE_TABLE_NOT_FOUND@ - The state of the route
    --     table association is not associated.
    RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionReasonCode
reasonCode :: Prelude.Maybe RouteAnalysisCompletionReasonCode,
    -- | Additional information about the path. Available only if a connection is
    -- not found.
    RouteAnalysisCompletion -> Maybe (HashMap Text Text)
reasonContext :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The result of the analysis. If the status is @NOT_CONNECTED@, check the
    -- reason code.
    RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionResultCode
resultCode :: Prelude.Maybe RouteAnalysisCompletionResultCode
  }
  deriving (RouteAnalysisCompletion -> RouteAnalysisCompletion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RouteAnalysisCompletion -> RouteAnalysisCompletion -> Bool
$c/= :: RouteAnalysisCompletion -> RouteAnalysisCompletion -> Bool
== :: RouteAnalysisCompletion -> RouteAnalysisCompletion -> Bool
$c== :: RouteAnalysisCompletion -> RouteAnalysisCompletion -> Bool
Prelude.Eq, ReadPrec [RouteAnalysisCompletion]
ReadPrec RouteAnalysisCompletion
Int -> ReadS RouteAnalysisCompletion
ReadS [RouteAnalysisCompletion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RouteAnalysisCompletion]
$creadListPrec :: ReadPrec [RouteAnalysisCompletion]
readPrec :: ReadPrec RouteAnalysisCompletion
$creadPrec :: ReadPrec RouteAnalysisCompletion
readList :: ReadS [RouteAnalysisCompletion]
$creadList :: ReadS [RouteAnalysisCompletion]
readsPrec :: Int -> ReadS RouteAnalysisCompletion
$creadsPrec :: Int -> ReadS RouteAnalysisCompletion
Prelude.Read, Int -> RouteAnalysisCompletion -> ShowS
[RouteAnalysisCompletion] -> ShowS
RouteAnalysisCompletion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RouteAnalysisCompletion] -> ShowS
$cshowList :: [RouteAnalysisCompletion] -> ShowS
show :: RouteAnalysisCompletion -> String
$cshow :: RouteAnalysisCompletion -> String
showsPrec :: Int -> RouteAnalysisCompletion -> ShowS
$cshowsPrec :: Int -> RouteAnalysisCompletion -> ShowS
Prelude.Show, forall x. Rep RouteAnalysisCompletion x -> RouteAnalysisCompletion
forall x. RouteAnalysisCompletion -> Rep RouteAnalysisCompletion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RouteAnalysisCompletion x -> RouteAnalysisCompletion
$cfrom :: forall x. RouteAnalysisCompletion -> Rep RouteAnalysisCompletion x
Prelude.Generic)

-- |
-- Create a value of 'RouteAnalysisCompletion' 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:
--
-- 'reasonCode', 'routeAnalysisCompletion_reasonCode' - The reason code. Available only if a connection is not found.
--
-- -   @BLACKHOLE_ROUTE_FOR_DESTINATION_FOUND@ - Found a black hole route
--     with the destination CIDR block.
--
-- -   @CYCLIC_PATH_DETECTED@ - Found the same resource multiple times
--     while traversing the path.
--
-- -   @INACTIVE_ROUTE_FOR_DESTINATION_FOUND@ - Found an inactive route
--     with the destination CIDR block.
--
-- -   @MAX_HOPS_EXCEEDED@ - Analysis exceeded 64 hops without finding the
--     destination.
--
-- -   @ROUTE_NOT_FOUND@ - Cannot find a route table with the destination
--     CIDR block.
--
-- -   @TGW_ATTACH_ARN_NO_MATCH@ - Found an attachment, but not with the
--     correct destination ARN.
--
-- -   @TGW_ATTACH_NOT_FOUND@ - Cannot find an attachment.
--
-- -   @TGW_ATTACH_NOT_IN_TGW@ - Found an attachment, but not to the
--     correct transit gateway.
--
-- -   @TGW_ATTACH_STABLE_ROUTE_TABLE_NOT_FOUND@ - The state of the route
--     table association is not associated.
--
-- 'reasonContext', 'routeAnalysisCompletion_reasonContext' - Additional information about the path. Available only if a connection is
-- not found.
--
-- 'resultCode', 'routeAnalysisCompletion_resultCode' - The result of the analysis. If the status is @NOT_CONNECTED@, check the
-- reason code.
newRouteAnalysisCompletion ::
  RouteAnalysisCompletion
newRouteAnalysisCompletion :: RouteAnalysisCompletion
newRouteAnalysisCompletion =
  RouteAnalysisCompletion'
    { $sel:reasonCode:RouteAnalysisCompletion' :: Maybe RouteAnalysisCompletionReasonCode
reasonCode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:reasonContext:RouteAnalysisCompletion' :: Maybe (HashMap Text Text)
reasonContext = forall a. Maybe a
Prelude.Nothing,
      $sel:resultCode:RouteAnalysisCompletion' :: Maybe RouteAnalysisCompletionResultCode
resultCode = forall a. Maybe a
Prelude.Nothing
    }

-- | The reason code. Available only if a connection is not found.
--
-- -   @BLACKHOLE_ROUTE_FOR_DESTINATION_FOUND@ - Found a black hole route
--     with the destination CIDR block.
--
-- -   @CYCLIC_PATH_DETECTED@ - Found the same resource multiple times
--     while traversing the path.
--
-- -   @INACTIVE_ROUTE_FOR_DESTINATION_FOUND@ - Found an inactive route
--     with the destination CIDR block.
--
-- -   @MAX_HOPS_EXCEEDED@ - Analysis exceeded 64 hops without finding the
--     destination.
--
-- -   @ROUTE_NOT_FOUND@ - Cannot find a route table with the destination
--     CIDR block.
--
-- -   @TGW_ATTACH_ARN_NO_MATCH@ - Found an attachment, but not with the
--     correct destination ARN.
--
-- -   @TGW_ATTACH_NOT_FOUND@ - Cannot find an attachment.
--
-- -   @TGW_ATTACH_NOT_IN_TGW@ - Found an attachment, but not to the
--     correct transit gateway.
--
-- -   @TGW_ATTACH_STABLE_ROUTE_TABLE_NOT_FOUND@ - The state of the route
--     table association is not associated.
routeAnalysisCompletion_reasonCode :: Lens.Lens' RouteAnalysisCompletion (Prelude.Maybe RouteAnalysisCompletionReasonCode)
routeAnalysisCompletion_reasonCode :: Lens'
  RouteAnalysisCompletion (Maybe RouteAnalysisCompletionReasonCode)
routeAnalysisCompletion_reasonCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteAnalysisCompletion' {Maybe RouteAnalysisCompletionReasonCode
reasonCode :: Maybe RouteAnalysisCompletionReasonCode
$sel:reasonCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionReasonCode
reasonCode} -> Maybe RouteAnalysisCompletionReasonCode
reasonCode) (\s :: RouteAnalysisCompletion
s@RouteAnalysisCompletion' {} Maybe RouteAnalysisCompletionReasonCode
a -> RouteAnalysisCompletion
s {$sel:reasonCode:RouteAnalysisCompletion' :: Maybe RouteAnalysisCompletionReasonCode
reasonCode = Maybe RouteAnalysisCompletionReasonCode
a} :: RouteAnalysisCompletion)

-- | Additional information about the path. Available only if a connection is
-- not found.
routeAnalysisCompletion_reasonContext :: Lens.Lens' RouteAnalysisCompletion (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
routeAnalysisCompletion_reasonContext :: Lens' RouteAnalysisCompletion (Maybe (HashMap Text Text))
routeAnalysisCompletion_reasonContext = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteAnalysisCompletion' {Maybe (HashMap Text Text)
reasonContext :: Maybe (HashMap Text Text)
$sel:reasonContext:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe (HashMap Text Text)
reasonContext} -> Maybe (HashMap Text Text)
reasonContext) (\s :: RouteAnalysisCompletion
s@RouteAnalysisCompletion' {} Maybe (HashMap Text Text)
a -> RouteAnalysisCompletion
s {$sel:reasonContext:RouteAnalysisCompletion' :: Maybe (HashMap Text Text)
reasonContext = Maybe (HashMap Text Text)
a} :: RouteAnalysisCompletion) 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 result of the analysis. If the status is @NOT_CONNECTED@, check the
-- reason code.
routeAnalysisCompletion_resultCode :: Lens.Lens' RouteAnalysisCompletion (Prelude.Maybe RouteAnalysisCompletionResultCode)
routeAnalysisCompletion_resultCode :: Lens'
  RouteAnalysisCompletion (Maybe RouteAnalysisCompletionResultCode)
routeAnalysisCompletion_resultCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RouteAnalysisCompletion' {Maybe RouteAnalysisCompletionResultCode
resultCode :: Maybe RouteAnalysisCompletionResultCode
$sel:resultCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionResultCode
resultCode} -> Maybe RouteAnalysisCompletionResultCode
resultCode) (\s :: RouteAnalysisCompletion
s@RouteAnalysisCompletion' {} Maybe RouteAnalysisCompletionResultCode
a -> RouteAnalysisCompletion
s {$sel:resultCode:RouteAnalysisCompletion' :: Maybe RouteAnalysisCompletionResultCode
resultCode = Maybe RouteAnalysisCompletionResultCode
a} :: RouteAnalysisCompletion)

instance Data.FromJSON RouteAnalysisCompletion where
  parseJSON :: Value -> Parser RouteAnalysisCompletion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RouteAnalysisCompletion"
      ( \Object
x ->
          Maybe RouteAnalysisCompletionReasonCode
-> Maybe (HashMap Text Text)
-> Maybe RouteAnalysisCompletionResultCode
-> RouteAnalysisCompletion
RouteAnalysisCompletion'
            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
"ReasonCode")
            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
"ReasonContext" 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
"ResultCode")
      )

instance Prelude.Hashable RouteAnalysisCompletion where
  hashWithSalt :: Int -> RouteAnalysisCompletion -> Int
hashWithSalt Int
_salt RouteAnalysisCompletion' {Maybe (HashMap Text Text)
Maybe RouteAnalysisCompletionReasonCode
Maybe RouteAnalysisCompletionResultCode
resultCode :: Maybe RouteAnalysisCompletionResultCode
reasonContext :: Maybe (HashMap Text Text)
reasonCode :: Maybe RouteAnalysisCompletionReasonCode
$sel:resultCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionResultCode
$sel:reasonContext:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe (HashMap Text Text)
$sel:reasonCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionReasonCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteAnalysisCompletionReasonCode
reasonCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
reasonContext
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RouteAnalysisCompletionResultCode
resultCode

instance Prelude.NFData RouteAnalysisCompletion where
  rnf :: RouteAnalysisCompletion -> ()
rnf RouteAnalysisCompletion' {Maybe (HashMap Text Text)
Maybe RouteAnalysisCompletionReasonCode
Maybe RouteAnalysisCompletionResultCode
resultCode :: Maybe RouteAnalysisCompletionResultCode
reasonContext :: Maybe (HashMap Text Text)
reasonCode :: Maybe RouteAnalysisCompletionReasonCode
$sel:resultCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionResultCode
$sel:reasonContext:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe (HashMap Text Text)
$sel:reasonCode:RouteAnalysisCompletion' :: RouteAnalysisCompletion -> Maybe RouteAnalysisCompletionReasonCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteAnalysisCompletionReasonCode
reasonCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
reasonContext
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RouteAnalysisCompletionResultCode
resultCode