{-# 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.Lambda.Types.SnapStart
-- 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.Lambda.Types.SnapStart where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lambda.Types.SnapStartApplyOn
import qualified Amazonka.Prelude as Prelude

-- | The function\'s SnapStart setting. Set @ApplyOn@ to @PublishedVersions@
-- to create a snapshot of the initialized execution environment when you
-- publish a function version. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html Reducing startup time with Lambda SnapStart>.
--
-- /See:/ 'newSnapStart' smart constructor.
data SnapStart = SnapStart'
  { -- | Set to @PublishedVersions@ to create a snapshot of the initialized
    -- execution environment when you publish a function version.
    SnapStart -> Maybe SnapStartApplyOn
applyOn :: Prelude.Maybe SnapStartApplyOn
  }
  deriving (SnapStart -> SnapStart -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapStart -> SnapStart -> Bool
$c/= :: SnapStart -> SnapStart -> Bool
== :: SnapStart -> SnapStart -> Bool
$c== :: SnapStart -> SnapStart -> Bool
Prelude.Eq, ReadPrec [SnapStart]
ReadPrec SnapStart
Int -> ReadS SnapStart
ReadS [SnapStart]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapStart]
$creadListPrec :: ReadPrec [SnapStart]
readPrec :: ReadPrec SnapStart
$creadPrec :: ReadPrec SnapStart
readList :: ReadS [SnapStart]
$creadList :: ReadS [SnapStart]
readsPrec :: Int -> ReadS SnapStart
$creadsPrec :: Int -> ReadS SnapStart
Prelude.Read, Int -> SnapStart -> ShowS
[SnapStart] -> ShowS
SnapStart -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapStart] -> ShowS
$cshowList :: [SnapStart] -> ShowS
show :: SnapStart -> String
$cshow :: SnapStart -> String
showsPrec :: Int -> SnapStart -> ShowS
$cshowsPrec :: Int -> SnapStart -> ShowS
Prelude.Show, forall x. Rep SnapStart x -> SnapStart
forall x. SnapStart -> Rep SnapStart x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapStart x -> SnapStart
$cfrom :: forall x. SnapStart -> Rep SnapStart x
Prelude.Generic)

-- |
-- Create a value of 'SnapStart' 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:
--
-- 'applyOn', 'snapStart_applyOn' - Set to @PublishedVersions@ to create a snapshot of the initialized
-- execution environment when you publish a function version.
newSnapStart ::
  SnapStart
newSnapStart :: SnapStart
newSnapStart = SnapStart' {$sel:applyOn:SnapStart' :: Maybe SnapStartApplyOn
applyOn = forall a. Maybe a
Prelude.Nothing}

-- | Set to @PublishedVersions@ to create a snapshot of the initialized
-- execution environment when you publish a function version.
snapStart_applyOn :: Lens.Lens' SnapStart (Prelude.Maybe SnapStartApplyOn)
snapStart_applyOn :: Lens' SnapStart (Maybe SnapStartApplyOn)
snapStart_applyOn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapStart' {Maybe SnapStartApplyOn
applyOn :: Maybe SnapStartApplyOn
$sel:applyOn:SnapStart' :: SnapStart -> Maybe SnapStartApplyOn
applyOn} -> Maybe SnapStartApplyOn
applyOn) (\s :: SnapStart
s@SnapStart' {} Maybe SnapStartApplyOn
a -> SnapStart
s {$sel:applyOn:SnapStart' :: Maybe SnapStartApplyOn
applyOn = Maybe SnapStartApplyOn
a} :: SnapStart)

instance Prelude.Hashable SnapStart where
  hashWithSalt :: Int -> SnapStart -> Int
hashWithSalt Int
_salt SnapStart' {Maybe SnapStartApplyOn
applyOn :: Maybe SnapStartApplyOn
$sel:applyOn:SnapStart' :: SnapStart -> Maybe SnapStartApplyOn
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SnapStartApplyOn
applyOn

instance Prelude.NFData SnapStart where
  rnf :: SnapStart -> ()
rnf SnapStart' {Maybe SnapStartApplyOn
applyOn :: Maybe SnapStartApplyOn
$sel:applyOn:SnapStart' :: SnapStart -> Maybe SnapStartApplyOn
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapStartApplyOn
applyOn

instance Data.ToJSON SnapStart where
  toJSON :: SnapStart -> Value
toJSON SnapStart' {Maybe SnapStartApplyOn
applyOn :: Maybe SnapStartApplyOn
$sel:applyOn:SnapStart' :: SnapStart -> Maybe SnapStartApplyOn
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"ApplyOn" 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 SnapStartApplyOn
applyOn]
      )