{-# 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.CodeReviewType
-- 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.CodeReviewType where

import Amazonka.CodeGuruReviewer.Types.AnalysisType
import Amazonka.CodeGuruReviewer.Types.RepositoryAnalysis
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The type of a code review. There are two code review types:
--
-- -   @PullRequest@ - A code review that is automatically triggered by a
--     pull request on an associated repository.
--
-- -   @RepositoryAnalysis@ - A code review that analyzes all code under a
--     specified branch in an associated repository. The associated
--     repository is specified using its ARN in
--     <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CreateCodeReview CreateCodeReview>
--     .
--
-- /See:/ 'newCodeReviewType' smart constructor.
data CodeReviewType = CodeReviewType'
  { -- | They types of analysis performed during a repository analysis or a pull
    -- request review. You can specify either @Security@, @CodeQuality@, or
    -- both.
    CodeReviewType -> Maybe [AnalysisType]
analysisTypes :: Prelude.Maybe [AnalysisType],
    -- | A code review that analyzes all code under a specified branch in an
    -- associated repository. The associated repository is specified using its
    -- ARN in
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CreateCodeReview CreateCodeReview>
    -- .
    CodeReviewType -> RepositoryAnalysis
repositoryAnalysis :: RepositoryAnalysis
  }
  deriving (CodeReviewType -> CodeReviewType -> Bool
(CodeReviewType -> CodeReviewType -> Bool)
-> (CodeReviewType -> CodeReviewType -> Bool) -> Eq CodeReviewType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeReviewType -> CodeReviewType -> Bool
$c/= :: CodeReviewType -> CodeReviewType -> Bool
== :: CodeReviewType -> CodeReviewType -> Bool
$c== :: CodeReviewType -> CodeReviewType -> Bool
Prelude.Eq, ReadPrec [CodeReviewType]
ReadPrec CodeReviewType
Int -> ReadS CodeReviewType
ReadS [CodeReviewType]
(Int -> ReadS CodeReviewType)
-> ReadS [CodeReviewType]
-> ReadPrec CodeReviewType
-> ReadPrec [CodeReviewType]
-> Read CodeReviewType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeReviewType]
$creadListPrec :: ReadPrec [CodeReviewType]
readPrec :: ReadPrec CodeReviewType
$creadPrec :: ReadPrec CodeReviewType
readList :: ReadS [CodeReviewType]
$creadList :: ReadS [CodeReviewType]
readsPrec :: Int -> ReadS CodeReviewType
$creadsPrec :: Int -> ReadS CodeReviewType
Prelude.Read, Int -> CodeReviewType -> ShowS
[CodeReviewType] -> ShowS
CodeReviewType -> String
(Int -> CodeReviewType -> ShowS)
-> (CodeReviewType -> String)
-> ([CodeReviewType] -> ShowS)
-> Show CodeReviewType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeReviewType] -> ShowS
$cshowList :: [CodeReviewType] -> ShowS
show :: CodeReviewType -> String
$cshow :: CodeReviewType -> String
showsPrec :: Int -> CodeReviewType -> ShowS
$cshowsPrec :: Int -> CodeReviewType -> ShowS
Prelude.Show, (forall x. CodeReviewType -> Rep CodeReviewType x)
-> (forall x. Rep CodeReviewType x -> CodeReviewType)
-> Generic CodeReviewType
forall x. Rep CodeReviewType x -> CodeReviewType
forall x. CodeReviewType -> Rep CodeReviewType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeReviewType x -> CodeReviewType
$cfrom :: forall x. CodeReviewType -> Rep CodeReviewType x
Prelude.Generic)

-- |
-- Create a value of 'CodeReviewType' 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:
--
-- 'analysisTypes', 'codeReviewType_analysisTypes' - They types of analysis performed during a repository analysis or a pull
-- request review. You can specify either @Security@, @CodeQuality@, or
-- both.
--
-- 'repositoryAnalysis', 'codeReviewType_repositoryAnalysis' - A code review that analyzes all code under a specified branch in an
-- associated repository. The associated repository is specified using its
-- ARN in
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CreateCodeReview CreateCodeReview>
-- .
newCodeReviewType ::
  -- | 'repositoryAnalysis'
  RepositoryAnalysis ->
  CodeReviewType
newCodeReviewType :: RepositoryAnalysis -> CodeReviewType
newCodeReviewType RepositoryAnalysis
pRepositoryAnalysis_ =
  CodeReviewType' :: Maybe [AnalysisType] -> RepositoryAnalysis -> CodeReviewType
