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

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

-- | A resource that is used to connect third-party source providers with
-- services like AWS CodePipeline.
--
-- Note: A connection created through CloudFormation, the CLI, or the SDK
-- is in \`PENDING\` status by default. You can make its status
-- \`AVAILABLE\` by updating the connection in the console.
--
-- /See:/ 'newConnection' smart constructor.
data Connection = Connection'
  { -- | The identifier of the external provider where your third-party code
    -- repository is configured. For Bitbucket, this is the account ID of the
    -- owner of the Bitbucket repository.
    Connection -> Maybe Text
ownerAccountId :: Prelude.Maybe Prelude.Text,
    -- | The name of the external provider where your third-party code repository
    -- is configured.
    Connection -> Maybe ProviderType
providerType :: Prelude.Maybe ProviderType,
    -- | The name of the connection. Connection names must be unique in an AWS
    -- user account.
    Connection -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | The current status of the connection.
    Connection -> Maybe ConnectionStatus
connectionStatus :: Prelude.Maybe ConnectionStatus,
    -- | The Amazon Resource Name (ARN) of the host associated with the
    -- connection.
    Connection -> Maybe Text
hostArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the connection. The ARN is used as the
    -- connection reference when the connection is shared between AWS services.
    --
    -- The ARN is never reused if the connection is deleted.
    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:
--
-- 'ownerAccountId', 'connection_ownerAccountId' - The identifier of the external provider where your third-party code
-- repository is configured. For Bitbucket, this is the account ID of the
-- owner of the Bitbucket repository.
--
-- 'providerType', 'connection_providerType' - The name of the external provider where your third-party code repository
-- is configured.
--
-- 'connectionName', 'connection_connectionName' - The name of the connection. Connection names must be unique in an AWS
-- user account.
--
-- 'connectionStatus', 'connection_connectionStatus' - The current status of the connection.
--
-- 'hostArn', 'connection_hostArn' - The Amazon Resource Name (ARN) of the host associated with the
-- connection.
--
-- 'connectionArn', 'connection_connectionArn' - The Amazon Resource Name (ARN) of the connection. The ARN is used as the
-- connection reference when the connection is shared between AWS services.
--
-- The ARN is never reused if the connection is deleted.
newConnection ::
  Connection
newConnection :: Connection
newConnection =
  Connection' :: Maybe Text
-> Maybe ProviderType
-> Maybe Text
-> Maybe ConnectionStatus
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
    { $sel:ownerAccountId:Connection' :: Maybe Text
ownerAccountId = Maybe Text
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:connectionStatus:Connection' :: Maybe ConnectionStatus
connectionStatus = Maybe ConnectionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:hostArn:Connection' :: Maybe Text
hostArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionArn:Connection' :: Maybe Text
connectionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the external provider where your third-party code
-- repository is configured. For Bitbucket, this is the account ID of the
-- owner of the Bitbucket repository.
connection_ownerAccountId :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_ownerAccountId :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_ownerAccountId = (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
ownerAccountId :: Maybe Text
$sel:ownerAccountId:Connection' :: Connection -> Maybe Text
ownerAccountId} -> Maybe Text
ownerAccountId) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:ownerAccountId:Connection' :: Maybe Text
ownerAccountId = Maybe Text
a} :: Connection)

-- | The name of the external provider where your third-party code repository
-- is configured.
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 name of the connection. Connection names must be unique in an AWS
-- user account.
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 current status of the connection.
connection_connectionStatus :: Lens.Lens' Connection (Prelude.Maybe ConnectionStatus)
connection_connectionStatus :: (Maybe ConnectionStatus -> f (Maybe ConnectionStatus))
-> Connection -> f Connection
connection_connectionStatus = (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
connectionStatus :: Maybe ConnectionStatus
$sel:connectionStatus:Connection' :: Connection -> Maybe ConnectionStatus
connectionStatus} -> Maybe ConnectionStatus
connectionStatus) (\s :: Connection
s@Connection' {} Maybe ConnectionStatus
a -> Connection
s {$sel:connectionStatus:Connection' :: Maybe ConnectionStatus
connectionStatus = Maybe ConnectionStatus
a} :: Connection)

-- | The Amazon Resource Name (ARN) of the host associated with the
-- connection.
connection_hostArn :: Lens.Lens' Connection (Prelude.Maybe Prelude.Text)
connection_hostArn :: (Maybe Text -> f (Maybe Text)) -> Connection -> f Connection
connection_hostArn = (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
hostArn :: Maybe Text
$sel:hostArn:Connection' :: Connection -> Maybe Text
hostArn} -> Maybe Text
hostArn) (\s :: Connection
s@Connection' {} Maybe Text
a -> Connection
s {$sel:hostArn:Connection' :: Maybe Text
hostArn = Maybe Text
a} :: Connection)

-- | The Amazon Resource Name (ARN) of the connection. The ARN is used as the
-- connection reference when the connection is shared between AWS services.
--
-- The ARN is never reused if the connection is deleted.
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 Text
-> Maybe ProviderType
-> Maybe Text
-> Maybe ConnectionStatus
-> Maybe Text
-> Maybe Text
-> Connection
Connection'
            (Maybe Text
 -> Maybe ProviderType
 -> Maybe Text
 -> Maybe ConnectionStatus
 -> Maybe Text
 -> Maybe Text
 -> Connection)
-> Parser (Maybe Text)
-> Parser
     (Maybe ProviderType
      -> Maybe Text
      -> Maybe ConnectionStatus
      -> 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
"OwnerAccountId")
            Parser
  (Maybe ProviderType
   -> Maybe Text
   -> Maybe ConnectionStatus
   -> Maybe Text
   -> Maybe Text
   -> Connection)
-> Parser (Maybe ProviderType)
-> Parser
     (Maybe Text
      -> Maybe ConnectionStatus
      -> 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 ConnectionStatus
   -> Maybe Text
   -> Maybe Text
   -> Connection)
-> Parser (Maybe Text)
-> Parser
     (Maybe ConnectionStatus -> 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
"ConnectionName")
            Parser
  (Maybe ConnectionStatus -> Maybe Text -> Maybe Text -> Connection)
-> Parser (Maybe ConnectionStatus)
-> 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 ConnectionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionStatus")
            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
"HostArn")
            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