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

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

-- | The refresh cache information for the file share or FSx file systems.
--
-- /See:/ 'newCacheAttributes' smart constructor.
data CacheAttributes = CacheAttributes'
  { -- | Refreshes a file share\'s cache by using Time To Live (TTL). TTL is the
    -- length of time since the last refresh after which access to the
    -- directory would cause the file gateway to first refresh that
    -- directory\'s contents from the Amazon S3 bucket or Amazon FSx file
    -- system. The TTL duration is in seconds.
    --
    -- Valid Values:0, 300 to 2,592,000 seconds (5 minutes to 30 days)
    CacheAttributes -> Maybe Int
cacheStaleTimeoutInSeconds :: Prelude.Maybe Prelude.Int
  }
  deriving (CacheAttributes -> CacheAttributes -> Bool
(CacheAttributes -> CacheAttributes -> Bool)
-> (CacheAttributes -> CacheAttributes -> Bool)
-> Eq CacheAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CacheAttributes -> CacheAttributes -> Bool
$c/= :: CacheAttributes -> CacheAttributes -> Bool
== :: CacheAttributes -> CacheAttributes -> Bool
$c== :: CacheAttributes -> CacheAttributes -> Bool
Prelude.Eq, ReadPrec [CacheAttributes]
ReadPrec CacheAttributes
Int -> ReadS CacheAttributes
ReadS [CacheAttributes]
(Int -> ReadS CacheAttributes)
-> ReadS [CacheAttributes]
-> ReadPrec CacheAttributes
-> ReadPrec [CacheAttributes]
-> Read CacheAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CacheAttributes]
$creadListPrec :: ReadPrec [CacheAttributes]
readPrec :: ReadPrec CacheAttributes
$creadPrec :: ReadPrec CacheAttributes
readList :: ReadS [CacheAttributes]
$creadList :: ReadS [CacheAttributes]
readsPrec :: Int -> ReadS CacheAttributes
$creadsPrec :: Int -> ReadS CacheAttributes
Prelude.Read, Int -> CacheAttributes -> ShowS
[CacheAttributes] -> ShowS
CacheAttributes -> String
(Int -> CacheAttributes -> ShowS)
-> (CacheAttributes -> String)
-> ([CacheAttributes] -> ShowS)
-> Show CacheAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CacheAttributes] -> ShowS
$cshowList :: [CacheAttributes] -> ShowS
show :: CacheAttributes -> String
$cshow :: CacheAttributes -> String
showsPrec :: Int -> CacheAttributes -> ShowS
$cshowsPrec :: Int -> CacheAttributes -> ShowS
Prelude.Show, (forall x. CacheAttributes -> Rep CacheAttributes x)
-> (forall x. Rep CacheAttributes x -> CacheAttributes)
-> Generic CacheAttributes
forall x. Rep CacheAttributes x -> CacheAttributes
forall x. CacheAttributes -> Rep CacheAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CacheAttributes x -> CacheAttributes
$cfrom :: forall x. CacheAttributes -> Rep CacheAttributes x
Prelude.Generic)

-- |
-- Create a value of 'CacheAttributes' 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:
--
-- 'cacheStaleTimeoutInSeconds', 'cacheAttributes_cacheStaleTimeoutInSeconds' - Refreshes a file share\'s cache by using Time To Live (TTL). TTL is the
-- length of time since the last refresh after which access to the
-- directory would cause the file gateway to first refresh that
-- directory\'s contents from the Amazon S3 bucket or Amazon FSx file
-- system. The TTL duration is in seconds.
--
-- Valid Values:0, 300 to 2,592,000 seconds (5 minutes to 30 days)
newCacheAttributes ::
  CacheAttributes
newCacheAttributes :: CacheAttributes
newCacheAttributes =
  CacheAttributes' :: Maybe Int -> CacheAttributes
CacheAttributes'
    { $sel:cacheStaleTimeoutInSeconds:CacheAttributes' :: Maybe Int
cacheStaleTimeoutInSeconds =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Refreshes a file share\'s cache by using Time To Live (TTL). TTL is the
-- length of time since the last refresh after which access to the
-- directory would cause the file gateway to first refresh that
-- directory\'s contents from the Amazon S3 bucket or Amazon FSx file
-- system. The TTL duration is in seconds.
--
-- Valid Values:0, 300 to 2,592,000 seconds (5 minutes to 30 days)
cacheAttributes_cacheStaleTimeoutInSeconds :: Lens.Lens' CacheAttributes (Prelude.Maybe Prelude.Int)
cacheAttributes_cacheStaleTimeoutInSeconds :: (Maybe Int -> f (Maybe Int))
-> CacheAttributes -> f CacheAttributes
cacheAttributes_cacheStaleTimeoutInSeconds = (CacheAttributes -> Maybe Int)
-> (CacheAttributes -> Maybe Int -> CacheAttributes)
-> Lens CacheAttributes CacheAttributes (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CacheAttributes' {Maybe Int
cacheStaleTimeoutInSeconds :: Maybe Int
$sel:cacheStaleTimeoutInSeconds:CacheAttributes' :: CacheAttributes -> Maybe Int
cacheStaleTimeoutInSeconds} -> Maybe Int
cacheStaleTimeoutInSeconds) (\s :: CacheAttributes
s@CacheAttributes' {} Maybe Int
a -> CacheAttributes
s {$sel:cacheStaleTimeoutInSeconds:CacheAttributes' :: Maybe Int
cacheStaleTimeoutInSeconds = Maybe Int
a} :: CacheAttributes)

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

instance Prelude.Hashable CacheAttributes

instance Prelude.NFData CacheAttributes

instance Core.ToJSON CacheAttributes where
  toJSON :: CacheAttributes -> Value
toJSON CacheAttributes' {Maybe Int
cacheStaleTimeoutInSeconds :: Maybe Int
$sel:cacheStaleTimeoutInSeconds:CacheAttributes' :: CacheAttributes -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CacheStaleTimeoutInSeconds" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
cacheStaleTimeoutInSeconds
          ]
      )