{-# 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.SecurityLake.Types.SourceType
-- 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.SecurityLake.Types.SourceType 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
import Amazonka.SecurityLake.Types.AwsLogSourceType

-- | The supported source types from which logs and events are collected in
-- Amazon Security Lake. For the list of supported Amazon Web Services, see
-- the
-- <https://docs.aws.amazon.com/security-lake/latest/userguide/internal-sources.html Amazon Security Lake User Guide>.
--
-- /See:/ 'newSourceType' smart constructor.
data SourceType = SourceType'
  { -- | Amazon Security Lake supports log and event collection for natively
    -- supported Amazon Web Services.
    SourceType -> Maybe AwsLogSourceType
awsSourceType :: Prelude.Maybe AwsLogSourceType,
    -- | Amazon Security Lake supports custom source types. For a detailed list,
    -- see the Amazon Security Lake User Guide.
    SourceType -> Maybe Text
customSourceType :: Prelude.Maybe Prelude.Text
  }
  deriving (SourceType -> SourceType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceType -> SourceType -> Bool
$c/= :: SourceType -> SourceType -> Bool
== :: SourceType -> SourceType -> Bool
$c== :: SourceType -> SourceType -> Bool
Prelude.Eq, ReadPrec [SourceType]
ReadPrec SourceType
Int -> ReadS SourceType
ReadS [SourceType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceType]
$creadListPrec :: ReadPrec [SourceType]
readPrec :: ReadPrec SourceType
$creadPrec :: ReadPrec SourceType
readList :: ReadS [SourceType]
$creadList :: ReadS [SourceType]
readsPrec :: Int -> ReadS SourceType
$creadsPrec :: Int -> ReadS SourceType
Prelude.Read, Int -> SourceType -> ShowS
[SourceType] -> ShowS
SourceType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceType] -> ShowS
$cshowList :: [SourceType] -> ShowS
show :: SourceType -> String
$cshow :: SourceType -> String
showsPrec :: Int -> SourceType -> ShowS
$cshowsPrec :: Int -> SourceType -> ShowS
Prelude.Show, forall x. Rep SourceType x -> SourceType
forall x. SourceType -> Rep SourceType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceType x -> SourceType
$cfrom :: forall x. SourceType -> Rep SourceType x
Prelude.Generic)

-- |
-- Create a value of 'SourceType' 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:
--
-- 'awsSourceType', 'sourceType_awsSourceType' - Amazon Security Lake supports log and event collection for natively
-- supported Amazon Web Services.
--
-- 'customSourceType', 'sourceType_customSourceType' - Amazon Security Lake supports custom source types. For a detailed list,
-- see the Amazon Security Lake User Guide.
newSourceType ::
  SourceType
newSourceType :: SourceType
newSourceType =
  SourceType'
    { $sel:awsSourceType:SourceType' :: Maybe AwsLogSourceType
awsSourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:customSourceType:SourceType' :: Maybe Text
customSourceType = forall a. Maybe a
Prelude.Nothing
    }

-- | Amazon Security Lake supports log and event collection for natively
-- supported Amazon Web Services.
sourceType_awsSourceType :: Lens.Lens' SourceType (Prelude.Maybe AwsLogSourceType)
sourceType_awsSourceType :: Lens' SourceType (Maybe AwsLogSourceType)
sourceType_awsSourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceType' {Maybe AwsLogSourceType
awsSourceType :: Maybe AwsLogSourceType
$sel:awsSourceType:SourceType' :: SourceType -> Maybe AwsLogSourceType
awsSourceType} -> Maybe AwsLogSourceType
awsSourceType) (\s :: SourceType
s@SourceType' {} Maybe AwsLogSourceType
a -> SourceType
s {$sel:awsSourceType:SourceType' :: Maybe AwsLogSourceType
awsSourceType = Maybe AwsLogSourceType
a} :: SourceType)

-- | Amazon Security Lake supports custom source types. For a detailed list,
-- see the Amazon Security Lake User Guide.
sourceType_customSourceType :: Lens.Lens' SourceType (Prelude.Maybe Prelude.Text)
sourceType_customSourceType :: Lens' SourceType (Maybe Text)
sourceType_customSourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceType' {Maybe Text
customSourceType :: Maybe Text
$sel:customSourceType:SourceType' :: SourceType -> Maybe Text
customSourceType} -> Maybe Text
customSourceType) (\s :: SourceType
s@SourceType' {} Maybe Text
a -> SourceType
s {$sel:customSourceType:SourceType' :: Maybe Text
customSourceType = Maybe Text
a} :: SourceType)

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

instance Prelude.Hashable SourceType where
  hashWithSalt :: Int -> SourceType -> Int
hashWithSalt Int
_salt SourceType' {Maybe Text
Maybe AwsLogSourceType
customSourceType :: Maybe Text
awsSourceType :: Maybe AwsLogSourceType
$sel:customSourceType:SourceType' :: SourceType -> Maybe Text
$sel:awsSourceType:SourceType' :: SourceType -> Maybe AwsLogSourceType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AwsLogSourceType
awsSourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customSourceType

instance Prelude.NFData SourceType where
  rnf :: SourceType -> ()
rnf SourceType' {Maybe Text
Maybe AwsLogSourceType
customSourceType :: Maybe Text
awsSourceType :: Maybe AwsLogSourceType
$sel:customSourceType:SourceType' :: SourceType -> Maybe Text
$sel:awsSourceType:SourceType' :: SourceType -> Maybe AwsLogSourceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AwsLogSourceType
awsSourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customSourceType

instance Data.ToJSON SourceType where
  toJSON :: SourceType -> Value
toJSON SourceType' {Maybe Text
Maybe AwsLogSourceType
customSourceType :: Maybe Text
awsSourceType :: Maybe AwsLogSourceType
$sel:customSourceType:SourceType' :: SourceType -> Maybe Text
$sel:awsSourceType:SourceType' :: SourceType -> Maybe AwsLogSourceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"awsSourceType" 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 AwsLogSourceType
awsSourceType,
            (Key
"customSourceType" 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
customSourceType
          ]
      )