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

-- | Describes the data repository association\'s automatic import policy.
-- The AutoImportPolicy defines how Amazon FSx keeps your file metadata and
-- directory listings up to date by importing changes to your Amazon FSx
-- for Lustre file system as you modify objects in a linked S3 bucket.
--
-- The @AutoImportPolicy@ is supported only for Amazon FSx for Lustre file
-- systems with the @Persistent_2@ deployment type.
--
-- /See:/ 'newAutoImportPolicy' smart constructor.
data AutoImportPolicy = AutoImportPolicy'
  { -- | The @AutoImportPolicy@ can have the following event values:
    --
    -- -   @NEW@ - Amazon FSx automatically imports metadata of files added to
    --     the linked S3 bucket that do not currently exist in the FSx file
    --     system.
    --
    -- -   @CHANGED@ - Amazon FSx automatically updates file metadata and
    --     invalidates existing file content on the file system as files change
    --     in the data repository.
    --
    -- -   @DELETED@ - Amazon FSx automatically deletes files on the file
    --     system as corresponding files are deleted in the data repository.
    --
    -- You can define any combination of event types for your
    -- @AutoImportPolicy@.
    AutoImportPolicy -> Maybe [EventType]
events :: Prelude.Maybe [EventType]
  }
  deriving (AutoImportPolicy -> AutoImportPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoImportPolicy -> AutoImportPolicy -> Bool
$c/= :: AutoImportPolicy -> AutoImportPolicy -> Bool
== :: AutoImportPolicy -> AutoImportPolicy -> Bool
$c== :: AutoImportPolicy -> AutoImportPolicy -> Bool
Prelude.Eq, ReadPrec [AutoImportPolicy]
ReadPrec AutoImportPolicy
Int -> ReadS AutoImportPolicy
ReadS [AutoImportPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoImportPolicy]
$creadListPrec :: ReadPrec [AutoImportPolicy]
readPrec :: ReadPrec AutoImportPolicy
$creadPrec :: ReadPrec AutoImportPolicy
readList :: ReadS [AutoImportPolicy]
$creadList :: ReadS [AutoImportPolicy]
readsPrec :: Int -> ReadS AutoImportPolicy
$creadsPrec :: Int -> ReadS AutoImportPolicy
Prelude.Read, Int -> AutoImportPolicy -> ShowS
[AutoImportPolicy] -> ShowS
AutoImportPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoImportPolicy] -> ShowS
$cshowList :: [AutoImportPolicy] -> ShowS
show :: AutoImportPolicy -> String
$cshow :: AutoImportPolicy -> String
showsPrec :: Int -> AutoImportPolicy -> ShowS
$cshowsPrec :: Int -> AutoImportPolicy -> ShowS
Prelude.Show, forall x. Rep AutoImportPolicy x -> AutoImportPolicy
forall x. AutoImportPolicy -> Rep AutoImportPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoImportPolicy x -> AutoImportPolicy
$cfrom :: forall x. AutoImportPolicy -> Rep AutoImportPolicy x
Prelude.Generic)

-- |
-- Create a value of 'AutoImportPolicy' 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:
--
-- 'events', 'autoImportPolicy_events' - The @AutoImportPolicy@ can have the following event values:
--
-- -   @NEW@ - Amazon FSx automatically imports metadata of files added to
--     the linked S3 bucket that do not currently exist in the FSx file
--     system.
--
-- -   @CHANGED@ - Amazon FSx automatically updates file metadata and
--     invalidates existing file content on the file system as files change
--     in the data repository.
--
-- -   @DELETED@ - Amazon FSx automatically deletes files on the file
--     system as corresponding files are deleted in the data repository.
--
-- You can define any combination of event types for your
-- @AutoImportPolicy@.
newAutoImportPolicy ::
  AutoImportPolicy
newAutoImportPolicy :: AutoImportPolicy
newAutoImportPolicy =
  AutoImportPolicy' {$sel:events:AutoImportPolicy' :: Maybe [EventType]
events = forall a. Maybe a
Prelude.Nothing}

-- | The @AutoImportPolicy@ can have the following event values:
--
-- -   @NEW@ - Amazon FSx automatically imports metadata of files added to
--     the linked S3 bucket that do not currently exist in the FSx file
--     system.
--
-- -   @CHANGED@ - Amazon FSx automatically updates file metadata and
--     invalidates existing file content on the file system as files change
--     in the data repository.
--
-- -   @DELETED@ - Amazon FSx automatically deletes files on the file
--     system as corresponding files are deleted in the data repository.
--
-- You can define any combination of event types for your
-- @AutoImportPolicy@.
autoImportPolicy_events :: Lens.Lens' AutoImportPolicy (Prelude.Maybe [EventType])
autoImportPolicy_events :: Lens' AutoImportPolicy (Maybe [EventType])
autoImportPolicy_events = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoImportPolicy' {Maybe [EventType]
events :: Maybe [EventType]
$sel:events:AutoImportPolicy' :: AutoImportPolicy -> Maybe [EventType]
events} -> Maybe [EventType]
events) (\s :: AutoImportPolicy
s@AutoImportPolicy' {} Maybe [EventType]
a -> AutoImportPolicy
s {$sel:events:AutoImportPolicy' :: Maybe [EventType]
events = Maybe [EventType]
a} :: AutoImportPolicy) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AutoImportPolicy where
  parseJSON :: Value -> Parser AutoImportPolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoImportPolicy"
      ( \Object
x ->
          Maybe [EventType] -> AutoImportPolicy
AutoImportPolicy'
            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
"Events" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AutoImportPolicy where
  hashWithSalt :: Int -> AutoImportPolicy -> Int
hashWithSalt Int
_salt AutoImportPolicy' {Maybe [EventType]
events :: Maybe [EventType]
$sel:events:AutoImportPolicy' :: AutoImportPolicy -> Maybe [EventType]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EventType]
events

instance Prelude.NFData AutoImportPolicy where
  rnf :: AutoImportPolicy -> ()
rnf AutoImportPolicy' {Maybe [EventType]
events :: Maybe [EventType]
$sel:events:AutoImportPolicy' :: AutoImportPolicy -> Maybe [EventType]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [EventType]
events

instance Data.ToJSON AutoImportPolicy where
  toJSON :: AutoImportPolicy -> Value
toJSON AutoImportPolicy' {Maybe [EventType]
events :: Maybe [EventType]
$sel:events:AutoImportPolicy' :: AutoImportPolicy -> Maybe [EventType]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Events" 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 [EventType]
events]
      )