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

import Amazonka.CodeGuruReviewer.Types.S3RepositoryDetails
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an associated repository in an S3 bucket. The
-- associated repository contains a source code .zip file and a build
-- artifacts .zip file that contains .jar or .class files.
--
-- /See:/ 'newS3BucketRepository' smart constructor.
data S3BucketRepository = S3BucketRepository'
  { -- | An @S3RepositoryDetails@ object that specifies the name of an S3 bucket
    -- and a @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
    -- object keys for a source code .zip file and for a build artifacts .zip
    -- file.
    S3BucketRepository -> Maybe S3RepositoryDetails
details :: Prelude.Maybe S3RepositoryDetails,
    -- | The name of the repository when the @ProviderType@ is @S3Bucket@.
    S3BucketRepository -> Text
name :: Prelude.Text
  }
  deriving (S3BucketRepository -> S3BucketRepository -> Bool
(S3BucketRepository -> S3BucketRepository -> Bool)
-> (S3BucketRepository -> S3BucketRepository -> Bool)
-> Eq S3BucketRepository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3BucketRepository -> S3BucketRepository -> Bool
$c/= :: S3BucketRepository -> S3BucketRepository -> Bool
== :: S3BucketRepository -> S3BucketRepository -> Bool
$c== :: S3BucketRepository -> S3BucketRepository -> Bool
Prelude.Eq, ReadPrec [S3BucketRepository]
ReadPrec S3BucketRepository
Int -> ReadS S3BucketRepository
ReadS [S3BucketRepository]
(Int -> ReadS S3BucketRepository)
-> ReadS [S3BucketRepository]
-> ReadPrec S3BucketRepository
-> ReadPrec [S3BucketRepository]
-> Read S3BucketRepository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3BucketRepository]
$creadListPrec :: ReadPrec [S3BucketRepository]
readPrec :: ReadPrec S3BucketRepository
$creadPrec :: ReadPrec S3BucketRepository
readList :: ReadS [S3BucketRepository]
$creadList :: ReadS [S3BucketRepository]
readsPrec :: Int -> ReadS S3BucketRepository
$creadsPrec :: Int -> ReadS S3BucketRepository
Prelude.Read, Int -> S3BucketRepository -> ShowS
[S3BucketRepository] -> ShowS
S3BucketRepository -> String
(Int -> S3BucketRepository -> ShowS)
-> (S3BucketRepository -> String)
-> ([S3BucketRepository] -> ShowS)
-> Show S3BucketRepository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3BucketRepository] -> ShowS
$cshowList :: [S3BucketRepository] -> ShowS
show :: S3BucketRepository -> String
$cshow :: S3BucketRepository -> String
showsPrec :: Int -> S3BucketRepository -> ShowS
$cshowsPrec :: Int -> S3BucketRepository -> ShowS
Prelude.Show, (forall x. S3BucketRepository -> Rep S3BucketRepository x)
-> (forall x. Rep S3BucketRepository x -> S3BucketRepository)
-> Generic S3BucketRepository
forall x. Rep S3BucketRepository x -> S3BucketRepository
forall x. S3BucketRepository -> Rep S3BucketRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3BucketRepository x -> S3BucketRepository
$cfrom :: forall x. S3BucketRepository -> Rep S3BucketRepository x
Prelude.Generic)

-- |
-- Create a value of 'S3BucketRepository' 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:
--
-- 'details', 's3BucketRepository_details' - An @S3RepositoryDetails@ object that specifies the name of an S3 bucket
-- and a @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
-- object keys for a source code .zip file and for a build artifacts .zip
-- file.
--
-- 'name', 's3BucketRepository_name' - The name of the repository when the @ProviderType@ is @S3Bucket@.
newS3BucketRepository ::
  -- | 'name'
  Prelude.Text ->
  S3BucketRepository
newS3BucketRepository :: Text -> S3BucketRepository
newS3BucketRepository Text
pName_ =
  S3BucketRepository' :: Maybe S3RepositoryDetails -> Text -> S3BucketRepository
S3BucketRepository'
    { $sel:details:S3BucketRepository' :: Maybe S3RepositoryDetails
details = Maybe S3RepositoryDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:name:S3BucketRepository' :: Text
name = Text
pName_
    }

-- | An @S3RepositoryDetails@ object that specifies the name of an S3 bucket
-- and a @CodeArtifacts@ object. The @CodeArtifacts@ object includes the S3
-- object keys for a source code .zip file and for a build artifacts .zip
-- file.
s3BucketRepository_details :: Lens.Lens' S3BucketRepository (Prelude.Maybe S3RepositoryDetails)
s3BucketRepository_details :: (Maybe S3RepositoryDetails -> f (Maybe S3RepositoryDetails))
-> S3BucketRepository -> f S3BucketRepository
s3BucketRepository_details = (S3BucketRepository -> Maybe S3RepositoryDetails)
-> (S3BucketRepository
    -> Maybe S3RepositoryDetails -> S3BucketRepository)
-> Lens
     S3BucketRepository
     S3BucketRepository
     (Maybe S3RepositoryDetails)
     (Maybe S3RepositoryDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketRepository' {Maybe S3RepositoryDetails
details :: Maybe S3RepositoryDetails
$sel:details:S3BucketRepository' :: S3BucketRepository -> Maybe S3RepositoryDetails
details} -> Maybe S3RepositoryDetails
details) (\s :: S3BucketRepository
s@S3BucketRepository' {} Maybe S3RepositoryDetails
a -> S3BucketRepository
s {$sel:details:S3BucketRepository' :: Maybe S3RepositoryDetails
details = Maybe S3RepositoryDetails
a} :: S3BucketRepository)

-- | The name of the repository when the @ProviderType@ is @S3Bucket@.
s3BucketRepository_name :: Lens.Lens' S3BucketRepository Prelude.Text
s3BucketRepository_name :: (Text -> f Text) -> S3BucketRepository -> f S3BucketRepository
s3BucketRepository_name = (S3BucketRepository -> Text)
-> (S3BucketRepository -> Text -> S3BucketRepository)
-> Lens S3BucketRepository S3BucketRepository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketRepository' {Text
name :: Text
$sel:name:S3BucketRepository' :: S3BucketRepository -> Text
name} -> Text
name) (\s :: S3BucketRepository
s@S3BucketRepository' {} Text
a -> S3BucketRepository
s {$sel:name:S3BucketRepository' :: Text
name = Text
a} :: S3BucketRepository)

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

instance Prelude.Hashable S3BucketRepository

instance Prelude.NFData S3BucketRepository

instance Core.ToJSON S3BucketRepository where
  toJSON :: S3BucketRepository -> Value
toJSON S3BucketRepository' {Maybe S3RepositoryDetails
Text
name :: Text
details :: Maybe S3RepositoryDetails
$sel:name:S3BucketRepository' :: S3BucketRepository -> Text
$sel:details:S3BucketRepository' :: S3BucketRepository -> Maybe S3RepositoryDetails
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Details" Text -> S3RepositoryDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3RepositoryDetails -> Pair)
-> Maybe S3RepositoryDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3RepositoryDetails
details,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )