{-# 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.Connection
-- 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.Connection 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.ConnectionState
import Amazonka.NetworkManager.Types.Tag
import qualified Amazonka.Prelude as Prelude

-- | Describes a connection.
--
-- /See:/ 'newConnection' smart constructor.
data Connection = Connection'
  { -- | The ID of the second device in the connection.
    Connection -> Maybe Text
connectedDeviceId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the link for the second device in the connection.
    Connection -> Maybe Text
connectedLinkId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the connection.
    Connection -> Maybe Text
connectionArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the connection.
    Connection -> Maybe Text
connectionId :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the connection was created.
    Connection -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | The description of the connection.
    Connection -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of the first device in the connection.
    Connection -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the global network.
    Connection -> Maybe Text
globalNetworkId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the link for the first device in the connection.
    Connection -> Maybe Text
linkId :: Prelude.Maybe Prelude.Text,
    -- | The state of the connection.
    Connection -> Maybe ConnectionState
state :: Prelude.Maybe ConnectionState,
    -- | The tags for the connection.
    Connection -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (Connection -> Connection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Connection -> Connection -> Bool
$c/= :: Connection -> Connection -> Bool
== :: Connection -> Connection -> Bool
$c== :: Connection -> Connection -> Bool
Prelude.Eq, ReadPrec [Connection]
ReadPrec Connection
Int -> ReadS Connection
ReadS [Connection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Connection]
$creadListPrec :: ReadPrec [Connection]
readPrec :: ReadPrec Connection
$creadPrec :: ReadPrec Connection
readList :: ReadS [Connection]
$creadList :: ReadS [Connection]
readsPrec :: Int -> ReadS Connection
$creadsPrec :: Int -> ReadS Connection
Prelude.Read, Int -> Connection -> ShowS
[Connection] -> ShowS
Connection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Connection] -> ShowS
$cshowList :: [Connection] -> ShowS
show :: Connection -> String
$cshow :: Connection -> String
showsPrec :: Int -> Connection -> ShowS
$cshowsPrec :: Int -> Connection -> ShowS
Prelude.Show, forall x. Rep Connection x -> Connection
forall x. Connection -> Rep Connection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Connection x -> Connection
$cfrom :: forall x. Connection -> Rep Connection x
Prelude.Generic)

-- |
-- Create a value of 'Connection' 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:
--
-- 'connectedDeviceId', 'connection_connectedDeviceId' - The ID of the second device in the connection.
--
-- 'connectedLinkId', 'connection_connectedLinkId' - The ID of the link for the second device in the connection.
--
-- 'connectionArn', 'connection_connectionArn' - The Amazon Resource Name (ARN) of the connection.
--
-- 'connectionId', 'connection_connectionId' - The ID of the connection.
--
-- 'createdAt', 'connection_createdAt' - The date and time that the connection was created.
--
-- 'description', 'connection_description' - The description of the connection.
--
-- 'deviceId', 'connection_deviceId' - The ID of the first device in the connection.
--
-- 'globalNetworkId', 'connection_globalNetworkId' - The ID of the global network.
--
-- 'linkId', 'connection_linkId' - The ID of the link for the first device in the connection.
--
-- 'state', 'connection_state' - The state of the connection.
--
-- 'tags', 'connection_tags' - The tags for the connection.
newConnection ::
  Connection
newConnection :: Connection
newConnection =
  Connection'
    { $sel:connectedDeviceId:Connection' :: Maybe Text
connectedDeviceId = forall a. Maybe a
Prelude.Nothing,
      $sel:connectedLinkId:Connection' :: Maybe Text
connectedLinkId = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionArn:Connection' :: Maybe Text
connectionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionId:Connection' :: Maybe Text
connectionId = forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:Connection' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Connection' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:Connection' :: Maybe Text
deviceId = forall a. Maybe a
Prelude.Nothing,
      $sel:globalNetworkId:Connection' :: Maybe Text
globalNetworkId = forall a. Maybe a
Prelude.Nothing,
      $sel:linkId:Connection' :: Maybe Text
linkId = forall a. Maybe a
Prelude.Nothing,
      $sel:state:Connection' :: Maybe ConnectionState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:Connection' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the second device in the connection.
connection_connectedDeviceId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_connectedDeviceId :: Lens' Connection (Maybe Text)
connection_connectedDeviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
connectedDeviceId :: Maybe Text
$sel:connectedDeviceId:Connection' :: Connection -> Maybe Text
connectedDeviceId} -> Maybe Text
connectedDeviceId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:connectedDeviceId:Connection' :: Maybe Text
connectedDeviceId = Maybe Text
a} :: Connection)

