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

import Amazonka.CodeGuruReviewer.Types.CodeCommitRepository
import Amazonka.CodeGuruReviewer.Types.S3Repository
import Amazonka.CodeGuruReviewer.Types.ThirdPartySourceRepository
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an associated Amazon Web Services CodeCommit
-- repository or an associated repository that is managed by Amazon Web
-- Services CodeStar Connections (for example, Bitbucket). This
-- @Repository@ object is not used if your source code is in an associated
-- GitHub repository.
--
-- /See:/ 'newRepository' smart constructor.
data Repository = Repository'
  { -- | Information about an Amazon Web Services CodeCommit repository.
    Repository -> Maybe CodeCommitRepository
codeCommit :: Prelude.Maybe CodeCommitRepository,
    -- | Information about a GitHub Enterprise Server repository.
    Repository -> Maybe ThirdPartySourceRepository
gitHubEnterpriseServer :: Prelude.Maybe ThirdPartySourceRepository,
    Repository -> Maybe S3Repository
s3Bucket :: Prelude.Maybe S3Repository,
    -- | Information about a Bitbucket repository.
    Repository -> Maybe ThirdPartySourceRepository
bitbucket :: Prelude.Maybe ThirdPartySourceRepository
  }
  deriving (Repository -> Repository -> Bool
(Repository -> Repository -> Bool)
-> (Repository -> Repository -> Bool) -> Eq Repository
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]
(Int -> ReadS Repository)
-> ReadS [Repository]
-> ReadPrec Repository
-> ReadPrec [Repository]
-> Read 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
(Int -> Repository -> ShowS)
-> (Repository -> String)
-> ([Repository] -> ShowS)
-> Show Repository
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. Repository -> Rep Repository x)
-> (forall x. Rep Repository x -> Repository) -> Generic Repository
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:
--
-- 'codeCommit', 'repository_codeCommit' - Information about an Amazon Web Services CodeCommit repository.
--
-- 'gitHubEnterpriseServer', 'repository_gitHubEnterpriseServer' - Information about a GitHub Enterprise Server repository.
--
-- 's3Bucket', 'repository_s3Bucket' - Undocumented member.
--
-- 'bitbucket', 'repository_bitbucket' - Information about a Bitbucket repository.
newRepository ::
  Repository
newRepository :: Repository
newRepository =
  Repository' :: Maybe CodeCommitRepository
-> Maybe ThirdPartySourceRepository
-> Maybe S3Repository
-> Maybe ThirdPartySourceRepository
-> Repository
Repository'
    { $sel:codeCommit:Repository' :: Maybe CodeCommitRepository
codeCommit = Maybe CodeCommitRepository
forall a. Maybe a
Prelude.Nothing,
      $sel:gitHubEnterpriseServer:Repository' :: Maybe ThirdPartySourceRepository
gitHubEnterpriseServer = Maybe ThirdPartySourceRepository
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:Repository' :: Maybe S3Repository
s3Bucket = Maybe S3Repository
forall a. Maybe a
Prelude.Nothing,
      $sel:bitbucket:Repository' :: Maybe ThirdPartySourceRepository
bitbucket = Maybe ThirdPartySourceRepository
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about an Amazon Web Services CodeCommit repository.
repository_codeCommit :: Lens.Lens' Repository (Prelude.Maybe CodeCommitRepository)
repository_codeCommit :: (Maybe CodeCommitRepository -> f (Maybe CodeCommitRepository))
-> Repository -> f Repository
repository_codeCommit = (Repository -> Maybe CodeCommitRepository)
-> (Repository -> Maybe CodeCommitRepository -> Repository)
-> Lens
     Repository
     Repository
     (Maybe CodeCommitRepository)
     (Maybe CodeCommitRepository)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Maybe CodeCommitRepository
codeCommit :: Maybe CodeCommitRepository
$sel:codeCommit:Repository' :: Repository -> Maybe CodeCommitRepository
codeCommit} -> Maybe CodeCommitRepository
codeCommit) (\s :: Repository
s@Repository' {} Maybe CodeCommitRepository
a -> Repository
s {$sel:codeCommit:Repository' :: Maybe CodeCommitRepository
codeCommit = Maybe CodeCommitRepository
a} :: Repository)

-- | Information about a GitHub Enterprise Server repository.
repository_gitHubEnterpriseServer :: Lens.Lens' Repository (Prelude.Maybe ThirdPartySourceRepository)
repository_gitHubEnterpriseServer :: (Maybe ThirdPartySourceRepository
 -> f (Maybe ThirdPartySourceRepository))
