{-# 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.FSx.Types.OpenZFSOriginSnapshotConfiguration
-- 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.FSx.Types.OpenZFSOriginSnapshotConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FSx.Types.OpenZFSCopyStrategy
import qualified Amazonka.Prelude as Prelude

-- | The snapshot configuration to use when creating an OpenZFS volume from a
-- snapshot.
--
-- /See:/ 'newOpenZFSOriginSnapshotConfiguration' smart constructor.
data OpenZFSOriginSnapshotConfiguration = OpenZFSOriginSnapshotConfiguration'
  { -- | The strategy used when copying data from the snapshot to the new volume.
    --
    -- -   @CLONE@ - The new volume references the data in the origin snapshot.
    --     Cloning a snapshot is faster than copying the data from a snapshot
    --     to a new volume and doesn\'t consume disk throughput. However, the
    --     origin snapshot can\'t be deleted if there is a volume using its
    --     copied data.
    --
    -- -   @FULL_COPY@ - Copies all data from the snapshot to the new volume.
    OpenZFSOriginSnapshotConfiguration -> Maybe OpenZFSCopyStrategy
copyStrategy :: Prelude.Maybe OpenZFSCopyStrategy,
    OpenZFSOriginSnapshotConfiguration -> Maybe Text
snapshotARN :: Prelude.Maybe Prelude.Text
  }
  deriving (OpenZFSOriginSnapshotConfiguration
-> OpenZFSOriginSnapshotConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpenZFSOriginSnapshotConfiguration
-> OpenZFSOriginSnapshotConfiguration -> Bool
$c/= :: OpenZFSOriginSnapshotConfiguration
-> OpenZFSOriginSnapshotConfiguration -> Bool
== :: OpenZFSOriginSnapshotConfiguration
-> OpenZFSOriginSnapshotConfiguration -> Bool
$c== :: OpenZFSOriginSnapshotConfiguration
-> OpenZFSOriginSnapshotConfiguration -> Bool
Prelude.Eq, ReadPrec [OpenZFSOriginSnapshotConfiguration]
ReadPrec OpenZFSOriginSnapshotConfiguration
Int -> ReadS OpenZFSOriginSnapshotConfiguration
ReadS [OpenZFSOriginSnapshotConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpenZFSOriginSnapshotConfiguration]
$creadListPrec :: ReadPrec [OpenZFSOriginSnapshotConfiguration]
readPrec :: ReadPrec OpenZFSOriginSnapshotConfiguration
$creadPrec :: ReadPrec OpenZFSOriginSnapshotConfiguration
readList :: ReadS [OpenZFSOriginSnapshotConfiguration]
$creadList :: ReadS [OpenZFSOriginSnapshotConfiguration]
readsPrec :: Int -> ReadS OpenZFSOriginSnapshotConfiguration
$creadsPrec :: Int -> ReadS OpenZFSOriginSnapshotConfiguration
Prelude.Read, Int -> OpenZFSOriginSnapshotConfiguration -> ShowS
[OpenZFSOriginSnapshotConfiguration] -> ShowS
OpenZFSOriginSnapshotConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpenZFSOriginSnapshotConfiguration] -> ShowS
$cshowList :: [OpenZFSOriginSnapshotConfiguration] -> ShowS
show :: OpenZFSOriginSnapshotConfiguration -> String
$cshow :: OpenZFSOriginSnapshotConfiguration -> String
showsPrec :: Int -> OpenZFSOriginSnapshotConfiguration -> ShowS
$cshowsPrec :: Int -> OpenZFSOriginSnapshotConfiguration -> ShowS
Prelude.Show, forall x.
Rep OpenZFSOriginSnapshotConfiguration x
-> OpenZFSOriginSnapshotConfiguration
forall x.
OpenZFSOriginSnapshotConfiguration
-> Rep OpenZFSOriginSnapshotConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OpenZFSOriginSnapshotConfiguration x
-> OpenZFSOriginSnapshotConfiguration
$cfrom :: forall x.
OpenZFSOriginSnapshotConfiguration
-> Rep OpenZFSOriginSnapshotConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'OpenZFSOriginSnapshotConfiguration' 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:
--
-- 'copyStrategy', 'openZFSOriginSnapshotConfiguration_copyStrategy' - The strategy used when copying data from the snapshot to the new volume.
--
-- -   @CLONE@ - The new volume references the data in the origin snapshot.
--     Cloning a snapshot is faster than copying the data from a snapshot
--     to a new volume and doesn\'t consume disk throughput. However, the
--     origin snapshot can\'t be deleted if there is a volume using its
--     copied data.
--
-- -   @FULL_COPY@ - Copies all data from the snapshot to the new volume.
--
-- 'snapshotARN', 'openZFSOriginSnapshotConfiguration_snapshotARN' - Undocumented member.
newOpenZFSOriginSnapshotConfiguration ::
  OpenZFSOriginSnapshotConfiguration
newOpenZFSOriginSnapshotConfiguration :: OpenZFSOriginSnapshotConfiguration
newOpenZFSOriginSnapshotConfiguration =
  OpenZFSOriginSnapshotConfiguration'
    { $sel:copyStrategy:OpenZFSOriginSnapshotConfiguration' :: Maybe OpenZFSCopyStrategy
copyStrategy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotARN:OpenZFSOriginSnapshotConfiguration' :: Maybe Text
snapshotARN = forall a. Maybe a
Prelude.Nothing
    }

-- | The strategy used when copying data from the snapshot to the new volume.
--
-- -   @CLONE@ - The new volume references the data in the origin snapshot.
--     Cloning a snapshot is faster than copying the data from a snapshot
--     to a new volume and doesn\'t consume disk throughput. However, the
--     origin snapshot can\'t be deleted if there is a volume using its
--     copied data.
--
-- -   @FULL_COPY@ - Copies all data from the snapshot to the new volume.
openZFSOriginSnapshotConfiguration_copyStrategy :: Lens.Lens' OpenZFSOriginSnapshotConfiguration (Prelude.Maybe OpenZFSCopyStrategy)
openZFSOriginSnapshotConfiguration_copyStrategy :: Lens'
  OpenZFSOriginSnapshotConfiguration (Maybe OpenZFSCopyStrategy)
openZFSOriginSnapshotConfiguration_copyStrategy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenZFSOriginSnapshotConfiguration' {Maybe OpenZFSCopyStrategy
copyStrategy :: Maybe OpenZFSCopyStrategy
$sel:copyStrategy:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe OpenZFSCopyStrategy
copyStrategy} -> Maybe OpenZFSCopyStrategy
copyStrategy) (\s :: OpenZFSOriginSnapshotConfiguration
s@OpenZFSOriginSnapshotConfiguration' {} Maybe OpenZFSCopyStrategy
a -> OpenZFSOriginSnapshotConfiguration
s {$sel:copyStrategy:OpenZFSOriginSnapshotConfiguration' :: Maybe OpenZFSCopyStrategy
copyStrategy = Maybe OpenZFSCopyStrategy
a} :: OpenZFSOriginSnapshotConfiguration)

