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

import Amazonka.CloudTrail.Types.S3ImportSource
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 import source.
--
-- /See:/ 'newImportSource' smart constructor.
data ImportSource = ImportSource'
  { -- | The source S3 bucket.
    ImportSource -> S3ImportSource
s3 :: S3ImportSource
  }
  deriving (ImportSource -> ImportSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportSource -> ImportSource -> Bool
$c/= :: ImportSource -> ImportSource -> Bool
== :: ImportSource -> ImportSource -> Bool
$c== :: ImportSource -> ImportSource -> Bool
Prelude.Eq, ReadPrec [ImportSource]
ReadPrec ImportSource
Int -> ReadS ImportSource
ReadS [ImportSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportSource]
$creadListPrec :: ReadPrec [ImportSource]
readPrec :: ReadPrec ImportSource
$creadPrec :: ReadPrec ImportSource
readList :: ReadS [ImportSource]
$creadList :: ReadS [ImportSource]
readsPrec :: Int -> ReadS ImportSource
$creadsPrec :: Int -> ReadS ImportSource
Prelude.Read, Int -> ImportSource -> ShowS
[ImportSource] -> ShowS
ImportSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportSource] -> ShowS
$cshowList :: [ImportSource] -> ShowS
show :: ImportSource -> String
$cshow :: ImportSource -> String
showsPrec :: Int -> ImportSource -> ShowS
$cshowsPrec :: Int -> ImportSource -> ShowS
Prelude.Show, forall x. Rep ImportSource x -> ImportSource
forall x. ImportSource -> Rep ImportSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportSource x -> ImportSource
$cfrom :: forall x. ImportSource -> Rep ImportSource x
Prelude.Generic)

-- |
-- Create a value of 'ImportSource' 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:
--
-- 's3', 'importSource_s3' - The source S3 bucket.
newImportSource ::
  -- | 's3'
  S3ImportSource ->
  ImportSource
newImportSource :: S3ImportSource -> ImportSource
newImportSource S3ImportSource
pS3_ = ImportSource' {$sel:s3:ImportSource' :: S3ImportSource
s3 = S3ImportSource
pS3_}

-- | The source S3 bucket.
importSource_s3 :: Lens.Lens' ImportSource S3ImportSource
importSource_s3 :: Lens' ImportSource S3ImportSource
importSource_s3 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportSource' {S3ImportSource
s3 :: S3ImportSource
$sel:s3:ImportSource' :: ImportSource -> S3ImportSource
s3} -> S3ImportSource
s3) (\s :: ImportSource
s@ImportSource' {} S3ImportSource
a -> ImportSource
s {$sel:s3:ImportSource' :: S3ImportSource
s3 = S3ImportSource
a} :: ImportSource)

instance Data.FromJSON ImportSource where
  parseJSON :: Value -> Parser ImportSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImportSource"
      (\Object
x -> S3ImportSource -> ImportSource
ImportSource' 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
"S3"))

instance Prelude.Hashable ImportSource where
  hashWithSalt :: Int -> ImportSource -> Int
hashWithSalt Int
_salt ImportSource' {S3ImportSource
s3 :: S3ImportSource
$sel:s3:ImportSource' :: ImportSource -> S3ImportSource
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` S3ImportSource
s3

instance Prelude.NFData ImportSource where
  rnf :: ImportSource -> ()
rnf ImportSource' {S3ImportSource
s3 :: S3ImportSource
$sel:s3:ImportSource' :: ImportSource -> S3ImportSource
..} = forall a. NFData a => a -> ()
Prelude.rnf S3ImportSource
s3

instance Data.ToJSON ImportSource where
  toJSON :: ImportSource -> Value
toJSON ImportSource' {S3ImportSource
s3 :: S3ImportSource
$sel:s3:ImportSource' :: ImportSource -> S3ImportSource
..} =
    [Pair] -> Value
Data.object
      (forall a. [Maybe a] -> [a]
Prelude.catMaybes [forall a. a -> Maybe a
Prelude.Just (Key
"S3" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= S3ImportSource
s3)])