-- | The ID of the link for the second device in the connection.
connection_connectedLinkId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_connectedLinkId :: Lens' Connection (Maybe Text)
connection_connectedLinkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
connectedLinkId :: Maybe Text
$sel:connectedLinkId:Connection' :: Connection -> Maybe Text
connectedLinkId} -> Maybe Text
connectedLinkId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:connectedLinkId:Connection' :: Maybe Text
connectedLinkId = Maybe Text
a} :: Connection)

-- | The Amazon Resource Name (ARN) of the connection.
connection_connectionArn :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_connectionArn :: Lens' Connection (Maybe Text)
connection_connectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
connectionArn :: Maybe Text
$sel:connectionArn:Connection' :: Connection -> Maybe Text
connectionArn} -> Maybe Text
connectionArn) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:connectionArn:Connection' :: Maybe Text
connectionArn = Maybe Text
a} :: Connection)

-- | The ID of the connection.
connection_connectionId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_connectionId :: Lens' Connection (Maybe Text)
connection_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
connectionId :: Maybe Text
$sel:connectionId:Connection' :: Connection -> Maybe Text
connectionId} -> Maybe Text
connectionId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:connectionId:Connection' :: Maybe Text
connectionId = Maybe Text
a} :: Connection)

-- | The date and time that the connection was created.
connection_createdAt :: Lens.Lens' Connection (Prelude.Maybe Prelude.UTCTime)
connection_createdAt :: Lens' Connection (Maybe UTCTime)
connection_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:Connection' :: Connection -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: Connection
s@Connection' {} Maybe POSIX
a -> Connection
s {$sel:createdAt:Connection' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: Connection) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The description of the connection.
connection_description :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_description :: Lens' Connection (Maybe Text)
connection_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
description :: Maybe Text
$sel:description:Connection' :: Connection -> Maybe Text
description} -> Maybe Text
description) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:description:Connection' :: Maybe Text
description = Maybe Text
a} :: Connection)

-- | The ID of the first device in the connection.
connection_deviceId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_deviceId :: Lens' Connection (Maybe Text)
connection_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:Connection' :: Connection -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:deviceId:Connection' :: Maybe Text
deviceId = Maybe Text
a} :: Connection)

-- | The ID of the global network.
connection_globalNetworkId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_globalNetworkId :: Lens' Connection (Maybe Text)
connection_globalNetworkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
globalNetworkId :: Maybe Text
$sel:globalNetworkId:Connection' :: Connection -> Maybe Text
globalNetworkId} -> Maybe Text
globalNetworkId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:globalNetworkId:Connection' :: Maybe Text
globalNetworkId = Maybe Text
a} :: Connection)

-- | The ID of the link for the first device in the connection.
connection_linkId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_linkId :: Lens' Connection (Maybe Text)
connection_linkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
linkId :: Maybe Text
$sel:linkId:Connection' :: Connection -> Maybe Text
linkId} -> Maybe Text
linkId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:linkId:Connection' :: Maybe Text
linkId = Maybe Text
a} :: Connection)

