{-# 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.StorageGateway.Types.AutomaticTapeCreationRule
-- 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.StorageGateway.Types.AutomaticTapeCreationRule where

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

-- | An automatic tape creation policy consists of automatic tape creation
-- rules where each rule defines when and how to create new tapes. For more
-- information about automatic tape creation, see
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/GettingStartedCreateTapes.html#CreateTapesAutomatically Creating Tapes Automatically>.
--
-- /See:/ 'newAutomaticTapeCreationRule' smart constructor.
data AutomaticTapeCreationRule = AutomaticTapeCreationRule'
  { -- | Set to @true@ to indicate that tapes are to be archived as
    -- write-once-read-many (WORM). Set to @false@ when WORM is not enabled for
    -- tapes.
    AutomaticTapeCreationRule -> Maybe Bool
worm :: Prelude.Maybe Prelude.Bool,
    -- | A prefix that you append to the barcode of the virtual tape that you are
    -- creating. This prefix makes the barcode unique.
    --
    -- The prefix must be 1-4 characters in length and must be one of the
    -- uppercase letters from A to Z.
    AutomaticTapeCreationRule -> Text
tapeBarcodePrefix :: Prelude.Text,
    -- | The ID of the pool that you want to add your tape to for archiving. The
    -- tape in this pool is archived in the Amazon S3 storage class that is
    -- associated with the pool. When you use your backup application to eject
    -- the tape, the tape is archived directly into the storage class (S3
    -- Glacier or S3 Glacier Deep Archive) that corresponds to the pool.
    AutomaticTapeCreationRule -> Text
poolId :: Prelude.Text,
    -- | The size, in bytes, of the virtual tape capacity.
    AutomaticTapeCreationRule -> Integer
tapeSizeInBytes :: Prelude.Integer,
    -- | The minimum number of available virtual tapes that the gateway maintains
    -- at all times. If the number of tapes on the gateway goes below this
    -- value, the gateway creates as many new tapes as are needed to have
    -- @MinimumNumTapes@ on the gateway. For more information about automatic
    -- tape creation, see
    -- <https://docs.aws.amazon.com/storagegateway/latest/userguide/GettingStartedCreateTapes.html#CreateTapesAutomatically Creating Tapes Automatically>.
    AutomaticTapeCreationRule -> Natural
minimumNumTapes :: Prelude.Natural
  }
  deriving (AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool
$c/= :: AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool
== :: AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool
$c== :: AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool
Prelude.Eq, ReadPrec [AutomaticTapeCreationRule]
ReadPrec AutomaticTapeCreationRule
Int -> ReadS AutomaticTapeCreationRule
ReadS [AutomaticTapeCreationRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutomaticTapeCreationRule]
$creadListPrec :: ReadPrec [AutomaticTapeCreationRule]
readPrec :: ReadPrec AutomaticTapeCreationRule
$creadPrec :: ReadPrec AutomaticTapeCreationRule
readList :: ReadS [AutomaticTapeCreationRule]
$creadList :: ReadS [AutomaticTapeCreationRule]
readsPrec :: Int -> ReadS AutomaticTapeCreationRule
$creadsPrec :: Int -> ReadS AutomaticTapeCreationRule
Prelude.Read, Int -> AutomaticTapeCreationRule -> ShowS
[AutomaticTapeCreationRule] -> ShowS
AutomaticTapeCreationRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutomaticTapeCreationRule] -> ShowS
$cshowList :: [AutomaticTapeCreationRule] -> ShowS
show :: AutomaticTapeCreationRule -> String
$cshow :: AutomaticTapeCreationRule -> String
showsPrec :: Int -> AutomaticTapeCreationRule -> ShowS
$cshowsPrec :: Int -> AutomaticTapeCreationRule -> ShowS
Prelude.Show, forall x.
Rep AutomaticTapeCreationRule x -> AutomaticTapeCreationRule
forall x.
AutomaticTapeCreationRule -> Rep AutomaticTapeCreationRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutomaticTapeCreationRule x -> AutomaticTapeCreationRule
$cfrom :: forall x.
AutomaticTapeCreationRule -> Rep AutomaticTapeCreationRule x
Prelude.Generic)

