{-# 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.ConnectPeerConfiguration
-- 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.ConnectPeerConfiguration 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.ConnectPeerBgpConfiguration
import Amazonka.NetworkManager.Types.TunnelProtocol
import qualified Amazonka.Prelude as Prelude

-- | Describes a core network Connect peer configuration.
--
-- /See:/ 'newConnectPeerConfiguration' smart constructor.
data ConnectPeerConfiguration = ConnectPeerConfiguration'
  { -- | The Connect peer BGP configurations.
    ConnectPeerConfiguration -> Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations :: Prelude.Maybe [ConnectPeerBgpConfiguration],
    -- | The IP address of a core network.
    ConnectPeerConfiguration -> Maybe Text
coreNetworkAddress :: Prelude.Maybe Prelude.Text,
    -- | The inside IP addresses used for a Connect peer configuration.
    ConnectPeerConfiguration -> Maybe [Text]
insideCidrBlocks :: Prelude.Maybe [Prelude.Text],
    -- | The IP address of the Connect peer.
    ConnectPeerConfiguration -> Maybe Text
peerAddress :: Prelude.Maybe Prelude.Text,
    -- | The protocol used for a Connect peer configuration.
    ConnectPeerConfiguration -> Maybe TunnelProtocol
protocol :: Prelude.Maybe TunnelProtocol
  }
  deriving (ConnectPeerConfiguration -> ConnectPeerConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectPeerConfiguration -> ConnectPeerConfiguration -> Bool
$c/= :: ConnectPeerConfiguration -> ConnectPeerConfiguration -> Bool
== :: ConnectPeerConfiguration -> ConnectPeerConfiguration -> Bool
$c== :: ConnectPeerConfiguration -> ConnectPeerConfiguration -> Bool
Prelude.Eq, ReadPrec [ConnectPeerConfiguration]
ReadPrec ConnectPeerConfiguration
Int -> ReadS ConnectPeerConfiguration
ReadS [ConnectPeerConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectPeerConfiguration]
$creadListPrec :: ReadPrec [ConnectPeerConfiguration]
readPrec :: ReadPrec ConnectPeerConfiguration
$creadPrec :: ReadPrec ConnectPeerConfiguration
readList :: ReadS [ConnectPeerConfiguration]
$creadList :: ReadS [ConnectPeerConfiguration]
readsPrec :: Int -> ReadS ConnectPeerConfiguration
$creadsPrec :: Int -> ReadS ConnectPeerConfiguration
Prelude.Read, Int -> ConnectPeerConfiguration -> ShowS
[ConnectPeerConfiguration] -> ShowS
ConnectPeerConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectPeerConfiguration] -> ShowS
$cshowList :: [ConnectPeerConfiguration] -> ShowS
show :: ConnectPeerConfiguration -> String
$cshow :: ConnectPeerConfiguration -> String
showsPrec :: Int -> ConnectPeerConfiguration -> ShowS
$cshowsPrec :: Int -> ConnectPeerConfiguration -> ShowS
Prelude.Show, forall x.
Rep ConnectPeerConfiguration x -> ConnectPeerConfiguration
forall x.
ConnectPeerConfiguration -> Rep ConnectPeerConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConnectPeerConfiguration x -> ConnectPeerConfiguration
$cfrom :: forall x.
ConnectPeerConfiguration -> Rep ConnectPeerConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ConnectPeerConfiguration' 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:
--
-- 'bgpConfigurations', 'connectPeerConfiguration_bgpConfigurations' - The Connect peer BGP configurations.
--
-- 'coreNetworkAddress', 'connectPeerConfiguration_coreNetworkAddress' - The IP address of a core network.
--
-- 'insideCidrBlocks', 'connectPeerConfiguration_insideCidrBlocks' - The inside IP addresses used for a Connect peer configuration.
--
-- 'peerAddress', 'connectPeerConfiguration_peerAddress' - The IP address of the Connect peer.
--
-- 'protocol', 'connectPeerConfiguration_protocol' - The protocol used for a Connect peer configuration.
newConnectPeerConfiguration ::
  ConnectPeerConfiguration
newConnectPeerConfiguration :: ConnectPeerConfiguration
newConnectPeerConfiguration =
  ConnectPeerConfiguration'
    { $sel:bgpConfigurations:ConnectPeerConfiguration' :: Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:coreNetworkAddress:ConnectPeerConfiguration' :: Maybe Text
coreNetworkAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:insideCidrBlocks:ConnectPeerConfiguration' :: Maybe [Text]
insideCidrBlocks = forall a. Maybe a
Prelude.Nothing,
      $sel:peerAddress:ConnectPeerConfiguration' :: Maybe Text
peerAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:ConnectPeerConfiguration' :: Maybe TunnelProtocol
protocol = forall a. Maybe a
Prelude.Nothing
    }

-- | The Connect peer BGP configurations.
connectPeerConfiguration_bgpConfigurations :: Lens.Lens' ConnectPeerConfiguration (Prelude.Maybe [ConnectPeerBgpConfiguration])
connectPeerConfiguration_bgpConfigurations :: Lens'
  ConnectPeerConfiguration (Maybe [ConnectPeerBgpConfiguration])
connectPeerConfiguration_bgpConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectPeerConfiguration' {Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations :: Maybe [ConnectPeerBgpConfiguration]
$sel:bgpConfigurations:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations} -> Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations) (\s :: ConnectPeerConfiguration
s@ConnectPeerConfiguration' {} Maybe [ConnectPeerBgpConfiguration]
a -> ConnectPeerConfiguration
s {$sel:bgpConfigurations:ConnectPeerConfiguration' :: Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations = Maybe [ConnectPeerBgpConfiguration]
a} :: ConnectPeerConfiguration) 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 IP address of a core network.
connectPeerConfiguration_coreNetworkAddress :: Lens.Lens' ConnectPeerConfiguration (Prelude.Maybe Prelude.Text)
connectPeerConfiguration_coreNetworkAddress :: Lens' ConnectPeerConfiguration (Maybe Text)
connectPeerConfiguration_coreNetworkAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectPeerConfiguration' {Maybe Text
coreNetworkAddress :: Maybe Text
$sel:coreNetworkAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
coreNetworkAddress} -> Maybe Text
coreNetworkAddress) (\s :: ConnectPeerConfiguration
s@ConnectPeerConfiguration' {} Maybe Text
a -> ConnectPeerConfiguration
s {$sel:coreNetworkAddress:ConnectPeerConfiguration' :: Maybe Text
coreNetworkAddress = Maybe Text
a} :: ConnectPeerConfiguration)

