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

import Amazonka.CodeGuruReviewer.Types.CodeArtifacts
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

-- | Specifies the name of an S3 bucket and a @CodeArtifacts@ object that
-- contains the S3 object keys for a source code .zip file and for a build
-- artifacts .zip file that contains .jar or .class files.
--
-- /See:/ 'newS3RepositoryDetails' smart constructor.
data S3RepositoryDetails = S3RepositoryDetails'
  { -- | The name of the S3 bucket used for associating a new S3 repository. It
    -- must begin with @codeguru-reviewer-@.
    S3RepositoryDetails -> Maybe Text
bucketName :: Prelude.Maybe Prelude.Text,
    -- | A @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
    -- object key for a source code .zip file and for a build artifacts .zip
    -- file that contains .jar or .class files.
    S3RepositoryDetails -> Maybe CodeArtifacts
codeArtifacts :: Prelude.Maybe CodeArtifacts
  }
  deriving (S3RepositoryDetails -> S3RepositoryDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3RepositoryDetails -> S3RepositoryDetails -> Bool
$c/= :: S3RepositoryDetails -> S3RepositoryDetails -> Bool
== :: S3RepositoryDetails -> S3RepositoryDetails -> Bool
$c== :: S3RepositoryDetails -> S3RepositoryDetails -> Bool
Prelude.Eq, ReadPrec [S3RepositoryDetails]
ReadPrec S3RepositoryDetails
Int -> ReadS S3RepositoryDetails
ReadS [S3RepositoryDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3RepositoryDetails]
$creadListPrec :: ReadPrec [S3RepositoryDetails]
readPrec :: ReadPrec S3RepositoryDetails
$creadPrec :: ReadPrec S3RepositoryDetails
readList :: ReadS [S3RepositoryDetails]
$creadList :: ReadS [S3RepositoryDetails]
readsPrec :: Int -> ReadS S3RepositoryDetails
$creadsPrec :: Int -> ReadS S3RepositoryDetails
Prelude.Read, Int -> S3RepositoryDetails -> ShowS
[S3RepositoryDetails] -> ShowS
S3RepositoryDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3RepositoryDetails] -> ShowS
$cshowList :: [S3RepositoryDetails] -> ShowS
show :: S3RepositoryDetails -> String
$cshow :: S3RepositoryDetails -> String
showsPrec :: Int -> S3RepositoryDetails -> ShowS
$cshowsPrec :: Int -> S3RepositoryDetails -> ShowS
Prelude.Show, forall x. Rep S3RepositoryDetails x -> S3RepositoryDetails
forall x. S3RepositoryDetails -> Rep S3RepositoryDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3RepositoryDetails x -> S3RepositoryDetails
$cfrom :: forall x. S3RepositoryDetails -> Rep S3RepositoryDetails x
Prelude.Generic)

-- |
-- Create a value of 'S3RepositoryDetails' 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:
--
-- 'bucketName', 's3RepositoryDetails_bucketName' - The name of the S3 bucket used for associating a new S3 repository. It
-- must begin with @codeguru-reviewer-@.
--
-- 'codeArtifacts', 's3RepositoryDetails_codeArtifacts' - A @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
-- object key for a source code .zip file and for a build artifacts .zip
-- file that contains .jar or .class files.
newS3RepositoryDetails ::
  S3RepositoryDetails
newS3RepositoryDetails :: S3RepositoryDetails
newS3RepositoryDetails =
  S3RepositoryDetails'
    { $sel:bucketName:S3RepositoryDetails' :: Maybe Text
bucketName = forall a. Maybe a
Prelude.Nothing,
      $sel:codeArtifacts:S3RepositoryDetails' :: Maybe CodeArtifacts
codeArtifacts = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the S3 bucket used for associating a new S3 repository. It
-- must begin with @codeguru-reviewer-@.
s3RepositoryDetails_bucketName :: Lens.Lens' S3RepositoryDetails (Prelude.Maybe Prelude.Text)
s3RepositoryDetails_bucketName :: Lens' S3RepositoryDetails (Maybe Text)
s3RepositoryDetails_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3RepositoryDetails' {Maybe Text
bucketName :: Maybe Text
$sel:bucketName:S3RepositoryDetails' :: S3RepositoryDetails -> Maybe Text
bucketName} -> Maybe Text
bucketName) (\s :: S3RepositoryDetails
s@S3RepositoryDetails' {} Maybe Text
a -> S3RepositoryDetails
s {$sel:bucketName:S3RepositoryDetails' :: Maybe Text
bucketName = Maybe Text
a} :: S3RepositoryDetails)

-- | A @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
-- object key for a source code .zip file and for a build artifacts .zip
-- file that contains .jar or .class files.
s3RepositoryDetails_codeArtifacts :: Lens.Lens' S3RepositoryDetails (Prelude.Maybe CodeArtifacts)
s3RepositoryDetails_codeArtifacts :: Lens' S3RepositoryDetails (Maybe CodeArtifacts)
s3RepositoryDetails_codeArtifacts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3RepositoryDetails' {Maybe CodeArtifacts
codeArtifacts :: Maybe CodeArtifacts
$sel:codeArtifacts:S3RepositoryDetails' :: S3RepositoryDetails -> Maybe CodeArtifacts
codeArtifacts} -> Maybe CodeArtifacts
codeArtifacts) (\s :: S3RepositoryDetails
s@S3RepositoryDetails' {} Maybe CodeArtifacts
a -> S3RepositoryDetails
s {$sel:codeArtifacts:S3RepositoryDetails' :: Maybe CodeArtifacts
codeArtifacts = Maybe CodeArtifacts
a} :: S3RepositoryDetails)

instance Data.FromJSON S3RepositoryDetails where
  parseJSON :: Value -> Parser S3RepositoryDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3RepositoryDetails"
      ( \Object
x ->
          Maybe Text -> Maybe CodeArtifacts -> S3RepositoryDetails
S3RepositoryDetails'
            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
"BucketName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CodeArtifacts")
      )

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

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

instance Data.ToJSON S3RepositoryDetails where
  toJSON :: S3RepositoryDetails -> Value
toJSON S3RepositoryDetails' {Maybe Text
Maybe CodeArtifacts
codeArtifacts :: Maybe CodeArtifacts
bucketName :: Maybe Text
$sel:codeArtifacts:S3RepositoryDetails' :: S3RepositoryDetails -> Maybe CodeArtifacts
$sel:bucketName:S3RepositoryDetails' :: S3RepositoryDetails -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BucketName" 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
bucketName,
            (Key
"CodeArtifacts" 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 CodeArtifacts
codeArtifacts
          ]
      )