-- | The state of the connection.
connection_state :: Lens.Lens' Connection (Prelude.Maybe ConnectionState)
connection_state :: Lens' Connection (Maybe ConnectionState)
connection_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe ConnectionState
state :: Maybe ConnectionState
$sel:state:Connection' :: Connection -> Maybe ConnectionState
state} -> Maybe ConnectionState
state) (\s :: Connection
s@Connection' {} Maybe ConnectionState
a -> Connection
s {$sel:state:Connection' :: Maybe ConnectionState
state = Maybe ConnectionState
a} :: Connection)

-- | The tags for the connection.
connection_tags :: Lens.Lens' Connection (Prelude.Maybe [Tag])
connection_tags :: Lens' Connection (Maybe [Tag])
connection_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:Connection' :: Connection -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: Connection
s@Connection' {} Maybe [Tag]
a -> Connection
s {$sel:tags:Connection' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: Connection) 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

instance Data.FromJSON Connection where
  parseJSON :: Value -> Parser Connection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Connection"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ConnectionState
-> Maybe [Tag]
-> Connection
Connection'
            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
"ConnectedDeviceId")
            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
"ConnectedLinkId")
            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
"ConnectionArn")
            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
"ConnectionId")
            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
"CreatedAt")
            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
"Description")
            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
"DeviceId")
            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
"GlobalNetworkId")
            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
"LinkId")
            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
"Tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Connection where
  hashWithSalt :: Int -> Connection -> Int
hashWithSalt Int
_salt Connection' {Maybe [Tag]
Maybe Text
Maybe POSIX
Maybe ConnectionState
tags :: Maybe [Tag]
state :: Maybe ConnectionState
linkId :: Maybe Text
globalNetworkId :: Maybe Text
deviceId :: Maybe Text
description :: Maybe Text
createdAt :: Maybe POSIX
connectionId :: Maybe Text
connectionArn :: Maybe Text
connectedLinkId :: Maybe Text
connectedDeviceId :: Maybe Text
$sel:tags:Connection' :: Connection -> Maybe [Tag]
$sel:state:Connection' :: Connection -> Maybe ConnectionState
$sel:linkId:Connection' :: Connection -> Maybe Text
$sel:globalNetworkId:Connection' :: Connection -> Maybe Text
$sel:deviceId:Connection' :: Connection -> Maybe Text
$sel:description:Connection' :: Connection -> Maybe Text
$sel:createdAt:Connection' :: Connection -> Maybe POSIX
$sel:connectionId:Connection' :: Connection -> Maybe Text
$sel:connectionArn:Connection' :: Connection -> Maybe Text
$sel:connectedLinkId:Connection' :: Connection -> Maybe Text
$sel:connectedDeviceId:Connection' :: Connection -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectedDeviceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectedLinkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
globalNetworkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
linkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectionState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags

instance Prelude.NFData Connection where
  rnf :: Connection -> ()
rnf Connection' {Maybe [Tag]
Maybe Text
Maybe POSIX
Maybe ConnectionState
tags :: Maybe [Tag]
state :: Maybe ConnectionState
linkId :: Maybe Text
globalNetworkId :: Maybe Text
deviceId :: Maybe Text
description :: Maybe Text
createdAt :: Maybe POSIX
connectionId :: Maybe Text
connectionArn :: Maybe Text
connectedLinkId :: Maybe Text
connectedDeviceId :: Maybe Text
$sel:tags:Connection' :: Connection -> Maybe [Tag]
$sel:state:Connection' :: Connection -> Maybe ConnectionState
$sel:linkId:Connection' :: Connection -> Maybe Text
$sel:globalNetworkId:Connection' :: Connection -> Maybe Text
$sel:deviceId:Connection' :: Connection -> Maybe Text
$sel:description:Connection' :: Connection -> Maybe Text
$sel:createdAt:Connection' :: Connection -> Maybe POSIX
$sel:connectionId:Connection' :: Connection -> Maybe Text
$sel:connectionArn:Connection' :: Connection -> Maybe Text
$sel:connectedLinkId:Connection' :: Connection -> Maybe Text
$sel:connectedDeviceId:Connection' :: Connection -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectedDeviceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectedLinkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
globalNetworkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
linkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectionState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags