{-# 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.KinesisAnalyticsV2.Types.FlinkRunConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisAnalyticsV2.Types.FlinkRunConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the starting parameters for a Flink-based Kinesis Data
-- Analytics application.
--
-- /See:/ 'newFlinkRunConfiguration' smart constructor.
data FlinkRunConfiguration = FlinkRunConfiguration'
  { -- | When restoring from a snapshot, specifies whether the runtime is allowed
    -- to skip a state that cannot be mapped to the new program. This will
    -- happen if the program is updated between snapshots to remove stateful
    -- parameters, and state data in the snapshot no longer corresponds to
    -- valid application data. For more information, see
    -- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/savepoints.html#allowing-non-restored-state Allowing Non-Restored State>
    -- in the
    -- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink documentation>.
    --
    -- This value defaults to @false@. If you update your application without
    -- specifying this parameter, @AllowNonRestoredState@ will be set to
    -- @false@, even if it was previously set to @true@.
    FlinkRunConfiguration -> Maybe Bool
allowNonRestoredState :: Prelude.Maybe Prelude.Bool
  }
  deriving (FlinkRunConfiguration -> FlinkRunConfiguration -> Bool
(FlinkRunConfiguration -> FlinkRunConfiguration -> Bool)
-> (FlinkRunConfiguration -> FlinkRunConfiguration -> Bool)
-> Eq FlinkRunConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FlinkRunConfiguration -> FlinkRunConfiguration -> Bool
$c/= :: FlinkRunConfiguration -> FlinkRunConfiguration -> Bool
== :: FlinkRunConfiguration -> FlinkRunConfiguration -> Bool
$c== :: FlinkRunConfiguration -> FlinkRunConfiguration -> Bool
Prelude.Eq, ReadPrec [FlinkRunConfiguration]
ReadPrec FlinkRunConfiguration
Int -> ReadS FlinkRunConfiguration
ReadS [FlinkRunConfiguration]
(Int -> ReadS FlinkRunConfiguration)
-> ReadS [FlinkRunConfiguration]
-> ReadPrec FlinkRunConfiguration
-> ReadPrec [FlinkRunConfiguration]
-> Read FlinkRunConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FlinkRunConfiguration]
$creadListPrec :: ReadPrec [FlinkRunConfiguration]
readPrec :: ReadPrec FlinkRunConfiguration
$creadPrec :: ReadPrec FlinkRunConfiguration
readList :: ReadS [FlinkRunConfiguration]
$creadList :: ReadS [FlinkRunConfiguration]
readsPrec :: Int -> ReadS FlinkRunConfiguration
$creadsPrec :: Int -> ReadS FlinkRunConfiguration
Prelude.Read, Int -> FlinkRunConfiguration -> ShowS
[FlinkRunConfiguration] -> ShowS
FlinkRunConfiguration -> String
(Int -> FlinkRunConfiguration -> ShowS)
-> (FlinkRunConfiguration -> String)
-> ([FlinkRunConfiguration] -> ShowS)
-> Show FlinkRunConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FlinkRunConfiguration] -> ShowS
$cshowList :: [FlinkRunConfiguration] -> ShowS
show :: FlinkRunConfiguration -> String
$cshow :: FlinkRunConfiguration -> String
showsPrec :: Int -> FlinkRunConfiguration -> ShowS
$cshowsPrec :: Int -> FlinkRunConfiguration -> ShowS
Prelude.Show, (forall x. FlinkRunConfiguration -> Rep FlinkRunConfiguration x)
-> (forall x. Rep FlinkRunConfiguration x -> FlinkRunConfiguration)
-> Generic FlinkRunConfiguration
forall x. Rep FlinkRunConfiguration x -> FlinkRunConfiguration
forall x. FlinkRunConfiguration -> Rep FlinkRunConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FlinkRunConfiguration x -> FlinkRunConfiguration
$cfrom :: forall x. FlinkRunConfiguration -> Rep FlinkRunConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FlinkRunConfiguration' 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:
--
-- 'allowNonRestoredState', 'flinkRunConfiguration_allowNonRestoredState' - When restoring from a snapshot, specifies whether the runtime is allowed
-- to skip a state that cannot be mapped to the new program. This will
-- happen if the program is updated between snapshots to remove stateful
-- parameters, and state data in the snapshot no longer corresponds to
-- valid application data. For more information, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/savepoints.html#allowing-non-restored-state Allowing Non-Restored State>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink documentation>.
--
-- This value defaults to @false@. If you update your application without
-- specifying this parameter, @AllowNonRestoredState@ will be set to
-- @false@, even if it was previously set to @true@.
newFlinkRunConfiguration ::
  FlinkRunConfiguration
