{-# 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.CloudWatchEvents.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.CloudWatchEvents.Types.Connection where

import Amazonka.CloudWatchEvents.Types.ConnectionAuthorizationType
import Amazonka.CloudWatchEvents.Types.ConnectionState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a connection.
--
-- /See:/ 'newConnection' smart constructor.
data Connection = Connection'
  { -- | A time stamp for the time that the connection was created.
    Connection -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | A time stamp for the time that the connection was last modified.
    Connection -> Maybe POSIX
lastModifiedTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the connection.
    Connection -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A time stamp for the time that the connection was last authorized.
    Connection -> Maybe POSIX
lastAuthorizedTime :: Prelude.Maybe Core.POSIX,
    -- | The authorization type specified for the connection.
    Connection -> Maybe ConnectionAuthorizationType
authorizationType :: Prelude.Maybe ConnectionAuthorizationType,
    -- | The ARN of the connection.
    Connection -> Maybe Text
connectionArn :: Prelude.Maybe Prelude.Text,
    -- | The reason that the connection is in the connection state.
    Connection -> Maybe Text
stateReason :: Prelude.Maybe Prelude.Text,
    -- | The state of the connection.
    Connection -> Maybe ConnectionState
connectionState :: Prelude.Maybe ConnectionState
  }
  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:
--
-- 'creationTime', 'connection_creationTime' - A time stamp for the time that the connection was created.
--
-- 'lastModifiedTime', 'connection_lastModifiedTime' - A time stamp for the time that the connection was last modified.
--
-- 'name', 'connection_name' - The name of the connection.
--
-- 'lastAuthorizedTime', 'connection_lastAuthorizedTime' - A time stamp for the time that the connection was last authorized.
--
-- 'authorizationType', 'connection_authorizationType' - The authorization type specified for the connection.
--
-- 'connectionArn', 'connection_connectionArn' - The ARN of the connection.
--
-- 'stateReason', 'connection_stateReason' - The reason that the connection is in the connection state.
--
-- 'connectionState', 'connection_connectionState' - The state of the connection.
newConnection ::
  Connection
newConnection :: Connection
newConnection =
  Connection' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe ConnectionAuthorizationType
-> Maybe Text
-> Maybe Text
-> Maybe ConnectionState
-> Connection
Connection'
    { $sel:creationTime:Connection' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedTime:Connection' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Connection' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastAuthorizedTime:Connection' :: Maybe POSIX
lastAuthorizedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:authorizationType:Connection' :: Maybe ConnectionAuthorizationType
authorizationType = Maybe ConnectionAuthorizationType
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionArn:Connection' :: Maybe Text
connectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stateReason:Connection' :: Maybe Text
stateReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionState:Connection' :: Maybe ConnectionState
connectionState = Maybe ConnectionState
forall a. Maybe a
Prelude.Nothing
    }

-- | A time stamp for the time that the connection was created.
connection_creationTime :: Lens.Lens' Connection (Prelude.Maybe Prelude.UTCTime)
connection_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Connection -> f Connection
connection_creationTime = (Connection -> Maybe POSIX)
-> (Connection -> Maybe POSIX -> Connection)
-> Lens Connection Connection (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Connection' :: Connection -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Connection
s@Connection' {} Maybe POSIX
a -> Connection
s {$sel:creationTime:Connection' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Connection) ((Maybe POSIX -> f (Maybe POSIX)) -> Connection -> f Connection)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Connection
-> f Connection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A time stamp for the time that the connection was last modified.
connection_lastModifiedTime :: Lens.Lens' Connection (Prelude.Maybe Prelude.UTCTime)
connection_lastModifiedTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Connection -> f Connection
connection_lastModifiedTime = (Connection -> Maybe POSIX)
-> (Connection -> Maybe POSIX -> Connection)
-> Lens Connection Connection (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe POSIX
lastModifiedTime :: Maybe POSIX
$sel:lastModifiedTime:Connection' :: Connection -> Maybe POSIX
lastModifiedTime} -> Maybe POSIX
lastModifiedTime) (\s :: Connection
s@Connection' {} Maybe POSIX
a -> Connection
s {$sel:lastModifiedTime:Connection' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
a} :: Connection) ((Maybe POSIX -> f (Maybe POSIX)) -> Connection -> f Connection)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Connection
-> f Connection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the connection.
connection_name :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_name :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_name = (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
name :: Maybe Text
$sel:name:Connection' :: Connection -> Maybe Text
name} -> Maybe Text
name) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:name:Connection' :: Maybe Text
name = Maybe Text
a} :: Connection)

