{-# 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.SnapStartResponse
-- 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.SnapStartResponse 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 Amazonka.Lambda.Types.SnapStartOptimizationStatus
import qualified Amazonka.Prelude as Prelude

-- | The function\'s
-- <https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html SnapStart>
-- setting.
--
-- /See:/ 'newSnapStartResponse' smart constructor.
data SnapStartResponse = SnapStartResponse'
  { -- | When set to @PublishedVersions@, Lambda creates a snapshot of the
    -- execution environment when you publish a function version.
    SnapStartResponse -> Maybe SnapStartApplyOn
applyOn :: Prelude.Maybe SnapStartApplyOn,
    -- | When you provide a
    -- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html#versioning-versions-using qualified Amazon Resource Name (ARN)>,
    -- this response element indicates whether SnapStart is activated for the
    -- specified function version.
    SnapStartResponse -> Maybe SnapStartOptimizationStatus
optimizationStatus :: Prelude.Maybe SnapStartOptimizationStatus
  }
  deriving (SnapStartResponse -> SnapStartResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapStartResponse -> SnapStartResponse -> Bool
$c/= :: SnapStartResponse -> SnapStartResponse -> Bool
== :: SnapStartResponse -> SnapStartResponse -> Bool
$c== :: SnapStartResponse -> SnapStartResponse -> Bool
Prelude.Eq, ReadPrec [SnapStartResponse]
ReadPrec SnapStartResponse
Int -> ReadS SnapStartResponse
ReadS [SnapStartResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapStartResponse]
$creadListPrec :: ReadPrec [SnapStartResponse]
readPrec :: ReadPrec SnapStartResponse
$creadPrec :: ReadPrec SnapStartResponse
readList :: ReadS [SnapStartResponse]
$creadList :: ReadS [SnapStartResponse]
readsPrec :: Int -> ReadS SnapStartResponse
$creadsPrec :: Int -> ReadS SnapStartResponse
Prelude.Read, Int -> SnapStartResponse -> ShowS
[SnapStartResponse] -> ShowS
SnapStartResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapStartResponse] -> ShowS
$cshowList :: [SnapStartResponse] -> ShowS
show :: SnapStartResponse -> String
$cshow :: SnapStartResponse -> String
showsPrec :: Int -> SnapStartResponse -> ShowS
$cshowsPrec :: Int -> SnapStartResponse -> ShowS
Prelude.Show, forall x. Rep SnapStartResponse x -> SnapStartResponse
forall x. SnapStartResponse -> Rep SnapStartResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapStartResponse x -> SnapStartResponse
$cfrom :: forall x. SnapStartResponse -> Rep SnapStartResponse x
Prelude.Generic)

-- |
-- Create a value of 'SnapStartResponse' 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', 'snapStartResponse_applyOn' - When set to @PublishedVersions@, Lambda creates a snapshot of the
-- execution environment when you publish a function version.
--
-- 'optimizationStatus', 'snapStartResponse_optimizationStatus' - When you provide a
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html#versioning-versions-using qualified Amazon Resource Name (ARN)>,
-- this response element indicates whether SnapStart is activated for the
-- specified function version.
newSnapStartResponse ::
  SnapStartResponse
newSnapStartResponse :: SnapStartResponse
newSnapStartResponse =
  SnapStartResponse'
    { $sel:applyOn:SnapStartResponse' :: Maybe SnapStartApplyOn
applyOn = forall a. Maybe a
Prelude.Nothing,
      $sel:optimizationStatus:SnapStartResponse' :: Maybe SnapStartOptimizationStatus
optimizationStatus = forall a. Maybe a
Prelude.Nothing
    }

-- | When set to @PublishedVersions@, Lambda creates a snapshot of the
-- execution environment when you publish a function version.
snapStartResponse_applyOn :: Lens.Lens' SnapStartResponse (Prelude.Maybe SnapStartApplyOn)
snapStartResponse_applyOn :: Lens' SnapStartResponse (Maybe SnapStartApplyOn)
snapStartResponse_applyOn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapStartResponse' {Maybe SnapStartApplyOn
applyOn :: Maybe SnapStartApplyOn
$sel:applyOn:SnapStartResponse' :: SnapStartResponse -> Maybe SnapStartApplyOn
applyOn} -> Maybe SnapStartApplyOn
applyOn) (\s :: SnapStartResponse
s@SnapStartResponse' {} Maybe SnapStartApplyOn
a -> SnapStartResponse
s {$sel:applyOn:SnapStartResponse' :: Maybe SnapStartApplyOn
applyOn = Maybe SnapStartApplyOn
a} :: SnapStartResponse)

-- | When you provide a
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html#versioning-versions-using qualified Amazon Resource Name (ARN)>,
-- this response element indicates whether SnapStart is activated for the
-- specified function version.
snapStartResponse_optimizationStatus :: Lens.Lens' SnapStartResponse (Prelude.Maybe SnapStartOptimizationStatus)
snapStartResponse_optimizationStatus :: Lens' SnapStartResponse (Maybe SnapStartOptimizationStatus)
snapStartResponse_optimizationStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapStartResponse' {Maybe SnapStartOptimizationStatus
optimizationStatus :: Maybe SnapStartOptimizationStatus
$sel:optimizationStatus:SnapStartResponse' :: SnapStartResponse -> Maybe SnapStartOptimizationStatus
optimizationStatus} -> Maybe SnapStartOptimizationStatus
optimizationStatus) (\s :: SnapStartResponse
s@SnapStartResponse' {} Maybe SnapStartOptimizationStatus
a -> SnapStartResponse
s {$sel:optimizationStatus:SnapStartResponse' :: Maybe SnapStartOptimizationStatus
optimizationStatus = Maybe SnapStartOptimizationStatus
a} :: SnapStartResponse)

instance Data.FromJSON SnapStartResponse where
  parseJSON :: Value -> Parser SnapStartResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SnapStartResponse"
      ( \Object
x ->
          Maybe SnapStartApplyOn
-> Maybe SnapStartOptimizationStatus -> SnapStartResponse
SnapStartResponse'
            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
"ApplyOn")
            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
"OptimizationStatus")
      )

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

instance Prelude.NFData SnapStartResponse where
  rnf :: SnapStartResponse -> ()
rnf SnapStartResponse' {Maybe SnapStartApplyOn
Maybe SnapStartOptimizationStatus
optimizationStatus :: Maybe SnapStartOptimizationStatus
applyOn :: Maybe SnapStartApplyOn
$sel:optimizationStatus:SnapStartResponse' :: SnapStartResponse -> Maybe SnapStartOptimizationStatus
$sel:applyOn:SnapStartResponse' :: SnapStartResponse -> Maybe SnapStartApplyOn
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapStartApplyOn
applyOn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapStartOptimizationStatus
optimizationStatus