{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:analysisTypes:CodeReviewType' :: Maybe [AnalysisType]
analysisTypes = 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 :: Lens' CodeReviewType (Maybe [AnalysisType])
codeReviewType_analysisTypes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' CodeReviewType RepositoryAnalysis
codeReviewType_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 where
  hashWithSalt :: Int -> CodeReviewType -> Int
hashWithSalt Int
_salt CodeReviewType' {Maybe [AnalysisType]
RepositoryAnalysis
repositoryAnalysis :: RepositoryAnalysis
analysisTypes :: Maybe [AnalysisType]
$sel:repositoryAnalysis:CodeReviewType' :: CodeReviewType -> RepositoryAnalysis
$sel:analysisTypes:CodeReviewType' :: CodeReviewType -> Maybe [AnalysisType]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AnalysisType]
analysisTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RepositoryAnalysis
repositoryAnalysis

instance Prelude.NFData CodeReviewType where
  rnf :: CodeReviewType -> ()
rnf CodeReviewType' {Maybe [AnalysisType]
RepositoryAnalysis
repositoryAnalysis :: RepositoryAnalysis
analysisTypes :: Maybe [AnalysisType]
$sel:repositoryAnalysis:CodeReviewType' :: CodeReviewType -> RepositoryAnalysis
$sel:analysisTypes:CodeReviewType' :: CodeReviewType -> Maybe [AnalysisType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AnalysisType]
analysisTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RepositoryAnalysis
repositoryAnalysis

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AnalysisTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AnalysisType]
analysisTypes,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RepositoryAnalysis" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RepositoryAnalysis
repositoryAnalysis)
          ]
      )