-> Repository -> f Repository
repository_gitHubEnterpriseServer = (Repository -> Maybe ThirdPartySourceRepository)
-> (Repository -> Maybe ThirdPartySourceRepository -> Repository)
-> Lens
     Repository
     Repository
     (Maybe ThirdPartySourceRepository)
     (Maybe ThirdPartySourceRepository)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Maybe ThirdPartySourceRepository
gitHubEnterpriseServer :: Maybe ThirdPartySourceRepository
$sel:gitHubEnterpriseServer:Repository' :: Repository -> Maybe ThirdPartySourceRepository
gitHubEnterpriseServer} -> Maybe ThirdPartySourceRepository
gitHubEnterpriseServer) (\s :: Repository
s@Repository' {} Maybe ThirdPartySourceRepository
a -> Repository
s {$sel:gitHubEnterpriseServer:Repository' :: Maybe ThirdPartySourceRepository
gitHubEnterpriseServer = Maybe ThirdPartySourceRepository
a} :: Repository)

-- | Undocumented member.
repository_s3Bucket :: Lens.Lens' Repository (Prelude.Maybe S3Repository)
repository_s3Bucket :: (Maybe S3Repository -> f (Maybe S3Repository))
-> Repository -> f Repository
repository_s3Bucket = (Repository -> Maybe S3Repository)
-> (Repository -> Maybe S3Repository -> Repository)
-> Lens
     Repository Repository (Maybe S3Repository) (Maybe S3Repository)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Maybe S3Repository
s3Bucket :: Maybe S3Repository
$sel:s3Bucket:Repository' :: Repository -> Maybe S3Repository
s3Bucket} -> Maybe S3Repository
s3Bucket) (\s :: Repository
s@Repository' {} Maybe S3Repository
a -> Repository
s {$sel:s3Bucket:Repository' :: Maybe S3Repository
s3Bucket = Maybe S3Repository
a} :: Repository)

-- | Information about a Bitbucket repository.
repository_bitbucket :: Lens.Lens' Repository (Prelude.Maybe ThirdPartySourceRepository)
repository_bitbucket :: (Maybe ThirdPartySourceRepository
 -> f (Maybe ThirdPartySourceRepository))
-> Repository -> f Repository
repository_bitbucket = (Repository -> Maybe ThirdPartySourceRepository)
-> (Repository -> Maybe ThirdPartySourceRepository -> Repository)
-> Lens
     Repository
     Repository
     (Maybe ThirdPartySourceRepository)
     (Maybe ThirdPartySourceRepository)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Repository' {Maybe ThirdPartySourceRepository
bitbucket :: Maybe ThirdPartySourceRepository
$sel:bitbucket:Repository' :: Repository -> Maybe ThirdPartySourceRepository
bitbucket} -> Maybe ThirdPartySourceRepository
bitbucket) (\s :: Repository
s@Repository' {} Maybe ThirdPartySourceRepository
a -> Repository
s {$sel:bitbucket:Repository' :: Maybe ThirdPartySourceRepository
bitbucket = Maybe ThirdPartySourceRepository
a} :: Repository)

instance Prelude.Hashable Repository

instance Prelude.NFData Repository

instance Core.ToJSON Repository where
  toJSON :: Repository -> Value
toJSON Repository' {Maybe CodeCommitRepository
Maybe S3Repository
Maybe ThirdPartySourceRepository
bitbucket :: Maybe ThirdPartySourceRepository
s3Bucket :: Maybe S3Repository
gitHubEnterpriseServer :: Maybe ThirdPartySourceRepository
codeCommit :: Maybe CodeCommitRepository
$sel:bitbucket:Repository' :: Repository -> Maybe ThirdPartySourceRepository
$sel:s3Bucket:Repository' :: Repository -> Maybe S3Repository
$sel:gitHubEnterpriseServer:Repository' :: Repository -> Maybe ThirdPartySourceRepository
$sel:codeCommit:Repository' :: Repository -> Maybe CodeCommitRepository
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CodeCommit" Text -> CodeCommitRepository -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CodeCommitRepository -> Pair)
-> Maybe CodeCommitRepository -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CodeCommitRepository
codeCommit,
            (Text
"GitHubEnterpriseServer" Text -> ThirdPartySourceRepository -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ThirdPartySourceRepository -> Pair)
-> Maybe ThirdPartySourceRepository -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ThirdPartySourceRepository
gitHubEnterpriseServer,
            (Text
"S3Bucket" Text -> S3Repository -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3Repository -> Pair) -> Maybe S3Repository -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Repository
s3Bucket,
            (Text
"Bitbucket" Text -> ThirdPartySourceRepository -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ThirdPartySourceRepository -> Pair)
-> Maybe ThirdPartySourceRepository -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ThirdPartySourceRepository
bitbucket
          ]
      )