{-# 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.TieringPolicy
-- 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.TieringPolicy 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.TieringPolicyName
import qualified Amazonka.Prelude as Prelude

-- | Describes the data tiering policy for an ONTAP volume. When enabled,
-- Amazon FSx for ONTAP\'s intelligent tiering automatically transitions a
-- volume\'s data between the file system\'s primary storage and capacity
-- pool storage based on your access patterns.
--
-- Valid tiering policies are the following:
--
-- -   @SNAPSHOT_ONLY@ - (Default value) moves cold snapshots to the
--     capacity pool storage tier.
--
-- -   @AUTO@ - moves cold user data and snapshots to the capacity pool
--     storage tier based on your access patterns.
--
-- -   @ALL@ - moves all user data blocks in both the active file system
--     and Snapshot copies to the storage pool tier.
--
-- -   @NONE@ - keeps a volume\'s data in the primary storage tier,
--     preventing it from being moved to the capacity pool tier.
--
-- /See:/ 'newTieringPolicy' smart constructor.
data TieringPolicy = TieringPolicy'
  { -- | Specifies the number of days that user data in a volume must remain
    -- inactive before it is considered \"cold\" and moved to the capacity
    -- pool. Used with the @AUTO@ and @SNAPSHOT_ONLY@ tiering policies. Enter a
    -- whole number between 2 and 183. Default values are 31 days for @AUTO@
    -- and 2 days for @SNAPSHOT_ONLY@.
    TieringPolicy -> Maybe Natural
coolingPeriod :: Prelude.Maybe Prelude.Natural,
    -- | Specifies the tiering policy used to transition data. Default value is
    -- @SNAPSHOT_ONLY@.
    --
    -- -   @SNAPSHOT_ONLY@ - moves cold snapshots to the capacity pool storage
    --     tier.
    --
    -- -   @AUTO@ - moves cold user data and snapshots to the capacity pool
    --     storage tier based on your access patterns.
    --
    -- -   @ALL@ - moves all user data blocks in both the active file system
    --     and Snapshot copies to the storage pool tier.
    --
    -- -   @NONE@ - keeps a volume\'s data in the primary storage tier,
    --     preventing it from being moved to the capacity pool tier.
    TieringPolicy -> Maybe TieringPolicyName
name :: Prelude.Maybe TieringPolicyName
  }
  deriving (TieringPolicy -> TieringPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TieringPolicy -> TieringPolicy -> Bool
$c/= :: TieringPolicy -> TieringPolicy -> Bool
== :: TieringPolicy -> TieringPolicy -> Bool
$c== :: TieringPolicy -> TieringPolicy -> Bool
Prelude.Eq, ReadPrec [TieringPolicy]
ReadPrec TieringPolicy
Int -> ReadS TieringPolicy
ReadS [TieringPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TieringPolicy]
$creadListPrec :: ReadPrec [TieringPolicy]
readPrec :: ReadPrec TieringPolicy
$creadPrec :: ReadPrec TieringPolicy
readList :: ReadS [TieringPolicy]
$creadList :: ReadS [TieringPolicy]
readsPrec :: Int -> ReadS TieringPolicy
$creadsPrec :: Int -> ReadS TieringPolicy
Prelude.Read, Int -> TieringPolicy -> ShowS
[TieringPolicy] -> ShowS
TieringPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TieringPolicy] -> ShowS
$cshowList :: [TieringPolicy] -> ShowS
show :: TieringPolicy -> String
$cshow :: TieringPolicy -> String
showsPrec :: Int -> TieringPolicy -> ShowS
$cshowsPrec :: Int -> TieringPolicy -> ShowS
Prelude.Show, forall x. Rep TieringPolicy x -> TieringPolicy
forall x. TieringPolicy -> Rep TieringPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TieringPolicy x -> TieringPolicy
$cfrom :: forall x. TieringPolicy -> Rep TieringPolicy x
Prelude.Generic)

-- |
-- Create a value of 'TieringPolicy' 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:
--
-- 'coolingPeriod', 'tieringPolicy_coolingPeriod' - Specifies the number of days that user data in a volume must remain
-- inactive before it is considered \"cold\" and moved to the capacity
-- pool. Used with the @AUTO@ and @SNAPSHOT_ONLY@ tiering policies. Enter a
-- whole number between 2 and 183. Default values are 31 days for @AUTO@
-- and 2 days for @SNAPSHOT_ONLY@.
--
-- 'name', 'tieringPolicy_name' - Specifies the tiering policy used to transition data. Default value is
-- @SNAPSHOT_ONLY@.
--
-- -   @SNAPSHOT_ONLY@ - moves cold snapshots to the capacity pool storage
--     tier.
--
-- -   @AUTO@ - moves cold user data and snapshots to the capacity pool
--     storage tier based on your access patterns.
--
-- -   @ALL@ - moves all user data blocks in both the active file system
--     and Snapshot copies to the storage pool tier.
--
-- -   @NONE@ - keeps a volume\'s data in the primary storage tier,
--     preventing it from being moved to the capacity pool tier.
newTieringPolicy ::
  TieringPolicy
