{-# 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.DMS.Types.Connection
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DMS.Types.Connection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Status of the connection between an endpoint and a replication instance,
-- including Amazon Resource Names (ARNs) and the last error message
-- issued.
--
-- /See:/ 'newConnection' smart constructor.
data Connection = Connection'
  { -- | The connection status. This parameter can return one of the following
    -- values:
    --
    -- -   @\"successful\"@
    --
    -- -   @\"testing\"@
    --
    -- -   @\"failed\"@
    --
    -- -   @\"deleting\"@
    Connection -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the replication instance.
    Connection -> Maybe Text
replicationInstanceArn :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the endpoint. Identifiers must begin with a letter and
    -- must contain only ASCII letters, digits, and hyphens. They can\'t end
    -- with a hyphen or contain two consecutive hyphens.
    Connection -> Maybe Text
endpointIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The replication instance identifier. This parameter is stored as a
    -- lowercase string.
    Connection -> Maybe Text
replicationInstanceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The ARN string that uniquely identifies the endpoint.
    Connection -> Maybe Text
endpointArn :: Prelude.Maybe Prelude.Text,
    -- | The error message when the connection last failed.
    Connection -> Maybe Text
lastFailureMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (Connection -> Connection -> Bool
(Connection -> Connection -> Bool)
-> (Connection -> Connection -> Bool) -> Eq Connection
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]
(Int -> ReadS Connection)
-> ReadS [Connection]
-> ReadPrec Connection
-> ReadPrec [Connection]
-> Read 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
(Int -> Connection -> ShowS)
-> (Connection -> String)
-> ([Connection] -> ShowS)
-> Show Connection
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. Connection -> Rep Connection x)
-> (forall x. Rep Connection x -> Connection) -> Generic Connection
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:
--
-- 'status', 'connection_status' - The connection status. This parameter can return one of the following
-- values:
--
-- -   @\"successful\"@
--
-- -   @\"testing\"@
--
-- -   @\"failed\"@
--
-- -   @\"deleting\"@
--
-- 'replicationInstanceArn', 'connection_replicationInstanceArn' - The ARN of the replication instance.
--
-- 'endpointIdentifier', 'connection_endpointIdentifier' - The identifier of the endpoint. Identifiers must begin with a letter and
-- must contain only ASCII letters, digits, and hyphens. They can\'t end
-- with a hyphen or contain two consecutive hyphens.
--
-- 'replicationInstanceIdentifier', 'connection_replicationInstanceIdentifier' - The replication instance identifier. This parameter is stored as a
-- lowercase string.
--
-- 'endpointArn', 'connection_endpointArn' - The ARN string that uniquely identifies the endpoint.
--
-- 'lastFailureMessage', 'connection_lastFailureMessage' - The error message when the connection last failed.
newConnection ::
  Connection
newConnection :: Connection
newConnection =
  Connection' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
    { $sel:status:Connection' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationInstanceArn:Connection' :: Maybe Text
replicationInstanceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointIdentifier:Connection' :: Maybe Text
endpointIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationInstanceIdentifier:Connection' :: Maybe Text
replicationInstanceIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointArn:Connection' :: Maybe Text
endpointArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastFailureMessage:Connection' :: Maybe Text
lastFailureMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The connection status. This parameter can return one of the following
-- values:
--
-- -   @\"successful\"@
--
-- -   @\"testing\"@
--
-- -   @\"failed\"@
--
-- -   @\"deleting\"@
connection_status :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_status :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_status = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
status :: Maybe Text
$sel:status:Connection' :: Connection -> Maybe Text
status} -> Maybe Text
status) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:status:Connection' :: Maybe Text
status = Maybe Text
a} :: Connection)

-- | The ARN of the replication instance.
connection_replicationInstanceArn :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_replicationInstanceArn :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_replicationInstanceArn = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
replicationInstanceArn :: Maybe Text
$sel:replicationInstanceArn:Connection' :: Connection -> Maybe Text
replicationInstanceArn} -> Maybe Text
replicationInstanceArn) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:replicationInstanceArn:Connection' :: Maybe Text
replicationInstanceArn = Maybe Text
a} :: Connection)

-- | The identifier of the endpoint. Identifiers must begin with a letter and
-- must contain only ASCII letters, digits, and hyphens. They can\'t end
-- with a hyphen or contain two consecutive hyphens.
connection_endpointIdentifier :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_endpointIdentifier :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_endpointIdentifier = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
endpointIdentifier :: Maybe Text
$sel:endpointIdentifier:Connection' :: Connection -> Maybe Text
endpointIdentifier} -> Maybe Text
endpointIdentifier) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:endpointIdentifier:Connection' :: Maybe Text
endpointIdentifier = Maybe Text
a} :: Connection)

-- | The replication instance identifier. This parameter is stored as a
-- lowercase string.
connection_replicationInstanceIdentifier :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_replicationInstanceIdentifier :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_replicationInstanceIdentifier = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
replicationInstanceIdentifier :: Maybe Text
$sel:replicationInstanceIdentifier:Connection' :: Connection -> Maybe Text
replicationInstanceIdentifier} -> Maybe Text
replicationInstanceIdentifier) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:replicationInstanceIdentifier:Connection' :: Maybe Text
replicationInstanceIdentifier = Maybe Text
a} :: Connection)

-- | The ARN string that uniquely identifies the endpoint.
connection_endpointArn :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_endpointArn :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_endpointArn = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
endpointArn :: Maybe Text
$sel:endpointArn:Connection' :: Connection -> Maybe Text
endpointArn} -> Maybe Text
endpointArn) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:endpointArn:Connection' :: Maybe Text
endpointArn = Maybe Text
a} :: Connection)

-- | The error message when the connection last failed.
connection_lastFailureMessage :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_lastFailureMessage :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_lastFailureMessage = (Connection -> Maybe Text)
-> (Connection -> Maybe Text -> Connection)
-> Lens Connection Connection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe Text
lastFailureMessage :: Maybe Text
$sel:lastFailureMessage:Connection' :: Connection -> Maybe Text
lastFailureMessage} -> Maybe Text
lastFailureMessage) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:lastFailureMessage:Connection' :: Maybe Text
lastFailureMessage = Maybe Text
a} :: Connection)

instance Core.FromJSON Connection where
  parseJSON :: Value -> Parser Connection
parseJSON =
    String
-> (Object -> Parser Connection) -> Value -> Parser Connection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Connection"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Connection)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Connection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Connection)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplicationInstanceArn")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndpointIdentifier")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReplicationInstanceIdentifier")
            Parser (Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndpointArn")
            Parser (Maybe Text -> Connection)
-> Parser (Maybe Text) -> Parser Connection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastFailureMessage")
      )

instance Prelude.Hashable Connection

instance Prelude.NFData Connection