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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.ApplicationRestoreType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the method and snapshot to use when restarting an application
-- using previously saved application state.
--
-- /See:/ 'newApplicationRestoreConfiguration' smart constructor.
data ApplicationRestoreConfiguration = ApplicationRestoreConfiguration'
  { -- | The identifier of an existing snapshot of application state to use to
    -- restart an application. The application uses this value if
    -- @RESTORE_FROM_CUSTOM_SNAPSHOT@ is specified for the
    -- @ApplicationRestoreType@.
    ApplicationRestoreConfiguration -> Maybe Text
snapshotName :: Prelude.Maybe Prelude.Text,
    -- | Specifies how the application should be restored.
    ApplicationRestoreConfiguration -> ApplicationRestoreType
applicationRestoreType :: ApplicationRestoreType
  }
  deriving (ApplicationRestoreConfiguration
-> ApplicationRestoreConfiguration -> Bool
(ApplicationRestoreConfiguration
 -> ApplicationRestoreConfiguration -> Bool)
-> (ApplicationRestoreConfiguration
    -> ApplicationRestoreConfiguration -> Bool)
-> Eq ApplicationRestoreConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationRestoreConfiguration
-> ApplicationRestoreConfiguration -> Bool
$c/= :: ApplicationRestoreConfiguration
-> ApplicationRestoreConfiguration -> Bool
== :: ApplicationRestoreConfiguration
-> ApplicationRestoreConfiguration -> Bool
$c== :: ApplicationRestoreConfiguration
-> ApplicationRestoreConfiguration -> Bool
Prelude.Eq, ReadPrec [ApplicationRestoreConfiguration]
ReadPrec ApplicationRestoreConfiguration
Int -> ReadS ApplicationRestoreConfiguration
ReadS [ApplicationRestoreConfiguration]
(Int -> ReadS ApplicationRestoreConfiguration)
-> ReadS [ApplicationRestoreConfiguration]
-> ReadPrec ApplicationRestoreConfiguration
-> ReadPrec [ApplicationRestoreConfiguration]
-> Read ApplicationRestoreConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationRestoreConfiguration]
$creadListPrec :: ReadPrec [ApplicationRestoreConfiguration]
readPrec :: ReadPrec ApplicationRestoreConfiguration
$creadPrec :: ReadPrec ApplicationRestoreConfiguration
readList :: ReadS [ApplicationRestoreConfiguration]
$creadList :: ReadS [ApplicationRestoreConfiguration]
readsPrec :: Int -> ReadS ApplicationRestoreConfiguration
$creadsPrec :: Int -> ReadS ApplicationRestoreConfiguration
Prelude.Read, Int -> ApplicationRestoreConfiguration -> ShowS
[ApplicationRestoreConfiguration] -> ShowS
ApplicationRestoreConfiguration -> String
(Int -> ApplicationRestoreConfiguration -> ShowS)
-> (ApplicationRestoreConfiguration -> String)
-> ([ApplicationRestoreConfiguration] -> ShowS)
-> Show ApplicationRestoreConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationRestoreConfiguration] -> ShowS
$cshowList :: [ApplicationRestoreConfiguration] -> ShowS
show :: ApplicationRestoreConfiguration -> String
$cshow :: ApplicationRestoreConfiguration -> String
showsPrec :: Int -> ApplicationRestoreConfiguration -> ShowS
$cshowsPrec :: Int -> ApplicationRestoreConfiguration -> ShowS
Prelude.Show, (forall x.
 ApplicationRestoreConfiguration
 -> Rep ApplicationRestoreConfiguration x)
-> (forall x.
    Rep ApplicationRestoreConfiguration x
    -> ApplicationRestoreConfiguration)
-> Generic ApplicationRestoreConfiguration
forall x.
Rep ApplicationRestoreConfiguration x
-> ApplicationRestoreConfiguration
forall x.
ApplicationRestoreConfiguration
-> Rep ApplicationRestoreConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ApplicationRestoreConfiguration x
-> ApplicationRestoreConfiguration
$cfrom :: forall x.
ApplicationRestoreConfiguration
-> Rep ApplicationRestoreConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationRestoreConfiguration' 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:
--
-- 'snapshotName', 'applicationRestoreConfiguration_snapshotName' - The identifier of an existing snapshot of application state to use to
-- restart an application. The application uses this value if
-- @RESTORE_FROM_CUSTOM_SNAPSHOT@ is specified for the
-- @ApplicationRestoreType@.
--
-- 'applicationRestoreType', 'applicationRestoreConfiguration_applicationRestoreType' - Specifies how the application should be restored.
newApplicationRestoreConfiguration ::
  -- | 'applicationRestoreType'
  ApplicationRestoreType ->
  ApplicationRestoreConfiguration
