{-# 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.Macie.Types.S3Resource
-- 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.Macie.Types.S3Resource where

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

-- | (Discontinued) Contains information about the S3 resource. This data
-- type is used as a request parameter in the @DisassociateS3Resources@
-- action and can be used as a response parameter in the
-- @AssociateS3Resources@ and @UpdateS3Resources@ actions.
--
-- /See:/ 'newS3Resource' smart constructor.
data S3Resource = S3Resource'
  { -- | (Discontinued) The prefix of the S3 bucket.
    S3Resource -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | (Discontinued) The name of the S3 bucket.
    S3Resource -> Text
bucketName :: Prelude.Text
  }
  deriving (S3Resource -> S3Resource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Resource -> S3Resource -> Bool
$c/= :: S3Resource -> S3Resource -> Bool
== :: S3Resource -> S3Resource -> Bool
$c== :: S3Resource -> S3Resource -> Bool
Prelude.Eq, ReadPrec [S3Resource]
ReadPrec S3Resource
Int -> ReadS S3Resource
ReadS [S3Resource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Resource]
$creadListPrec :: ReadPrec [S3Resource]
readPrec :: ReadPrec S3Resource
$creadPrec :: ReadPrec S3Resource
readList :: ReadS [S3Resource]
$creadList :: ReadS [S3Resource]
readsPrec :: Int -> ReadS S3Resource
$creadsPrec :: Int -> ReadS S3Resource
Prelude.Read, Int -> S3Resource -> ShowS
[S3Resource] -> ShowS
S3Resource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Resource] -> ShowS
$cshowList :: [S3Resource] -> ShowS
show :: S3Resource -> String
$cshow :: S3Resource -> String
showsPrec :: Int -> S3Resource -> ShowS
$cshowsPrec :: Int -> S3Resource -> ShowS
Prelude.Show, forall x. Rep S3Resource x -> S3Resource
forall x. S3Resource -> Rep S3Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Resource x -> S3Resource
$cfrom :: forall x. S3Resource -> Rep S3Resource x
Prelude.Generic)

-- |
-- Create a value of 'S3Resource' 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:
--
-- 'prefix', 's3Resource_prefix' - (Discontinued) The prefix of the S3 bucket.
--
-- 'bucketName', 's3Resource_bucketName' - (Discontinued) The name of the S3 bucket.
newS3Resource ::
  -- | 'bucketName'
  Prelude.Text ->
  S3Resource
newS3Resource :: Text -> S3Resource
newS3Resource Text
pBucketName_ =
  S3Resource'
    { $sel:prefix:S3Resource' :: Maybe Text
prefix = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3Resource' :: Text
bucketName = Text
pBucketName_
    }

-- | (Discontinued) The prefix of the S3 bucket.
s3Resource_prefix :: Lens.Lens' S3Resource (Prelude.Maybe Prelude.Text)
s3Resource_prefix :: Lens' S3Resource (Maybe Text)
s3Resource_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Resource' {Maybe Text
prefix :: Maybe Text
$sel:prefix:S3Resource' :: S3Resource -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: S3Resource
s@S3Resource' {} Maybe Text
a -> S3Resource
s {$sel:prefix:S3Resource' :: Maybe Text
prefix = Maybe Text
a} :: S3Resource)

-- | (Discontinued) The name of the S3 bucket.
s3Resource_bucketName :: Lens.Lens' S3Resource Prelude.Text
s3Resource_bucketName :: Lens' S3Resource Text
s3Resource_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Resource' {Text
bucketName :: Text
$sel:bucketName:S3Resource' :: S3Resource -> Text
bucketName} -> Text
bucketName) (\s :: S3Resource
s@S3Resource' {} Text
a -> S3Resource
s {$sel:bucketName:S3Resource' :: Text
bucketName = Text
a} :: S3Resource)

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

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

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

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