{-# 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.CodeArtifacts
-- 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.CodeArtifacts 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

-- | Code artifacts are source code artifacts and build artifacts used in a
-- repository analysis or a pull request review.
--
-- -   Source code artifacts are source code files in a Git repository that
--     are compressed into a .zip file.
--
-- -   Build artifacts are .jar or .class files that are compressed in a
--     .zip file.
--
-- /See:/ 'newCodeArtifacts' smart constructor.
data CodeArtifacts = CodeArtifacts'
  { -- | The S3 object key for a build artifacts .zip file that contains .jar or
    -- .class files. This is required for a code review with security analysis.
    -- For more information, see
    -- <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/working-with-cicd.html Create code reviews with GitHub Actions>
    -- in the /Amazon CodeGuru Reviewer User Guide/.
    CodeArtifacts -> Maybe Text
buildArtifactsObjectKey :: Prelude.Maybe Prelude.Text,
    -- | The S3 object key for a source code .zip file. This is required for all
    -- code reviews.
    CodeArtifacts -> Text
sourceCodeArtifactsObjectKey :: Prelude.Text
  }
  deriving (CodeArtifacts -> CodeArtifacts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeArtifacts -> CodeArtifacts -> Bool
$c/= :: CodeArtifacts -> CodeArtifacts -> Bool
== :: CodeArtifacts -> CodeArtifacts -> Bool
$c== :: CodeArtifacts -> CodeArtifacts -> Bool
Prelude.Eq, ReadPrec [CodeArtifacts]
ReadPrec CodeArtifacts
Int -> ReadS CodeArtifacts
ReadS [CodeArtifacts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeArtifacts]
$creadListPrec :: ReadPrec [CodeArtifacts]
readPrec :: ReadPrec CodeArtifacts
$creadPrec :: ReadPrec CodeArtifacts
readList :: ReadS [CodeArtifacts]
$creadList :: ReadS [CodeArtifacts]
readsPrec :: Int -> ReadS CodeArtifacts
$creadsPrec :: Int -> ReadS CodeArtifacts
Prelude.Read, Int -> CodeArtifacts -> ShowS
[CodeArtifacts] -> ShowS
CodeArtifacts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeArtifacts] -> ShowS
$cshowList :: [CodeArtifacts] -> ShowS
show :: CodeArtifacts -> String
$cshow :: CodeArtifacts -> String
showsPrec :: Int -> CodeArtifacts -> ShowS
$cshowsPrec :: Int -> CodeArtifacts -> ShowS
Prelude.Show, forall x. Rep CodeArtifacts x -> CodeArtifacts
forall x. CodeArtifacts -> Rep CodeArtifacts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeArtifacts x -> CodeArtifacts
$cfrom :: forall x. CodeArtifacts -> Rep CodeArtifacts x
Prelude.Generic)

-- |
-- Create a value of 'CodeArtifacts' 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:
--
-- 'buildArtifactsObjectKey', 'codeArtifacts_buildArtifactsObjectKey' - The S3 object key for a build artifacts .zip file that contains .jar or
-- .class files. This is required for a code review with security analysis.
-- For more information, see
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/working-with-cicd.html Create code reviews with GitHub Actions>
-- in the /Amazon CodeGuru Reviewer User Guide/.
--
-- 'sourceCodeArtifactsObjectKey', 'codeArtifacts_sourceCodeArtifactsObjectKey' - The S3 object key for a source code .zip file. This is required for all
-- code reviews.
newCodeArtifacts ::
  -- | 'sourceCodeArtifactsObjectKey'
  Prelude.Text ->
  CodeArtifacts
newCodeArtifacts :: Text -> CodeArtifacts
newCodeArtifacts Text
pSourceCodeArtifactsObjectKey_ =
  CodeArtifacts'
    { $sel:buildArtifactsObjectKey:CodeArtifacts' :: Maybe Text
buildArtifactsObjectKey =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: Text
sourceCodeArtifactsObjectKey =
        Text
pSourceCodeArtifactsObjectKey_
    }

-- | The S3 object key for a build artifacts .zip file that contains .jar or
-- .class files. This is required for a code review with security analysis.
-- For more information, see
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-ug/working-with-cicd.html Create code reviews with GitHub Actions>
-- in the /Amazon CodeGuru Reviewer User Guide/.
codeArtifacts_buildArtifactsObjectKey :: Lens.Lens' CodeArtifacts (Prelude.Maybe Prelude.Text)
codeArtifacts_buildArtifactsObjectKey :: Lens' CodeArtifacts (Maybe Text)
codeArtifacts_buildArtifactsObjectKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeArtifacts' {Maybe Text
buildArtifactsObjectKey :: Maybe Text
$sel:buildArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Maybe Text
buildArtifactsObjectKey} -> Maybe Text
buildArtifactsObjectKey) (\s :: CodeArtifacts
s@CodeArtifacts' {} Maybe Text
a -> CodeArtifacts
s {$sel:buildArtifactsObjectKey:CodeArtifacts' :: Maybe Text
buildArtifactsObjectKey = Maybe Text
a} :: CodeArtifacts)

-- | The S3 object key for a source code .zip file. This is required for all
-- code reviews.
codeArtifacts_sourceCodeArtifactsObjectKey :: Lens.Lens' CodeArtifacts Prelude.Text
codeArtifacts_sourceCodeArtifactsObjectKey :: Lens' CodeArtifacts Text
codeArtifacts_sourceCodeArtifactsObjectKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeArtifacts' {Text
sourceCodeArtifactsObjectKey :: Text
$sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Text
sourceCodeArtifactsObjectKey} -> Text
sourceCodeArtifactsObjectKey) (\s :: CodeArtifacts
s@CodeArtifacts' {} Text
a -> CodeArtifacts
s {$sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: Text
sourceCodeArtifactsObjectKey = Text
a} :: CodeArtifacts)

instance Data.FromJSON CodeArtifacts where
  parseJSON :: Value -> Parser CodeArtifacts
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CodeArtifacts"
      ( \Object
x ->
          Maybe Text -> Text -> CodeArtifacts
CodeArtifacts'
            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
"BuildArtifactsObjectKey")
            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
"SourceCodeArtifactsObjectKey")
      )

instance Prelude.Hashable CodeArtifacts where
  hashWithSalt :: Int -> CodeArtifacts -> Int
hashWithSalt Int
_salt CodeArtifacts' {Maybe Text
Text
sourceCodeArtifactsObjectKey :: Text
buildArtifactsObjectKey :: Maybe Text
$sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Text
$sel:buildArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
buildArtifactsObjectKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceCodeArtifactsObjectKey

instance Prelude.NFData CodeArtifacts where
  rnf :: CodeArtifacts -> ()
rnf CodeArtifacts' {Maybe Text
Text
sourceCodeArtifactsObjectKey :: Text
buildArtifactsObjectKey :: Maybe Text
$sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Text
$sel:buildArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
buildArtifactsObjectKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceCodeArtifactsObjectKey

instance Data.ToJSON CodeArtifacts where
  toJSON :: CodeArtifacts -> Value
toJSON CodeArtifacts' {Maybe Text
Text
sourceCodeArtifactsObjectKey :: Text
buildArtifactsObjectKey :: Maybe Text
$sel:sourceCodeArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Text
$sel:buildArtifactsObjectKey:CodeArtifacts' :: CodeArtifacts -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BuildArtifactsObjectKey" 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 Text
buildArtifactsObjectKey,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"SourceCodeArtifactsObjectKey"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceCodeArtifactsObjectKey
              )
          ]
      )