-- | The inside IP addresses used for a Connect peer configuration.
connectPeerConfiguration_insideCidrBlocks :: Lens.Lens' ConnectPeerConfiguration (Prelude.Maybe [Prelude.Text])
connectPeerConfiguration_insideCidrBlocks :: Lens' ConnectPeerConfiguration (Maybe [Text])
connectPeerConfiguration_insideCidrBlocks = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectPeerConfiguration' {Maybe [Text]
insideCidrBlocks :: Maybe [Text]
$sel:insideCidrBlocks:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [Text]
insideCidrBlocks} -> Maybe [Text]
insideCidrBlocks) (\s :: ConnectPeerConfiguration
s@ConnectPeerConfiguration' {} Maybe [Text]
a -> ConnectPeerConfiguration
s {$sel:insideCidrBlocks:ConnectPeerConfiguration' :: Maybe [Text]
insideCidrBlocks = Maybe [Text]
a} :: ConnectPeerConfiguration) 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 IP address of the Connect peer.
connectPeerConfiguration_peerAddress :: Lens.Lens' ConnectPeerConfiguration (Prelude.Maybe Prelude.Text)
connectPeerConfiguration_peerAddress :: Lens' ConnectPeerConfiguration (Maybe Text)
connectPeerConfiguration_peerAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectPeerConfiguration' {Maybe Text
peerAddress :: Maybe Text
$sel:peerAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
peerAddress} -> Maybe Text
peerAddress) (\s :: ConnectPeerConfiguration
s@ConnectPeerConfiguration' {} Maybe Text
a -> ConnectPeerConfiguration
s {$sel:peerAddress:ConnectPeerConfiguration' :: Maybe Text
peerAddress = Maybe Text
a} :: ConnectPeerConfiguration)

