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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a repository in an S3 bucket.
--
-- /See:/ 'newS3Repository' smart constructor.
data S3Repository = S3Repository'
  { -- | The name of the repository in the S3 bucket.
    S3Repository -> Text
name :: Prelude.Text,
    -- | The name of the S3 bucket used for associating a new S3 repository. It
    -- must begin with @codeguru-reviewer-@.
    S3Repository -> Text
bucketName :: Prelude.Text
  }
  deriving (S3Repository -> S3Repository -> Bool
(S3Repository -> S3Repository -> Bool)
-> (S3Repository -> S3Repository -> Bool) -> Eq S3Repository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Repository -> S3Repository -> Bool
$c/= :: S3Repository -> S3Repository -> Bool
== :: S3Repository -> S3Repository -> Bool
$c== :: S3Repository -> S3Repository -> Bool
Prelude.Eq, ReadPrec [S3Repository]
ReadPrec S3Repository
Int -> ReadS S3Repository
ReadS [S3Repository]
(Int -> ReadS S3Repository)
-> ReadS [S3Repository]
-> ReadPrec S3Repository
-> ReadPrec [S3Repository]
-> Read S3Repository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Repository]
$creadListPrec :: ReadPrec [S3Repository]
readPrec :: ReadPrec S3Repository
$creadPrec :: ReadPrec S3Repository
readList :: ReadS [S3Repository]
$creadList :: ReadS [S3Repository]
readsPrec :: Int -> ReadS S3Repository
$creadsPrec :: Int -> ReadS S3Repository
Prelude.Read, Int -> S3Repository -> ShowS
[S3Repository] -> ShowS
S3Repository -> String
(Int -> S3Repository -> ShowS)
-> (S3Repository -> String)
-> ([S3Repository] -> ShowS)
-> Show S3Repository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Repository] -> ShowS
$cshowList :: [S3Repository] -> ShowS
show :: S3Repository -> String
$cshow :: S3Repository -> String
showsPrec :: Int -> S3Repository -> ShowS
$cshowsPrec :: Int -> S3Repository -> ShowS
Prelude.Show, (forall x. S3Repository -> Rep S3Repository x)
-> (forall x. Rep S3Repository x -> S3Repository)
-> Generic S3Repository
forall x. Rep S3Repository x -> S3Repository
forall x. S3Repository -> Rep S3Repository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Repository x -> S3Repository
$cfrom :: forall x. S3Repository -> Rep S3Repository x
Prelude.Generic)

-- |
-- Create a value of 'S3Repository' 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:
--
-- 'name', 's3Repository_name' - The name of the repository in the S3 bucket.
--
-- 'bucketName', 's3Repository_bucketName' - The name of the S3 bucket used for associating a new S3 repository. It
-- must begin with @codeguru-reviewer-@.
newS3Repository ::
  -- | 'name'
  Prelude.Text ->
  -- | 'bucketName'
  Prelude.Text ->
  S3Repository
newS3Repository :: Text -> Text -> S3Repository
newS3Repository Text
pName_ Text
pBucketName_ =
  S3Repository' :: Text -> Text -> S3Repository
S3Repository'
    { $sel:name:S3Repository' :: Text
name = Text
pName_,
      $sel:bucketName:S3Repository' :: Text
bucketName = Text
pBucketName_
    }

-- | The name of the repository in the S3 bucket.
s3Repository_name :: Lens.Lens' S3Repository Prelude.Text
s3Repository_name :: (Text -> f Text) -> S3Repository -> f S3Repository
s3Repository_name = (S3Repository -> Text)
-> (S3Repository -> Text -> S3Repository)
-> Lens S3Repository S3Repository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Repository' {Text
name :: Text
$sel:name:S3Repository' :: S3Repository -> Text
name} -> Text
name) (\s :: S3Repository
s@S3Repository' {} Text
a -> S3Repository
s {$sel:name:S3Repository' :: Text
name = Text
a} :: S3Repository)

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

instance Prelude.Hashable S3Repository

instance Prelude.NFData S3Repository

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