{-# 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.MacieV2.Types.S3BucketDefinitionForJob
-- 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.MacieV2.Types.S3BucketDefinitionForJob where

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

-- | Specifies an Amazon Web Services account that owns S3 buckets for a
-- classification job to analyze, and one or more specific buckets to
-- analyze for that account.
--
-- /See:/ 'newS3BucketDefinitionForJob' smart constructor.
data S3BucketDefinitionForJob = S3BucketDefinitionForJob'
  { -- | The unique identifier for the Amazon Web Services account that owns the
    -- buckets.
    S3BucketDefinitionForJob -> Text
accountId :: Prelude.Text,
    -- | An array that lists the names of the buckets.
    S3BucketDefinitionForJob -> [Text]
buckets :: [Prelude.Text]
  }
  deriving (S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool
(S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool)
-> (S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool)
-> Eq S3BucketDefinitionForJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool
$c/= :: S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool
== :: S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool
$c== :: S3BucketDefinitionForJob -> S3BucketDefinitionForJob -> Bool
Prelude.Eq, ReadPrec [S3BucketDefinitionForJob]
ReadPrec S3BucketDefinitionForJob
Int -> ReadS S3BucketDefinitionForJob
ReadS [S3BucketDefinitionForJob]
(Int -> ReadS S3BucketDefinitionForJob)
-> ReadS [S3BucketDefinitionForJob]
-> ReadPrec S3BucketDefinitionForJob
-> ReadPrec [S3BucketDefinitionForJob]
-> Read S3BucketDefinitionForJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3BucketDefinitionForJob]
$creadListPrec :: ReadPrec [S3BucketDefinitionForJob]
readPrec :: ReadPrec S3BucketDefinitionForJob
$creadPrec :: ReadPrec S3BucketDefinitionForJob
readList :: ReadS [S3BucketDefinitionForJob]
$creadList :: ReadS [S3BucketDefinitionForJob]
readsPrec :: Int -> ReadS S3BucketDefinitionForJob
$creadsPrec :: Int -> ReadS S3BucketDefinitionForJob
Prelude.Read, Int -> S3BucketDefinitionForJob -> ShowS
[S3BucketDefinitionForJob] -> ShowS
S3BucketDefinitionForJob -> String
(Int -> S3BucketDefinitionForJob -> ShowS)
-> (S3BucketDefinitionForJob -> String)
-> ([S3BucketDefinitionForJob] -> ShowS)
-> Show S3BucketDefinitionForJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3BucketDefinitionForJob] -> ShowS
$cshowList :: [S3BucketDefinitionForJob] -> ShowS
show :: S3BucketDefinitionForJob -> String
$cshow :: S3BucketDefinitionForJob -> String
showsPrec :: Int -> S3BucketDefinitionForJob -> ShowS
$cshowsPrec :: Int -> S3BucketDefinitionForJob -> ShowS
Prelude.Show, (forall x.
 S3BucketDefinitionForJob -> Rep S3BucketDefinitionForJob x)
-> (forall x.
    Rep S3BucketDefinitionForJob x -> S3BucketDefinitionForJob)
-> Generic S3BucketDefinitionForJob
forall x.
Rep S3BucketDefinitionForJob x -> S3BucketDefinitionForJob
forall x.
S3BucketDefinitionForJob -> Rep S3BucketDefinitionForJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep S3BucketDefinitionForJob x -> S3BucketDefinitionForJob
$cfrom :: forall x.
S3BucketDefinitionForJob -> Rep S3BucketDefinitionForJob x
Prelude.Generic)

-- |
-- Create a value of 'S3BucketDefinitionForJob' 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:
--
-- 'accountId', 's3BucketDefinitionForJob_accountId' - The unique identifier for the Amazon Web Services account that owns the
-- buckets.
--
-- 'buckets', 's3BucketDefinitionForJob_buckets' - An array that lists the names of the buckets.
newS3BucketDefinitionForJob ::
  -- | 'accountId'
  Prelude.Text ->
  S3BucketDefinitionForJob