newTieringPolicy :: TieringPolicy
newTieringPolicy =
  TieringPolicy'
    { $sel:coolingPeriod:TieringPolicy' :: Maybe Natural
coolingPeriod = forall a. Maybe a
Prelude.Nothing,
      $sel:name:TieringPolicy' :: Maybe TieringPolicyName
name = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the number of days that user data in a volume must remain
-- inactive before it is considered \"cold\" and moved to the capacity
-- pool. Used with the @AUTO@ and @SNAPSHOT_ONLY@ tiering policies. Enter a
-- whole number between 2 and 183. Default values are 31 days for @AUTO@
-- and 2 days for @SNAPSHOT_ONLY@.
tieringPolicy_coolingPeriod :: Lens.Lens' TieringPolicy (Prelude.Maybe Prelude.Natural)
tieringPolicy_coolingPeriod :: Lens' TieringPolicy (Maybe Natural)
tieringPolicy_coolingPeriod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TieringPolicy' {Maybe Natural
coolingPeriod :: Maybe Natural
$sel:coolingPeriod:TieringPolicy' :: TieringPolicy -> Maybe Natural
coolingPeriod} -> Maybe Natural
coolingPeriod) (\s :: TieringPolicy
s@TieringPolicy' {} Maybe Natural
a -> TieringPolicy
s {$sel:coolingPeriod:TieringPolicy' :: Maybe Natural
coolingPeriod = Maybe Natural
a} :: TieringPolicy)

-- | Specifies the tiering policy used to transition data. Default value is
-- @SNAPSHOT_ONLY@.
--
-- -   @SNAPSHOT_ONLY@ - moves cold snapshots to the capacity pool storage
--     tier.
--
-- -   @AUTO@ - moves cold user data and snapshots to the capacity pool
--     storage tier based on your access patterns.
--
-- -   @ALL@ - moves all user data blocks in both the active file system
--     and Snapshot copies to the storage pool tier.
--
-- -   @NONE@ - keeps a volume\'s data in the primary storage tier,
--     preventing it from being moved to the capacity pool tier.
tieringPolicy_name :: Lens.Lens' TieringPolicy (Prelude.Maybe TieringPolicyName)
tieringPolicy_name :: Lens' TieringPolicy (Maybe TieringPolicyName)
tieringPolicy_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TieringPolicy' {Maybe TieringPolicyName
name :: Maybe TieringPolicyName
$sel:name:TieringPolicy' :: TieringPolicy -> Maybe TieringPolicyName
name} -> Maybe TieringPolicyName
name) (\s :: TieringPolicy
s@TieringPolicy' {} Maybe TieringPolicyName
a -> TieringPolicy
s {$sel:name:TieringPolicy' :: Maybe TieringPolicyName
name = Maybe TieringPolicyName
a} :: TieringPolicy)

instance Data.FromJSON TieringPolicy where
  parseJSON :: Value -> Parser TieringPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TieringPolicy"
      ( \Object
x ->
          Maybe Natural -> Maybe TieringPolicyName -> TieringPolicy
TieringPolicy'
            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
"CoolingPeriod")
            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
"Name")
      )

instance Prelude.Hashable TieringPolicy where
  hashWithSalt :: Int -> TieringPolicy -> Int
hashWithSalt Int
_salt TieringPolicy' {Maybe Natural
Maybe TieringPolicyName
name :: Maybe TieringPolicyName
coolingPeriod :: Maybe Natural
$sel:name:TieringPolicy' :: TieringPolicy -> Maybe TieringPolicyName
$sel:coolingPeriod:TieringPolicy' :: TieringPolicy -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
coolingPeriod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TieringPolicyName
name

instance Prelude.NFData TieringPolicy where
  rnf :: TieringPolicy -> ()
rnf TieringPolicy' {Maybe Natural
Maybe TieringPolicyName
name :: Maybe TieringPolicyName
coolingPeriod :: Maybe Natural
$sel:name:TieringPolicy' :: TieringPolicy -> Maybe TieringPolicyName
$sel:coolingPeriod:TieringPolicy' :: TieringPolicy -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
coolingPeriod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TieringPolicyName
name

instance Data.ToJSON TieringPolicy where
  toJSON :: TieringPolicy -> Value
toJSON TieringPolicy' {Maybe Natural
Maybe TieringPolicyName
name :: Maybe TieringPolicyName
coolingPeriod :: Maybe Natural
$sel:name:TieringPolicy' :: TieringPolicy -> Maybe TieringPolicyName
$sel:coolingPeriod:TieringPolicy' :: TieringPolicy -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CoolingPeriod" 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 Natural
coolingPeriod,
            (Key
"Name" 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 TieringPolicyName
name
          ]
      )