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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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.
    --
    -- Valid Values: @GLACIER@ | @DEEP_ARCHIVE@
    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
(AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool)
-> (AutomaticTapeCreationRule -> AutomaticTapeCreationRule -> Bool)
-> Eq AutomaticTapeCreationRule
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]
(Int -> ReadS AutomaticTapeCreationRule)
-> ReadS [AutomaticTapeCreationRule]
-> ReadPrec AutomaticTapeCreationRule
-> ReadPrec [AutomaticTapeCreationRule]
-> Read 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
(Int -> AutomaticTapeCreationRule -> ShowS)
-> (AutomaticTapeCreationRule -> String)
-> ([AutomaticTapeCreationRule] -> ShowS)
-> Show AutomaticTapeCreationRule
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.
 AutomaticTapeCreationRule -> Rep AutomaticTapeCreationRule x)
-> (forall x.
    Rep AutomaticTapeCreationRule x -> AutomaticTapeCreationRule)
-> Generic AutomaticTapeCreationRule
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.
--
-- Valid Values: @GLACIER@ | @DEEP_ARCHIVE@
--
-- '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' :: Maybe Bool
-> Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule
AutomaticTapeCreationRule'
      { $sel:worm:AutomaticTapeCreationRule' :: Maybe Bool
worm = Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> AutomaticTapeCreationRule -> f AutomaticTapeCreationRule
automaticTapeCreationRule_worm = (AutomaticTapeCreationRule -> Maybe Bool)
-> (AutomaticTapeCreationRule
    -> Maybe Bool -> AutomaticTapeCreationRule)
-> Lens
     AutomaticTapeCreationRule
     AutomaticTapeCreationRule
     (Maybe Bool)
     (Maybe Bool)
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 :: (Text -> f Text)
-> AutomaticTapeCreationRule -> f AutomaticTapeCreationRule
automaticTapeCreationRule_tapeBarcodePrefix = (AutomaticTapeCreationRule -> Text)
-> (AutomaticTapeCreationRule -> Text -> AutomaticTapeCreationRule)
-> Lens
     AutomaticTapeCreationRule AutomaticTapeCreationRule Text Text
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.
--
-- Valid Values: @GLACIER@ | @DEEP_ARCHIVE@
automaticTapeCreationRule_poolId :: Lens.Lens' AutomaticTapeCreationRule Prelude.Text
automaticTapeCreationRule_poolId :: (Text -> f Text)
-> AutomaticTapeCreationRule -> f AutomaticTapeCreationRule
automaticTapeCreationRule_poolId = (AutomaticTapeCreationRule -> Text)
-> (AutomaticTapeCreationRule -> Text -> AutomaticTapeCreationRule)
-> Lens
     AutomaticTapeCreationRule AutomaticTapeCreationRule Text Text
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 :: (Integer -> f Integer)
-> AutomaticTapeCreationRule -> f AutomaticTapeCreationRule
automaticTapeCreationRule_tapeSizeInBytes = (AutomaticTapeCreationRule -> Integer)
-> (AutomaticTapeCreationRule
    -> Integer -> AutomaticTapeCreationRule)
-> Lens
     AutomaticTapeCreationRule AutomaticTapeCreationRule Integer Integer
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 :: (Natural -> f Natural)
-> AutomaticTapeCreationRule -> f AutomaticTapeCreationRule
automaticTapeCreationRule_minimumNumTapes = (AutomaticTapeCreationRule -> Natural)
-> (AutomaticTapeCreationRule
    -> Natural -> AutomaticTapeCreationRule)
-> Lens
     AutomaticTapeCreationRule AutomaticTapeCreationRule Natural Natural
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 Core.FromJSON AutomaticTapeCreationRule where
  parseJSON :: Value -> Parser AutomaticTapeCreationRule
parseJSON =
    String
-> (Object -> Parser AutomaticTapeCreationRule)
-> Value
-> Parser AutomaticTapeCreationRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutomaticTapeCreationRule"
      ( \Object
x ->
          Maybe Bool
-> Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule
AutomaticTapeCreationRule'
            (Maybe Bool
 -> Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule)
-> Parser (Maybe Bool)
-> Parser
     (Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule)
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
"Worm")
            Parser
  (Text -> Text -> Integer -> Natural -> AutomaticTapeCreationRule)
-> Parser Text
-> Parser (Text -> Integer -> Natural -> AutomaticTapeCreationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TapeBarcodePrefix")
            Parser (Text -> Integer -> Natural -> AutomaticTapeCreationRule)
-> Parser Text
-> Parser (Integer -> Natural -> AutomaticTapeCreationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PoolId")
            Parser (Integer -> Natural -> AutomaticTapeCreationRule)
-> Parser Integer -> Parser (Natural -> AutomaticTapeCreationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TapeSizeInBytes")
            Parser (Natural -> AutomaticTapeCreationRule)
-> Parser Natural -> Parser AutomaticTapeCreationRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MinimumNumTapes")
      )

instance Prelude.Hashable AutomaticTapeCreationRule

instance Prelude.NFData AutomaticTapeCreationRule

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Worm" 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
worm,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TapeBarcodePrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tapeBarcodePrefix),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
poolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TapeSizeInBytes" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Integer
tapeSizeInBytes),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MinimumNumTapes" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
minimumNumTapes)
          ]
      )