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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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/code-review-security.html Create code reviews with security analysis>
    -- 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
(CodeArtifacts -> CodeArtifacts -> Bool)
-> (CodeArtifacts -> CodeArtifacts -> Bool) -> Eq CodeArtifacts
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]
(Int -> ReadS CodeArtifacts)
-> ReadS [CodeArtifacts]
-> ReadPrec CodeArtifacts
-> ReadPrec [CodeArtifacts]
-> Read 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
(Int -> CodeArtifacts -> ShowS)
-> (CodeArtifacts -> String)
-> ([CodeArtifacts] -> ShowS)
-> Show CodeArtifacts
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. CodeArtifacts -> Rep CodeArtifacts x)
-> (forall x. Rep CodeArtifacts x -> CodeArtifacts)
-> Generic CodeArtifacts
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/code-review-security.html Create code reviews with security analysis>
-- 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' :: Maybe Text -> Text -> CodeArtifacts
CodeArtifacts'
    { $sel:buildArtifactsObjectKey:CodeArtifacts' :: Maybe Text
buildArtifactsObjectKey =
        Maybe Text
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/code-review-security.html Create code reviews with security analysis>
-- in the /Amazon CodeGuru Reviewer User Guide/.
codeArtifacts_buildArtifactsObjectKey :: Lens.Lens' CodeArtifacts (Prelude.Maybe Prelude.Text)
codeArtifacts_buildArtifactsObjectKey :: (Maybe Text -> f (Maybe Text)) -> CodeArtifacts -> f CodeArtifacts
codeArtifacts_buildArtifactsObjectKey = (CodeArtifacts -> Maybe Text)
-> (CodeArtifacts -> Maybe Text -> CodeArtifacts)
-> Lens CodeArtifacts CodeArtifacts (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> CodeArtifacts -> f CodeArtifacts
codeArtifacts_sourceCodeArtifactsObjectKey = (CodeArtifacts -> Text)
-> (CodeArtifacts -> Text -> CodeArtifacts)
-> Lens CodeArtifacts CodeArtifacts Text Text
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 Core.FromJSON CodeArtifacts where
  parseJSON :: Value -> Parser CodeArtifacts
parseJSON =
    String
-> (Object -> Parser CodeArtifacts)
-> Value
-> Parser CodeArtifacts
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeArtifacts"
      ( \Object
x ->
          Maybe Text -> Text -> CodeArtifacts
CodeArtifacts'
            (Maybe Text -> Text -> CodeArtifacts)
-> Parser (Maybe Text) -> Parser (Text -> CodeArtifacts)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BuildArtifactsObjectKey")
            Parser (Text -> CodeArtifacts)
-> Parser Text -> Parser CodeArtifacts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceCodeArtifactsObjectKey")
      )

instance Prelude.Hashable CodeArtifacts

instance Prelude.NFData CodeArtifacts

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BuildArtifactsObjectKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
buildArtifactsObjectKey,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"SourceCodeArtifactsObjectKey"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceCodeArtifactsObjectKey
              )
          ]
      )