{-# 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.CloudTrail.Types.S3ImportSource
-- 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.CloudTrail.Types.S3ImportSource 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

-- | The settings for the source S3 bucket.
--
-- /See:/ 'newS3ImportSource' smart constructor.
data S3ImportSource = S3ImportSource'
  { -- | The URI for the source S3 bucket.
    S3ImportSource -> Text
s3LocationUri :: Prelude.Text,
    -- | The region associated with the source S3 bucket.
    S3ImportSource -> Text
s3BucketRegion :: Prelude.Text,
    -- | The IAM ARN role used to access the source S3 bucket.
    S3ImportSource -> Text
s3BucketAccessRoleArn :: Prelude.Text
  }
  deriving (S3ImportSource -> S3ImportSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ImportSource -> S3ImportSource -> Bool
$c/= :: S3ImportSource -> S3ImportSource -> Bool
== :: S3ImportSource -> S3ImportSource -> Bool
$c== :: S3ImportSource -> S3ImportSource -> Bool
Prelude.Eq, ReadPrec [S3ImportSource]
ReadPrec S3ImportSource
Int -> ReadS S3ImportSource
ReadS [S3ImportSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ImportSource]
$creadListPrec :: ReadPrec [S3ImportSource]
readPrec :: ReadPrec S3ImportSource
$creadPrec :: ReadPrec S3ImportSource
readList :: ReadS [S3ImportSource]
$creadList :: ReadS [S3ImportSource]
readsPrec :: Int -> ReadS S3ImportSource
$creadsPrec :: Int -> ReadS S3ImportSource
Prelude.Read, Int -> S3ImportSource -> ShowS
[S3ImportSource] -> ShowS
S3ImportSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ImportSource] -> ShowS
$cshowList :: [S3ImportSource] -> ShowS
show :: S3ImportSource -> String
$cshow :: S3ImportSource -> String
showsPrec :: Int -> S3ImportSource -> ShowS
$cshowsPrec :: Int -> S3ImportSource -> ShowS
Prelude.Show, forall x. Rep S3ImportSource x -> S3ImportSource
forall x. S3ImportSource -> Rep S3ImportSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ImportSource x -> S3ImportSource
$cfrom :: forall x. S3ImportSource -> Rep S3ImportSource x
Prelude.Generic)

-- |
-- Create a value of 'S3ImportSource' 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:
--
-- 's3LocationUri', 's3ImportSource_s3LocationUri' - The URI for the source S3 bucket.
--
-- 's3BucketRegion', 's3ImportSource_s3BucketRegion' - The region associated with the source S3 bucket.
--
-- 's3BucketAccessRoleArn', 's3ImportSource_s3BucketAccessRoleArn' - The IAM ARN role used to access the source S3 bucket.
newS3ImportSource ::
  -- | 's3LocationUri'
  Prelude.Text ->
  -- | 's3BucketRegion'
  Prelude.Text ->
  -- | 's3BucketAccessRoleArn'
  Prelude.Text ->
  S3ImportSource
newS3ImportSource :: Text -> Text -> Text -> S3ImportSource
newS3ImportSource
  Text
pS3LocationUri_
  Text
pS3BucketRegion_
  Text
pS3BucketAccessRoleArn_ =
    S3ImportSource'
      { $sel:s3LocationUri:S3ImportSource' :: Text
s3LocationUri = Text
pS3LocationUri_,
        $sel:s3BucketRegion:S3ImportSource' :: Text
s3BucketRegion = Text
pS3BucketRegion_,
        $sel:s3BucketAccessRoleArn:S3ImportSource' :: Text
s3BucketAccessRoleArn = Text
pS3BucketAccessRoleArn_
      }

-- | The URI for the source S3 bucket.
s3ImportSource_s3LocationUri :: Lens.Lens' S3ImportSource Prelude.Text
s3ImportSource_s3LocationUri :: Lens' S3ImportSource Text
s3ImportSource_s3LocationUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ImportSource' {Text
s3LocationUri :: Text
$sel:s3LocationUri:S3ImportSource' :: S3ImportSource -> Text
s3LocationUri} -> Text
s3LocationUri) (\s :: S3ImportSource
s@S3ImportSource' {} Text
a -> S3ImportSource
s {$sel:s3LocationUri:S3ImportSource' :: Text
s3LocationUri = Text
a} :: S3ImportSource)