newS3BucketDefinitionForJob :: Text -> S3BucketDefinitionForJob
newS3BucketDefinitionForJob Text
pAccountId_ =
  S3BucketDefinitionForJob' :: Text -> [Text] -> S3BucketDefinitionForJob
S3BucketDefinitionForJob'
    { $sel:accountId:S3BucketDefinitionForJob' :: Text
accountId = Text
pAccountId_,
      $sel:buckets:S3BucketDefinitionForJob' :: [Text]
buckets = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The unique identifier for the Amazon Web Services account that owns the
-- buckets.
s3BucketDefinitionForJob_accountId :: Lens.Lens' S3BucketDefinitionForJob Prelude.Text
s3BucketDefinitionForJob_accountId :: (Text -> f Text)
-> S3BucketDefinitionForJob -> f S3BucketDefinitionForJob
s3BucketDefinitionForJob_accountId = (S3BucketDefinitionForJob -> Text)
-> (S3BucketDefinitionForJob -> Text -> S3BucketDefinitionForJob)
-> Lens S3BucketDefinitionForJob S3BucketDefinitionForJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketDefinitionForJob' {Text
accountId :: Text
$sel:accountId:S3BucketDefinitionForJob' :: S3BucketDefinitionForJob -> Text
accountId} -> Text
accountId) (\s :: S3BucketDefinitionForJob
s@S3BucketDefinitionForJob' {} Text
a -> S3BucketDefinitionForJob
s {$sel:accountId:S3BucketDefinitionForJob' :: Text
accountId = Text
a} :: S3BucketDefinitionForJob)

-- | An array that lists the names of the buckets.
s3BucketDefinitionForJob_buckets :: Lens.Lens' S3BucketDefinitionForJob [Prelude.Text]
s3BucketDefinitionForJob_buckets :: ([Text] -> f [Text])
-> S3BucketDefinitionForJob -> f S3BucketDefinitionForJob
s3BucketDefinitionForJob_buckets = (S3BucketDefinitionForJob -> [Text])
-> (S3BucketDefinitionForJob -> [Text] -> S3BucketDefinitionForJob)
-> Lens
     S3BucketDefinitionForJob S3BucketDefinitionForJob [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3BucketDefinitionForJob' {[Text]
buckets :: [Text]
$sel:buckets:S3BucketDefinitionForJob' :: S3BucketDefinitionForJob -> [Text]
buckets} -> [Text]
buckets) (\s :: S3BucketDefinitionForJob
s@S3BucketDefinitionForJob' {} [Text]
a -> S3BucketDefinitionForJob
s {$sel:buckets:S3BucketDefinitionForJob' :: [Text]
buckets = [Text]
a} :: S3BucketDefinitionForJob) (([Text] -> f [Text])
 -> S3BucketDefinitionForJob -> f S3BucketDefinitionForJob)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> S3BucketDefinitionForJob
-> f S3BucketDefinitionForJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON S3BucketDefinitionForJob where
  parseJSON :: Value -> Parser S3BucketDefinitionForJob
parseJSON =
    String
-> (Object -> Parser S3BucketDefinitionForJob)
-> Value
-> Parser S3BucketDefinitionForJob
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3BucketDefinitionForJob"
      ( \Object
x ->
          Text -> [Text] -> S3BucketDefinitionForJob
S3BucketDefinitionForJob'
            (Text -> [Text] -> S3BucketDefinitionForJob)
-> Parser Text -> Parser ([Text] -> S3BucketDefinitionForJob)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"accountId")
            Parser ([Text] -> S3BucketDefinitionForJob)
-> Parser [Text] -> Parser S3BucketDefinitionForJob
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
"buckets" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable S3BucketDefinitionForJob

instance Prelude.NFData S3BucketDefinitionForJob

instance Core.ToJSON S3BucketDefinitionForJob where
  toJSON :: S3BucketDefinitionForJob -> Value
toJSON S3BucketDefinitionForJob' {[Text]
Text
buckets :: [Text]
accountId :: Text
$sel:buckets:S3BucketDefinitionForJob' :: S3BucketDefinitionForJob -> [Text]
$sel:accountId:S3BucketDefinitionForJob' :: S3BucketDefinitionForJob -> 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
"accountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
accountId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"buckets" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
buckets)
          ]
      )