-- | The protocol used for a Connect peer configuration.
connectPeerConfiguration_protocol :: Lens.Lens' ConnectPeerConfiguration (Prelude.Maybe TunnelProtocol)
connectPeerConfiguration_protocol :: Lens' ConnectPeerConfiguration (Maybe TunnelProtocol)
connectPeerConfiguration_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectPeerConfiguration' {Maybe TunnelProtocol
protocol :: Maybe TunnelProtocol
$sel:protocol:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe TunnelProtocol
protocol} -> Maybe TunnelProtocol
protocol) (\s :: ConnectPeerConfiguration
s@ConnectPeerConfiguration' {} Maybe TunnelProtocol
a -> ConnectPeerConfiguration
s {$sel:protocol:ConnectPeerConfiguration' :: Maybe TunnelProtocol
protocol = Maybe TunnelProtocol
a} :: ConnectPeerConfiguration)

instance Data.FromJSON ConnectPeerConfiguration where
  parseJSON :: Value -> Parser ConnectPeerConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConnectPeerConfiguration"
      ( \Object
x ->
          Maybe [ConnectPeerBgpConfiguration]
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe TunnelProtocol
-> ConnectPeerConfiguration
ConnectPeerConfiguration'
            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
"BgpConfigurations"
                            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
"CoreNetworkAddress")
            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
"InsideCidrBlocks"
                            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
"PeerAddress")
            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
"Protocol")
      )

instance Prelude.Hashable ConnectPeerConfiguration where
  hashWithSalt :: Int -> ConnectPeerConfiguration -> Int
hashWithSalt Int
_salt ConnectPeerConfiguration' {Maybe [Text]
Maybe [ConnectPeerBgpConfiguration]
Maybe Text
Maybe TunnelProtocol
protocol :: Maybe TunnelProtocol
peerAddress :: Maybe Text
insideCidrBlocks :: Maybe [Text]
coreNetworkAddress :: Maybe Text
bgpConfigurations :: Maybe [ConnectPeerBgpConfiguration]
$sel:protocol:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe TunnelProtocol
$sel:peerAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
$sel:insideCidrBlocks:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [Text]
$sel:coreNetworkAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
$sel:bgpConfigurations:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [ConnectPeerBgpConfiguration]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
coreNetworkAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
insideCidrBlocks
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
peerAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TunnelProtocol
protocol

instance Prelude.NFData ConnectPeerConfiguration where
  rnf :: ConnectPeerConfiguration -> ()
rnf ConnectPeerConfiguration' {Maybe [Text]
Maybe [ConnectPeerBgpConfiguration]
Maybe Text
Maybe TunnelProtocol
protocol :: Maybe TunnelProtocol
peerAddress :: Maybe Text
insideCidrBlocks :: Maybe [Text]
coreNetworkAddress :: Maybe Text
bgpConfigurations :: Maybe [ConnectPeerBgpConfiguration]
$sel:protocol:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe TunnelProtocol
$sel:peerAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
$sel:insideCidrBlocks:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [Text]
$sel:coreNetworkAddress:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe Text
$sel:bgpConfigurations:ConnectPeerConfiguration' :: ConnectPeerConfiguration -> Maybe [ConnectPeerBgpConfiguration]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConnectPeerBgpConfiguration]
bgpConfigurations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
coreNetworkAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
insideCidrBlocks
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
peerAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TunnelProtocol
protocol