-- | The region associated with the source S3 bucket.
s3ImportSource_s3BucketRegion :: Lens.Lens' S3ImportSource Prelude.Text
s3ImportSource_s3BucketRegion :: Lens' S3ImportSource Text
s3ImportSource_s3BucketRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ImportSource' {Text
s3BucketRegion :: Text
$sel:s3BucketRegion:S3ImportSource' :: S3ImportSource -> Text
s3BucketRegion} -> Text
s3BucketRegion) (\s :: S3ImportSource
s@S3ImportSource' {} Text
a -> S3ImportSource
s {$sel:s3BucketRegion:S3ImportSource' :: Text
s3BucketRegion = Text
a} :: S3ImportSource)

-- | The IAM ARN role used to access the source S3 bucket.
s3ImportSource_s3BucketAccessRoleArn :: Lens.Lens' S3ImportSource Prelude.Text
s3ImportSource_s3BucketAccessRoleArn :: Lens' S3ImportSource Text
s3ImportSource_s3BucketAccessRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ImportSource' {Text
s3BucketAccessRoleArn :: Text
$sel:s3BucketAccessRoleArn:S3ImportSource' :: S3ImportSource -> Text
s3BucketAccessRoleArn} -> Text
s3BucketAccessRoleArn) (\s :: S3ImportSource
s@S3ImportSource' {} Text
a -> S3ImportSource
s {$sel:s3BucketAccessRoleArn:S3ImportSource' :: Text
s3BucketAccessRoleArn = Text
a} :: S3ImportSource)

instance Data.FromJSON S3ImportSource where
  parseJSON :: Value -> Parser S3ImportSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3ImportSource"
      ( \Object
x ->
          Text -> Text -> Text -> S3ImportSource
S3ImportSource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"S3LocationUri")
            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
"S3BucketRegion")
            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
"S3BucketAccessRoleArn")
      )

instance Prelude.Hashable S3ImportSource where
  hashWithSalt :: Int -> S3ImportSource -> Int
hashWithSalt Int
_salt S3ImportSource' {Text
s3BucketAccessRoleArn :: Text
s3BucketRegion :: Text
s3LocationUri :: Text
$sel:s3BucketAccessRoleArn:S3ImportSource' :: S3ImportSource -> Text
$sel:s3BucketRegion:S3ImportSource' :: S3ImportSource -> Text
$sel:s3LocationUri:S3ImportSource' :: S3ImportSource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3LocationUri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3BucketRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3BucketAccessRoleArn

instance Prelude.NFData S3ImportSource where
  rnf :: S3ImportSource -> ()
rnf S3ImportSource' {Text
s3BucketAccessRoleArn :: Text
s3BucketRegion :: Text
s3LocationUri :: Text
$sel:s3BucketAccessRoleArn:S3ImportSource' :: S3ImportSource -> Text
$sel:s3BucketRegion:S3ImportSource' :: S3ImportSource -> Text
$sel:s3LocationUri:S3ImportSource' :: S3ImportSource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
s3LocationUri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3BucketRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3BucketAccessRoleArn

instance Data.ToJSON S3ImportSource where
  toJSON :: S3ImportSource -> Value
toJSON S3ImportSource' {Text
s3BucketAccessRoleArn :: Text
s3BucketRegion :: Text
s3LocationUri :: Text
$sel:s3BucketAccessRoleArn:S3ImportSource' :: S3ImportSource -> Text
$sel:s3BucketRegion:S3ImportSource' :: S3ImportSource -> Text
$sel:s3LocationUri:S3ImportSource' :: S3ImportSource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"S3LocationUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3LocationUri),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"S3BucketRegion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3BucketRegion),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"S3BucketAccessRoleArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3BucketAccessRoleArn
              )
          ]
      )