newApplicationRestoreConfiguration :: ApplicationRestoreType -> ApplicationRestoreConfiguration
newApplicationRestoreConfiguration
  ApplicationRestoreType
pApplicationRestoreType_ =
    ApplicationRestoreConfiguration' :: Maybe Text
-> ApplicationRestoreType -> ApplicationRestoreConfiguration
ApplicationRestoreConfiguration'
      { $sel:snapshotName:ApplicationRestoreConfiguration' :: Maybe Text
snapshotName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationRestoreType:ApplicationRestoreConfiguration' :: ApplicationRestoreType
applicationRestoreType =
          ApplicationRestoreType
pApplicationRestoreType_
      }

-- | The identifier of an existing snapshot of application state to use to
-- restart an application. The application uses this value if
-- @RESTORE_FROM_CUSTOM_SNAPSHOT@ is specified for the
-- @ApplicationRestoreType@.
applicationRestoreConfiguration_snapshotName :: Lens.Lens' ApplicationRestoreConfiguration (Prelude.Maybe Prelude.Text)
applicationRestoreConfiguration_snapshotName :: (Maybe Text -> f (Maybe Text))
-> ApplicationRestoreConfiguration
-> f ApplicationRestoreConfiguration
applicationRestoreConfiguration_snapshotName = (ApplicationRestoreConfiguration -> Maybe Text)
-> (ApplicationRestoreConfiguration
    -> Maybe Text -> ApplicationRestoreConfiguration)
-> Lens
     ApplicationRestoreConfiguration
     ApplicationRestoreConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationRestoreConfiguration' {Maybe Text
snapshotName :: Maybe Text
$sel:snapshotName:ApplicationRestoreConfiguration' :: ApplicationRestoreConfiguration -> Maybe Text
snapshotName} -> Maybe Text
snapshotName) (\s :: ApplicationRestoreConfiguration
s@ApplicationRestoreConfiguration' {} Maybe Text
a -> ApplicationRestoreConfiguration
s {$sel:snapshotName:ApplicationRestoreConfiguration' :: Maybe Text
snapshotName = Maybe Text
a} :: ApplicationRestoreConfiguration)

-- | Specifies how the application should be restored.
applicationRestoreConfiguration_applicationRestoreType :: Lens.Lens' ApplicationRestoreConfiguration ApplicationRestoreType
applicationRestoreConfiguration_applicationRestoreType :: (ApplicationRestoreType -> f ApplicationRestoreType)
-> ApplicationRestoreConfiguration
-> f ApplicationRestoreConfiguration
applicationRestoreConfiguration_applicationRestoreType = (ApplicationRestoreConfiguration -> ApplicationRestoreType)
-> (ApplicationRestoreConfiguration
    -> ApplicationRestoreType -> ApplicationRestoreConfiguration)
-> Lens
     ApplicationRestoreConfiguration
     ApplicationRestoreConfiguration
     ApplicationRestoreType
     ApplicationRestoreType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationRestoreConfiguration' {ApplicationRestoreType
applicationRestoreType :: ApplicationRestoreType
$sel:applicationRestoreType:ApplicationRestoreConfiguration' :: ApplicationRestoreConfiguration -> ApplicationRestoreType
applicationRestoreType} -> ApplicationRestoreType
applicationRestoreType) (\s :: ApplicationRestoreConfiguration
s@ApplicationRestoreConfiguration' {} ApplicationRestoreType
a -> ApplicationRestoreConfiguration
s {$sel:applicationRestoreType:ApplicationRestoreConfiguration' :: ApplicationRestoreType
applicationRestoreType = ApplicationRestoreType
a} :: ApplicationRestoreConfiguration)

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

instance
  Prelude.Hashable
    ApplicationRestoreConfiguration

instance
  Prelude.NFData
    ApplicationRestoreConfiguration

instance Core.ToJSON ApplicationRestoreConfiguration where
  toJSON :: ApplicationRestoreConfiguration -> Value
toJSON ApplicationRestoreConfiguration' {Maybe Text
ApplicationRestoreType
applicationRestoreType :: ApplicationRestoreType
snapshotName :: Maybe Text
$sel:applicationRestoreType:ApplicationRestoreConfiguration' :: ApplicationRestoreConfiguration -> ApplicationRestoreType
$sel:snapshotName:ApplicationRestoreConfiguration' :: ApplicationRestoreConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SnapshotName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snapshotName,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ApplicationRestoreType"
                  Text -> ApplicationRestoreType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ApplicationRestoreType
applicationRestoreType
              )
          ]
      )