-- | Undocumented member.
openZFSOriginSnapshotConfiguration_snapshotARN :: Lens.Lens' OpenZFSOriginSnapshotConfiguration (Prelude.Maybe Prelude.Text)
openZFSOriginSnapshotConfiguration_snapshotARN :: Lens' OpenZFSOriginSnapshotConfiguration (Maybe Text)
openZFSOriginSnapshotConfiguration_snapshotARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpenZFSOriginSnapshotConfiguration' {Maybe Text
snapshotARN :: Maybe Text
$sel:snapshotARN:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe Text
snapshotARN} -> Maybe Text
snapshotARN) (\s :: OpenZFSOriginSnapshotConfiguration
s@OpenZFSOriginSnapshotConfiguration' {} Maybe Text
a -> OpenZFSOriginSnapshotConfiguration
s {$sel:snapshotARN:OpenZFSOriginSnapshotConfiguration' :: Maybe Text
snapshotARN = Maybe Text
a} :: OpenZFSOriginSnapshotConfiguration)

instance
  Data.FromJSON
    OpenZFSOriginSnapshotConfiguration
  where
  parseJSON :: Value -> Parser OpenZFSOriginSnapshotConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OpenZFSOriginSnapshotConfiguration"
      ( \Object
x ->
          Maybe OpenZFSCopyStrategy
-> Maybe Text -> OpenZFSOriginSnapshotConfiguration
OpenZFSOriginSnapshotConfiguration'
            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
"CopyStrategy")
            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
"SnapshotARN")
      )

instance
  Prelude.Hashable
    OpenZFSOriginSnapshotConfiguration
  where
  hashWithSalt :: Int -> OpenZFSOriginSnapshotConfiguration -> Int
hashWithSalt
    Int
_salt
    OpenZFSOriginSnapshotConfiguration' {Maybe Text
Maybe OpenZFSCopyStrategy
snapshotARN :: Maybe Text
copyStrategy :: Maybe OpenZFSCopyStrategy
$sel:snapshotARN:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe Text
$sel:copyStrategy:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe OpenZFSCopyStrategy
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OpenZFSCopyStrategy
copyStrategy
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snapshotARN

instance
  Prelude.NFData
    OpenZFSOriginSnapshotConfiguration
  where
  rnf :: OpenZFSOriginSnapshotConfiguration -> ()
rnf OpenZFSOriginSnapshotConfiguration' {Maybe Text
Maybe OpenZFSCopyStrategy
snapshotARN :: Maybe Text
copyStrategy :: Maybe OpenZFSCopyStrategy
$sel:snapshotARN:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe Text
$sel:copyStrategy:OpenZFSOriginSnapshotConfiguration' :: OpenZFSOriginSnapshotConfiguration -> Maybe OpenZFSCopyStrategy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe OpenZFSCopyStrategy
copyStrategy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snapshotARN