{-# 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.Proton.Types.Repository
-- 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.Proton.Types.Repository where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Proton.Types.RepositoryProvider

-- | Detailed data of a linked repository—a repository that has been
-- registered with Proton.
--
-- /See:/ 'newRepository' smart constructor.
data Repository = Repository'
  { -- | Your customer Amazon Web Services KMS encryption key.
    Repository -> Maybe Text
encryptionKey :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the linked repository.
    Repository -> Text
arn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of your AWS CodeStar connection that
    -- connects Proton to your repository provider account.
    Repository -> Text
connectionArn :: Prelude.Text,
    -- | The repository name.
    Repository -> Text
name :: Prelude.Text,
    -- | The repository provider.
    Repository -> RepositoryProvider
provider :: RepositoryProvider
  }
  deriving (Repository -> Repository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Repository -> Repository -> Bool
$c/= :: Repository -> Repository -> Bool
== :: Repository -> Repository -> Bool
$c== :: Repository -> Repository -> Bool
Prelude.Eq, ReadPrec [Repository]
ReadPrec Repository
Int -> ReadS Repository
ReadS [Repository]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Repository]
$creadListPrec :: ReadPrec [Repository]
readPrec :: ReadPrec Repository
$creadPrec :: ReadPrec Repository
readList :: ReadS [Repository]
$creadList :: ReadS [Repository]
readsPrec :: Int -> ReadS Repository
$creadsPrec :: Int -> ReadS Repository
Prelude.Read, Int -> Repository -> ShowS
[Repository] -> ShowS
Repository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Repository] -> ShowS
$cshowList :: [Repository] -> ShowS
show :: Repository -> String
$cshow :: Repository -> String
showsPrec :: Int -> Repository -> ShowS
$cshowsPrec :: Int -> Repository -> ShowS
Prelude.Show, forall x. Rep Repository x -> Repository
forall x. Repository -> Rep Repository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Repository x -> Repository
$cfrom :: forall x. Repository -> Rep Repository x
Prelude.Generic)

-- |
-- Create a value of 'Repository' 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:
--
-- 'encryptionKey', 'repository_encryptionKey' - Your customer Amazon Web Services KMS encryption key.
--
-- 'arn', 'repository_arn' - The Amazon Resource Name (ARN) of the linked repository.
--
-- 'connectionArn', 'repository_connectionArn' - The Amazon Resource Name (ARN) of your AWS CodeStar connection that
-- connects Proton to your repository provider account.
--
-- 'name', 'repository_name' - The repository name.
--
-- 'provider', 'repository_provider' - The repository provider.
newRepository ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'connectionArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'provider'
  RepositoryProvider ->
  Repository
newRepository :: Text -> Text -> Text -> RepositoryProvider -> Repository
newRepository Text
pArn_ Text
pConnectionArn_ Text
pName_ RepositoryProvider
pProvider_ =
  Repository'
    { $sel:encryptionKey:Repository' :: Maybe Text
encryptionKey = forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Repository' :: Text
arn = Text
pArn_,
      $sel:connectionArn:Repository' :: Text
connectionArn = Text
pConnectionArn_,
      $sel:name:Repository' :: Text
name = Text
pName_,
      $sel:provider:Repository' :: RepositoryProvider
provider = RepositoryProvider
pProvider_
    }

-- | Your customer Amazon Web Services KMS encryption key.
repository_encryptionKey :: Lens.Lens' Repository (Prelude.Maybe Prelude.Text)
repository_encryptionKey :: Lens' Repository (Maybe Text)
repository_encryptionKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Maybe Text
encryptionKey :: Maybe Text
$sel:encryptionKey:Repository' :: Repository -> Maybe Text
encryptionKey} -> Maybe Text
encryptionKey) (\s :: Repository
s@Repository' {} Maybe Text
a -> Repository
s {$sel:encryptionKey:Repository' :: Maybe Text
encryptionKey = Maybe Text
a} :: Repository)

-- | The Amazon Resource Name (ARN) of the linked repository.
repository_arn :: Lens.Lens' Repository Prelude.Text
repository_arn :: Lens' Repository Text
repository_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Text
arn :: Text
$sel:arn:Repository' :: Repository -> Text
arn} -> Text
arn) (\s :: Repository
s@Repository' {} Text
a -> Repository
s {$sel:arn:Repository' :: Text
arn = Text
a} :: Repository)

-- | The Amazon Resource Name (ARN) of your AWS CodeStar connection that
-- connects Proton to your repository provider account.
repository_connectionArn :: Lens.Lens' Repository Prelude.Text
repository_connectionArn :: Lens' Repository Text
repository_connectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Text
connectionArn :: Text
$sel:connectionArn:Repository' :: Repository -> Text
connectionArn} -> Text
connectionArn) (\s :: Repository
s@Repository' {} Text
a -> Repository
s {$sel:connectionArn:Repository' :: Text
connectionArn = Text
a} :: Repository)

-- | The repository name.
repository_name :: Lens.Lens' Repository Prelude.Text
repository_name :: Lens' Repository Text
repository_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Text
name :: Text
$sel:name:Repository' :: Repository -> Text
name} -> Text
name) (\s :: Repository
s@Repository' {} Text
a -> Repository
s {$sel:name:Repository' :: Text
name = Text
a} :: Repository)

-- | The repository provider.
repository_provider :: Lens.Lens' Repository RepositoryProvider
repository_provider :: Lens' Repository RepositoryProvider
repository_provider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {RepositoryProvider
provider :: RepositoryProvider
$sel:provider:Repository' :: Repository -> RepositoryProvider
provider} -> RepositoryProvider
provider) (\s :: Repository
s@Repository' {} RepositoryProvider
a -> Repository
s {$sel:provider:Repository' :: RepositoryProvider
provider = RepositoryProvider
a} :: Repository)

instance Data.FromJSON Repository where
  parseJSON :: Value -> Parser Repository
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Repository"
      ( \Object
x ->
          Maybe Text
-> Text -> Text -> Text -> RepositoryProvider -> Repository
Repository'
            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
"encryptionKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser 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 a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"provider")
      )

instance Prelude.Hashable Repository where
  hashWithSalt :: Int -> Repository -> Int
hashWithSalt Int
_salt Repository' {Maybe Text
Text
RepositoryProvider
provider :: RepositoryProvider
name :: Text
connectionArn :: Text
arn :: Text
encryptionKey :: Maybe Text
$sel:provider:Repository' :: Repository -> RepositoryProvider
$sel:name:Repository' :: Repository -> Text
$sel:connectionArn:Repository' :: Repository -> Text
$sel:arn:Repository' :: Repository -> Text
$sel:encryptionKey:Repository' :: Repository -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
encryptionKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RepositoryProvider
provider

instance Prelude.NFData Repository where
  rnf :: Repository -> ()
rnf Repository' {Maybe Text
Text
RepositoryProvider
provider :: RepositoryProvider
name :: Text
connectionArn :: Text
arn :: Text
encryptionKey :: Maybe Text
$sel:provider:Repository' :: Repository -> RepositoryProvider
$sel:name:Repository' :: Repository -> Text
$sel:connectionArn:Repository' :: Repository -> Text
$sel:arn:Repository' :: Repository -> Text
$sel:encryptionKey:Repository' :: Repository -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
encryptionKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
connectionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RepositoryProvider
provider