newFlinkRunConfiguration :: FlinkRunConfiguration
newFlinkRunConfiguration =
  FlinkRunConfiguration' :: Maybe Bool -> FlinkRunConfiguration
FlinkRunConfiguration'
    { $sel:allowNonRestoredState:FlinkRunConfiguration' :: Maybe Bool
allowNonRestoredState =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | When restoring from a snapshot, specifies whether the runtime is allowed
-- to skip a state that cannot be mapped to the new program. This will
-- happen if the program is updated between snapshots to remove stateful
-- parameters, and state data in the snapshot no longer corresponds to
-- valid application data. For more information, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/savepoints.html#allowing-non-restored-state Allowing Non-Restored State>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink documentation>.
--
-- This value defaults to @false@. If you update your application without
-- specifying this parameter, @AllowNonRestoredState@ will be set to
-- @false@, even if it was previously set to @true@.
flinkRunConfiguration_allowNonRestoredState :: Lens.Lens' FlinkRunConfiguration (Prelude.Maybe Prelude.Bool)
flinkRunConfiguration_allowNonRestoredState :: (Maybe Bool -> f (Maybe Bool))
-> FlinkRunConfiguration -> f FlinkRunConfiguration
flinkRunConfiguration_allowNonRestoredState = (FlinkRunConfiguration -> Maybe Bool)
-> (FlinkRunConfiguration -> Maybe Bool -> FlinkRunConfiguration)
-> Lens
     FlinkRunConfiguration
     FlinkRunConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FlinkRunConfiguration' {Maybe Bool
allowNonRestoredState :: Maybe Bool
$sel:allowNonRestoredState:FlinkRunConfiguration' :: FlinkRunConfiguration -> Maybe Bool
allowNonRestoredState} -> Maybe Bool
allowNonRestoredState) (\s :: FlinkRunConfiguration
s@FlinkRunConfiguration' {} Maybe Bool
a -> FlinkRunConfiguration
s {$sel:allowNonRestoredState:FlinkRunConfiguration' :: Maybe Bool
allowNonRestoredState = Maybe Bool
a} :: FlinkRunConfiguration)

instance Core.FromJSON FlinkRunConfiguration where
  parseJSON :: Value -> Parser FlinkRunConfiguration
parseJSON =
    String
-> (Object -> Parser FlinkRunConfiguration)
-> Value
-> Parser FlinkRunConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FlinkRunConfiguration"
      ( \Object
x ->
          Maybe Bool -> FlinkRunConfiguration
FlinkRunConfiguration'
            (Maybe Bool -> FlinkRunConfiguration)
-> Parser (Maybe Bool) -> Parser FlinkRunConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AllowNonRestoredState")
      )

instance Prelude.Hashable FlinkRunConfiguration

instance Prelude.NFData FlinkRunConfiguration

instance Core.ToJSON FlinkRunConfiguration where
  toJSON :: FlinkRunConfiguration -> Value
toJSON FlinkRunConfiguration' {Maybe Bool
allowNonRestoredState :: Maybe Bool
$sel:allowNonRestoredState:FlinkRunConfiguration' :: FlinkRunConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AllowNonRestoredState" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowNonRestoredState
          ]
      )