CodeReviewType'
    { $sel:analysisTypes:CodeReviewType' :: Maybe [AnalysisType]
analysisTypes = Maybe [AnalysisType]
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryAnalysis:CodeReviewType' :: RepositoryAnalysis
repositoryAnalysis = RepositoryAnalysis
pRepositoryAnalysis_
    }

-- | They types of analysis performed during a repository analysis or a pull
-- request review. You can specify either @Security@, @CodeQuality@, or
-- both.
codeReviewType_analysisTypes :: Lens.Lens' CodeReviewType (Prelude.Maybe [AnalysisType])
codeReviewType_analysisTypes :: (Maybe [AnalysisType] -> f (Maybe [AnalysisType]))
-> CodeReviewType -> f CodeReviewType
codeReviewType_analysisTypes = (CodeReviewType -> Maybe [AnalysisType])
-> (CodeReviewType -> Maybe [AnalysisType] -> CodeReviewType)
-> Lens
     CodeReviewType
     CodeReviewType
     (Maybe [AnalysisType])
     (Maybe [AnalysisType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeReviewType' {Maybe [AnalysisType]
analysisTypes :: Maybe [AnalysisType]
$sel:analysisTypes:CodeReviewType' :: CodeReviewType -> Maybe [AnalysisType]
analysisTypes} -> Maybe [AnalysisType]
analysisTypes) (\s :: CodeReviewType
s@CodeReviewType' {} Maybe [AnalysisType]
a -> CodeReviewType
s {$sel:analysisTypes:CodeReviewType' :: Maybe [AnalysisType]
analysisTypes = Maybe [AnalysisType]
a} :: CodeReviewType) ((Maybe [AnalysisType] -> f (Maybe [AnalysisType]))
 -> CodeReviewType -> f CodeReviewType)
-> ((Maybe [AnalysisType] -> f (Maybe [AnalysisType]))
    -> Maybe [AnalysisType] -> f (Maybe [AnalysisType]))
-> (Maybe [AnalysisType] -> f (Maybe [AnalysisType]))
-> CodeReviewType
-> f CodeReviewType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AnalysisType] [AnalysisType] [AnalysisType] [AnalysisType]
-> Iso
     (Maybe [AnalysisType])
     (Maybe [AnalysisType])
     (Maybe [AnalysisType])
     (Maybe [AnalysisType])
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 [AnalysisType] [AnalysisType] [AnalysisType] [AnalysisType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A code review that analyzes all code under a specified branch in an
-- associated repository. The associated repository is specified using its
-- ARN in
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_CreateCodeReview CreateCodeReview>
-- .
codeReviewType_repositoryAnalysis :: Lens.Lens' CodeReviewType RepositoryAnalysis
codeReviewType_repositoryAnalysis :: (RepositoryAnalysis -> f RepositoryAnalysis)
-> CodeReviewType -> f CodeReviewType
codeReviewType_repositoryAnalysis = (CodeReviewType -> RepositoryAnalysis)
-> (CodeReviewType -> RepositoryAnalysis -> CodeReviewType)
-> Lens
     CodeReviewType CodeReviewType RepositoryAnalysis RepositoryAnalysis
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeReviewType' {RepositoryAnalysis
repositoryAnalysis :: RepositoryAnalysis
$sel:repositoryAnalysis:CodeReviewType' :: CodeReviewType -> RepositoryAnalysis
repositoryAnalysis} -> RepositoryAnalysis
repositoryAnalysis) (\s :: CodeReviewType
s@CodeReviewType' {} RepositoryAnalysis
a -> CodeReviewType
s {$sel:repositoryAnalysis:CodeReviewType' :: RepositoryAnalysis
repositoryAnalysis = RepositoryAnalysis
a} :: CodeReviewType)

instance Prelude.Hashable CodeReviewType

instance Prelude.NFData CodeReviewType

instance Core.ToJSON CodeReviewType where
  toJSON :: CodeReviewType -> Value
toJSON CodeReviewType' {Maybe [AnalysisType]
RepositoryAnalysis
repositoryAnalysis :: RepositoryAnalysis
analysisTypes :: Maybe [AnalysisType]
$sel:repositoryAnalysis:CodeReviewType' :: CodeReviewType -> RepositoryAnalysis
$sel:analysisTypes:CodeReviewType' :: CodeReviewType -> Maybe [AnalysisType]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AnalysisTypes" Text -> [AnalysisType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AnalysisType] -> Pair) -> Maybe [AnalysisType] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AnalysisType]
analysisTypes,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RepositoryAnalysis" Text -> RepositoryAnalysis -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RepositoryAnalysis
repositoryAnalysis)
          ]
      )