-- |
-- Create a value of 'AutomaticTapeCreationRule' 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:
--
-- 'worm', 'automaticTapeCreationRule_worm' - Set to @true@ to indicate that tapes are to be archived as
-- write-once-read-many (WORM). Set to @false@ when WORM is not enabled for
-- tapes.
--
-- 'tapeBarcodePrefix', 'automaticTapeCreationRule_tapeBarcodePrefix' - A prefix that you append to the barcode of the virtual tape that you are
-- creating. This prefix makes the barcode unique.
--
-- The prefix must be 1-4 characters in length and must be one of the
-- uppercase letters from A to Z.
--
-- 'poolId', 'automaticTapeCreationRule_poolId' - The ID of the pool that you want to add your tape to for archiving. The
-- tape in this pool is archived in the Amazon S3 storage class that is
-- associated with the pool. When you use your backup application to eject
-- the tape, the tape is archived directly into the storage class (S3
-- Glacier or S3 Glacier Deep Archive) that corresponds to the pool.
--
-- 'tapeSizeInBytes', 'automaticTapeCreationRule_tapeSizeInBytes' - The size, in bytes, of the virtual tape capacity.
--
-- 'minimumNumTapes', 'automaticTapeCreationRule_minimumNumTapes' - The minimum number of available virtual tapes that the gateway maintains
-- at all times. If the number of tapes on the gateway goes below this
-- value, the gateway creates as many new tapes as are needed to have
-- @MinimumNumTapes@ on the gateway. For more information about automatic
-- tape creation, see
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/GettingStartedCreateTapes.html#CreateTapesAutomatically Creating Tapes Automatically>.
newAutomaticTapeCreationRule ::
  -- | 'tapeBarcodePrefix'
  Prelude.Text ->
  -- | 'poolId'
  Prelude.Text ->
  -- | 'tapeSizeInBytes'
  Prelude.Integer ->
  -- | 'minimumNumTapes'
  Prelude.Natural ->
  AutomaticTapeCreationRule
newAutomaticTapeCreationRule :: Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule
newAutomaticTapeCreationRule
  Text
pTapeBarcodePrefix_
  Text
pPoolId_
  Integer
pTapeSizeInBytes_
  Natural
pMinimumNumTapes_ =
    AutomaticTapeCreationRule'
      { $sel:worm:AutomaticTapeCreationRule' :: Maybe Bool
worm = forall a. Maybe a
Prelude.Nothing,
        $sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: Text
tapeBarcodePrefix = Text
pTapeBarcodePrefix_,
        $sel:poolId:AutomaticTapeCreationRule' :: Text
poolId = Text
pPoolId_,
        $sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: Integer
tapeSizeInBytes = Integer
pTapeSizeInBytes_,
        $sel:minimumNumTapes:AutomaticTapeCreationRule' :: Natural
minimumNumTapes = Natural
pMinimumNumTapes_
      }

-- | Set to @true@ to indicate that tapes are to be archived as
-- write-once-read-many (WORM). Set to @false@ when WORM is not enabled for
-- tapes.
automaticTapeCreationRule_worm :: Lens.Lens' AutomaticTapeCreationRule (Prelude.Maybe Prelude.Bool)
automaticTapeCreationRule_worm :: Lens' AutomaticTapeCreationRule (Maybe Bool)
automaticTapeCreationRule_worm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutomaticTapeCreationRule' {Maybe Bool
worm :: Maybe Bool
$sel:worm:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Maybe Bool
worm} -> Maybe Bool
worm) (\s :: AutomaticTapeCreationRule
s@AutomaticTapeCreationRule' {} Maybe Bool
a -> AutomaticTapeCreationRule
s {$sel:worm:AutomaticTapeCreationRule' :: Maybe Bool
worm = Maybe Bool
a} :: AutomaticTapeCreationRule)

-- | A prefix that you append to the barcode of the virtual tape that you are
-- creating. This prefix makes the barcode unique.
--
-- The prefix must be 1-4 characters in length and must be one of the
-- uppercase letters from A to Z.
automaticTapeCreationRule_tapeBarcodePrefix :: Lens.Lens' AutomaticTapeCreationRule Prelude.Text
automaticTapeCreationRule_tapeBarcodePrefix :: Lens' AutomaticTapeCreationRule Text
automaticTapeCreationRule_tapeBarcodePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutomaticTapeCreationRule' {Text
tapeBarcodePrefix :: Text
$sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
tapeBarcodePrefix} -> Text
tapeBarcodePrefix) (\s :: AutomaticTapeCreationRule
s@AutomaticTapeCreationRule' {} Text
a -> AutomaticTapeCreationRule
s {$sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: Text
tapeBarcodePrefix = Text
a} :: AutomaticTapeCreationRule)

-- | The ID of the pool that you want to add your tape to for archiving. The
-- tape in this pool is archived in the Amazon S3 storage class that is
-- associated with the pool. When you use your backup application to eject
-- the tape, the tape is archived directly into the storage class (S3
-- Glacier or S3 Glacier Deep Archive) that corresponds to the pool.
automaticTapeCreationRule_poolId :: Lens.Lens' AutomaticTapeCreationRule Prelude.Text
automaticTapeCreationRule_poolId :: Lens' AutomaticTapeCreationRule Text
automaticTapeCreationRule_poolId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutomaticTapeCreationRule' {Text
poolId :: Text
$sel:poolId:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
poolId} -> Text
poolId) (\s :: AutomaticTapeCreationRule
s@AutomaticTapeCreationRule' {} Text
a -> AutomaticTapeCreationRule
s {$sel:poolId:AutomaticTapeCreationRule' :: Text
poolId = Text
a} :: AutomaticTapeCreationRule)

