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

import Amazonka.CodeGuruReviewer.Types.CodeArtifacts
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | 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
  }
  deriving (S3RepositoryDetails -> S3RepositoryDetails -> Bool
(S3RepositoryDetails -> S3RepositoryDetails -> Bool)
-> (S3RepositoryDetails -> S3RepositoryDetails -> Bool)
-> Eq S3RepositoryDetails
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]
(Int -> ReadS S3RepositoryDetails)
-> ReadS [S3RepositoryDetails]
-> ReadPrec S3RepositoryDetails
-> ReadPrec [S3RepositoryDetails]
-> Read 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
(Int -> S3RepositoryDetails -> ShowS)
-> (S3RepositoryDetails -> String)
-> ([S3RepositoryDetails] -> ShowS)
-> Show S3RepositoryDetails
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. S3RepositoryDetails -> Rep S3RepositoryDetails x)
-> (forall x. Rep S3RepositoryDetails x -> S3RepositoryDetails)
-> Generic S3RepositoryDetails
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:
--
-- '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.
--
-- 'bucketName', 's3RepositoryDetails_bucketName' - The name of the S3 bucket used for associating a new S3 repository. It
-- must begin with @codeguru-reviewer-@.
newS3RepositoryDetails ::
  S3RepositoryDetails
newS3RepositoryDetails :: S3RepositoryDetails
newS3RepositoryDetails =
  S3RepositoryDetails' :: Maybe CodeArtifacts -> Maybe Text -> S3RepositoryDetails
S3RepositoryDetails'
    { $sel:codeArtifacts:S3RepositoryDetails' :: Maybe CodeArtifacts
codeArtifacts =
        Maybe CodeArtifacts
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3RepositoryDetails' :: Maybe Text
bucketName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe CodeArtifacts -> f (Maybe CodeArtifacts))
-> S3RepositoryDetails -> f S3RepositoryDetails
s3RepositoryDetails_codeArtifacts = (S3RepositoryDetails -> Maybe CodeArtifacts)
-> (S3RepositoryDetails
    -> Maybe CodeArtifacts -> S3RepositoryDetails)
-> Lens
     S3RepositoryDetails
     S3RepositoryDetails
     (Maybe CodeArtifacts)
     (Maybe 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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> S3RepositoryDetails -> f S3RepositoryDetails
s3RepositoryDetails_bucketName = (S3RepositoryDetails -> Maybe Text)
-> (S3RepositoryDetails -> Maybe Text -> S3RepositoryDetails)
-> Lens
     S3RepositoryDetails S3RepositoryDetails (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable S3RepositoryDetails

instance Prelude.NFData S3RepositoryDetails

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