-- | A time stamp for the time that the connection was last authorized.
connection_lastAuthorizedTime :: Lens.Lens' Connection (Prelude.Maybe Prelude.UTCTime)
connection_lastAuthorizedTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Connection -> f Connection
connection_lastAuthorizedTime = (Connection -> Maybe POSIX)
-> (Connection -> Maybe POSIX -> Connection)
-> Lens Connection Connection (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe POSIX
lastAuthorizedTime :: Maybe POSIX
$sel:lastAuthorizedTime:Connection' :: Connection -> Maybe POSIX
lastAuthorizedTime} -> Maybe POSIX
lastAuthorizedTime) (\s :: Connection
s@Connection' {} Maybe POSIX
a -> Connection
s {$sel:lastAuthorizedTime:Connection' :: Maybe POSIX
lastAuthorizedTime = Maybe POSIX
a} :: Connection) ((Maybe POSIX -> f (Maybe POSIX)) -> Connection -> f Connection)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Connection
-> f Connection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The authorization type specified for the connection.
connection_authorizationType :: Lens.Lens' Connection (Prelude.Maybe ConnectionAuthorizationType)
connection_authorizationType :: (Maybe ConnectionAuthorizationType
 -> f (Maybe ConnectionAuthorizationType))
-> Connection -> f Connection
connection_authorizationType = (Connection -> Maybe ConnectionAuthorizationType)
-> (Connection -> Maybe ConnectionAuthorizationType -> Connection)
-> Lens
     Connection
     Connection
     (Maybe ConnectionAuthorizationType)
     (Maybe ConnectionAuthorizationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe ConnectionAuthorizationType
authorizationType :: Maybe ConnectionAuthorizationType
$sel:authorizationType:Connection' :: Connection -> Maybe ConnectionAuthorizationType
authorizationType} -> Maybe ConnectionAuthorizationType
authorizationType) (\s :: Connection
s@Connection' {} Maybe ConnectionAuthorizationType
a -> Connection
s {$sel:authorizationType:Connection' :: Maybe ConnectionAuthorizationType
authorizationType = Maybe ConnectionAuthorizationType
a} :: Connection)

-- | The ARN of the connection.
connection_connectionArn :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_connectionArn :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_connectionArn = (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
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 reason that the connection is in the connection state.
connection_stateReason :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_stateReason :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_stateReason = (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
stateReason :: Maybe Text
$sel:stateReason:Connection' :: Connection -> Maybe Text
stateReason} -> Maybe Text
stateReason) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:stateReason:Connection' :: Maybe Text
stateReason = Maybe Text
a} :: Connection)

-- | The state of the connection.
connection_connectionState :: Lens.Lens' Connection (Prelude.Maybe ConnectionState)
connection_connectionState :: (Maybe ConnectionState -> f (Maybe ConnectionState))
-> Connection -> f Connection
connection_connectionState = (Connection -> Maybe ConnectionState)
-> (Connection -> Maybe ConnectionState -> Connection)
-> Lens
     Connection
     Connection
     (Maybe ConnectionState)
     (Maybe ConnectionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe ConnectionState
connectionState :: Maybe ConnectionState
$sel:connectionState:Connection' :: Connection -> Maybe ConnectionState
connectionState} -> Maybe ConnectionState
connectionState) (\s :: Connection
s@Connection' {} Maybe ConnectionState
a -> Connection
s {$sel:connectionState:Connection' :: Maybe ConnectionState
connectionState = Maybe ConnectionState
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 POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe ConnectionAuthorizationType
-> Maybe Text
-> Maybe Text
-> Maybe ConnectionState
-> Connection
Connection'
            (Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe ConnectionAuthorizationType
 -> Maybe Text
 -> Maybe Text
 -> Maybe ConnectionState
 -> Connection)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe ConnectionAuthorizationType
      -> Maybe Text
      -> Maybe Text
      -> Maybe ConnectionState
      -> Connection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreationTime")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe ConnectionAuthorizationType
   -> Maybe Text
   -> Maybe Text
   -> Maybe ConnectionState
   -> Connection)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe ConnectionAuthorizationType
      -> Maybe Text
      -> Maybe Text
      -> Maybe ConnectionState
      -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastModifiedTime")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe ConnectionAuthorizationType
   -> Maybe Text
   -> Maybe Text
   -> Maybe ConnectionState
   -> Connection)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe ConnectionAuthorizationType
      -> Maybe Text
      -> Maybe Text
      -> Maybe ConnectionState
      -> 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
"Name")
            Parser
  (Maybe POSIX
   -> Maybe ConnectionAuthorizationType
   -> Maybe Text
   -> Maybe Text
   -> Maybe ConnectionState
   -> Connection)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe ConnectionAuthorizationType
      -> Maybe Text -> Maybe Text -> Maybe ConnectionState -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastAuthorizedTime")
            Parser
  (Maybe ConnectionAuthorizationType
   -> Maybe Text -> Maybe Text -> Maybe ConnectionState -> Connection)
-> Parser (Maybe ConnectionAuthorizationType)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe ConnectionState -> Connection)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConnectionAuthorizationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AuthorizationType")
            Parser
  (Maybe Text -> Maybe Text -> Maybe ConnectionState -> Connection)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe ConnectionState -> 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
"ConnectionArn")
            Parser (Maybe Text -> Maybe ConnectionState -> Connection)
-> Parser (Maybe Text)
-> Parser (Maybe ConnectionState -> 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
"StateReason")
            Parser (Maybe ConnectionState -> Connection)
-> Parser (Maybe ConnectionState) -> Parser Connection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConnectionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionState")
      )

instance Prelude.Hashable Connection

instance Prelude.NFData Connection