-- | The size, in bytes, of the virtual tape capacity.
automaticTapeCreationRule_tapeSizeInBytes :: Lens.Lens' AutomaticTapeCreationRule Prelude.Integer
automaticTapeCreationRule_tapeSizeInBytes :: Lens' AutomaticTapeCreationRule Integer
automaticTapeCreationRule_tapeSizeInBytes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutomaticTapeCreationRule' {Integer
tapeSizeInBytes :: Integer
$sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Integer
tapeSizeInBytes} -> Integer
tapeSizeInBytes) (\s :: AutomaticTapeCreationRule
s@AutomaticTapeCreationRule' {} Integer
a -> AutomaticTapeCreationRule
s {$sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: Integer
tapeSizeInBytes = Integer
a} :: AutomaticTapeCreationRule)

-- | The minimum number of available virtual tapes that the gateway maintains
-- at all times. If the number of tapes on the gateway goes below this
-- value, the gateway creates as many new tapes as are needed to have
-- @MinimumNumTapes@ on the gateway. For more information about automatic
-- tape creation, see
-- <https://docs.aws.amazon.com/storagegateway/latest/userguide/GettingStartedCreateTapes.html#CreateTapesAutomatically Creating Tapes Automatically>.
automaticTapeCreationRule_minimumNumTapes :: Lens.Lens' AutomaticTapeCreationRule Prelude.Natural
automaticTapeCreationRule_minimumNumTapes :: Lens' AutomaticTapeCreationRule Natural
automaticTapeCreationRule_minimumNumTapes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutomaticTapeCreationRule' {Natural
minimumNumTapes :: Natural
$sel:minimumNumTapes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Natural
minimumNumTapes} -> Natural
minimumNumTapes) (\s :: AutomaticTapeCreationRule
s@AutomaticTapeCreationRule' {} Natural
a -> AutomaticTapeCreationRule
s {$sel:minimumNumTapes:AutomaticTapeCreationRule' :: Natural
minimumNumTapes = Natural
a} :: AutomaticTapeCreationRule)

instance Data.FromJSON AutomaticTapeCreationRule where
  parseJSON :: Value -> Parser AutomaticTapeCreationRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutomaticTapeCreationRule"
      ( \Object
x ->
          Maybe Bool
-> Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule
AutomaticTapeCreationRule'
            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
"Worm")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TapeBarcodePrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"PoolId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"TapeSizeInBytes")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MinimumNumTapes")
      )

instance Prelude.Hashable AutomaticTapeCreationRule where
  hashWithSalt :: Int -> AutomaticTapeCreationRule -> Int
hashWithSalt Int
_salt AutomaticTapeCreationRule' {Integer
Natural
Maybe Bool
Text
minimumNumTapes :: Natural
tapeSizeInBytes :: Integer
poolId :: Text
tapeBarcodePrefix :: Text
worm :: Maybe Bool
$sel:minimumNumTapes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Natural
$sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Integer
$sel:poolId:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:worm:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
worm
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tapeBarcodePrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
poolId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
tapeSizeInBytes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
minimumNumTapes

instance Prelude.NFData AutomaticTapeCreationRule where
  rnf :: AutomaticTapeCreationRule -> ()
rnf AutomaticTapeCreationRule' {Integer
Natural
Maybe Bool
Text
minimumNumTapes :: Natural
tapeSizeInBytes :: Integer
poolId :: Text
tapeBarcodePrefix :: Text
worm :: Maybe Bool
$sel:minimumNumTapes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Natural
$sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Integer
$sel:poolId:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:worm:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
worm
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tapeBarcodePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
poolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
tapeSizeInBytes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
minimumNumTapes

instance Data.ToJSON AutomaticTapeCreationRule where
  toJSON :: AutomaticTapeCreationRule -> Value
toJSON AutomaticTapeCreationRule' {Integer
Natural
Maybe Bool
Text
minimumNumTapes :: Natural
tapeSizeInBytes :: Integer
poolId :: Text
tapeBarcodePrefix :: Text
worm :: Maybe Bool
$sel:minimumNumTapes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Natural
$sel:tapeSizeInBytes:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Integer
$sel:poolId:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:tapeBarcodePrefix:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Text
$sel:worm:AutomaticTapeCreationRule' :: AutomaticTapeCreationRule -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Worm" 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 Bool
worm,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TapeBarcodePrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tapeBarcodePrefix),
            forall a. a -> Maybe a
Prelude.Just (Key
"PoolId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
poolId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TapeSizeInBytes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Integer
tapeSizeInBytes),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MinimumNumTapes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
minimumNumTapes)
          ]
      )