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

import Amazonka.AppRunner.Types.ConnectionStatus
import Amazonka.AppRunner.Types.ProviderType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an App Runner connection resource.
--
-- /See:/ 'newConnection' smart constructor.
data Connection = Connection'
  { -- | The current state of the App Runner connection. When the state is
    -- @AVAILABLE@, you can use the connection to create an App Runner service.
    Connection -> Maybe ConnectionStatus
status :: Prelude.Maybe ConnectionStatus,
    -- | The App Runner connection creation time, expressed as a Unix time stamp.
    Connection -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The source repository provider.
    Connection -> Maybe ProviderType
providerType :: Prelude.Maybe ProviderType,
    -- | The customer-provided connection name.
    Connection -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of this connection.
    Connection -> Maybe Text
connectionArn :: 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 current state of the App Runner connection. When the state is
-- @AVAILABLE@, you can use the connection to create an App Runner service.
--
-- 'createdAt', 'connection_createdAt' - The App Runner connection creation time, expressed as a Unix time stamp.
--
-- 'providerType', 'connection_providerType' - The source repository provider.
--
-- 'connectionName', 'connection_connectionName' - The customer-provided connection name.
--
-- 'connectionArn', 'connection_connectionArn' - The Amazon Resource Name (ARN) of this connection.
newConnection ::
  Connection
newConnection :: Connection
newConnection =
  Connection' :: Maybe ConnectionStatus
-> Maybe POSIX
-> Maybe ProviderType
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
    { $sel:status:Connection' :: Maybe ConnectionStatus
status = Maybe ConnectionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:Connection' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:providerType:Connection' :: Maybe ProviderType
providerType = Maybe ProviderType
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionName:Connection' :: Maybe Text
connectionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionArn:Connection' :: Maybe Text
connectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the App Runner connection. When the state is
-- @AVAILABLE@, you can use the connection to create an App Runner service.
connection_status :: Lens.Lens' Connection (Prelude.Maybe ConnectionStatus)
connection_status :: (Maybe ConnectionStatus -> f (Maybe ConnectionStatus))
-> Connection -> f Connection
connection_status = (Connection -> Maybe ConnectionStatus)
-> (Connection -> Maybe ConnectionStatus -> Connection)
-> Lens
     Connection
     Connection
     (Maybe ConnectionStatus)
     (Maybe ConnectionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe ConnectionStatus
status :: Maybe ConnectionStatus
$sel:status:Connection' :: Connection -> Maybe ConnectionStatus
status} -> Maybe ConnectionStatus
status) (\s :: Connection
s@Connection' {} Maybe ConnectionStatus
a -> Connection
s {$sel:status:Connection' :: Maybe ConnectionStatus
status = Maybe ConnectionStatus
a} :: Connection)

-- | The App Runner connection creation time, expressed as a Unix time stamp.
connection_createdAt :: Lens.Lens' Connection (Prelude.Maybe Prelude.UTCTime)
connection_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Connection -> f Connection
connection_createdAt = (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
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) ((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 source repository provider.
connection_providerType :: Lens.Lens' Connection (Prelude.Maybe ProviderType)
connection_providerType :: (Maybe ProviderType -> f (Maybe ProviderType))
-> Connection -> f Connection
connection_providerType = (Connection -> Maybe ProviderType)
-> (Connection -> Maybe ProviderType -> Connection)
-> Lens
     Connection Connection (Maybe ProviderType) (Maybe ProviderType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Connection' {Maybe ProviderType
providerType :: Maybe ProviderType
$sel:providerType:Connection' :: Connection -> Maybe ProviderType
providerType} -> Maybe ProviderType
providerType) (\s :: Connection
s@Connection' {} Maybe ProviderType
a -> Connection
s {$sel:providerType:Connection' :: Maybe ProviderType
providerType = Maybe ProviderType
a} :: Connection)

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

-- | The Amazon Resource Name (ARN) of this 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)

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 ConnectionStatus
-> Maybe POSIX
-> Maybe ProviderType
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
            (Maybe ConnectionStatus
 -> Maybe POSIX
 -> Maybe ProviderType
 -> Maybe Text
 -> Maybe Text
 -> Connection)
-> Parser (Maybe ConnectionStatus)
-> Parser
     (Maybe POSIX
      -> Maybe ProviderType -> Maybe Text -> Maybe Text -> Connection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ConnectionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe POSIX
   -> Maybe ProviderType -> Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe ProviderType -> 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 POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedAt")
            Parser
  (Maybe ProviderType -> Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe ProviderType)
-> 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 ProviderType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProviderType")
            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
"ConnectionName")
            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
"ConnectionArn")
      )

instance Prelude.Hashable Connection

instance Prelude.NFData Connection