{-# 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.Glue.Types.RecrawlPolicy
-- 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.Glue.Types.RecrawlPolicy where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.RecrawlBehavior
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | When crawling an Amazon S3 data source after the first crawl is
-- complete, specifies whether to crawl the entire dataset again or to
-- crawl only folders that were added since the last crawler run. For more
-- information, see
-- <https://docs.aws.amazon.com/glue/latest/dg/incremental-crawls.html Incremental Crawls in Glue>
-- in the developer guide.
--
-- /See:/ 'newRecrawlPolicy' smart constructor.
data RecrawlPolicy = RecrawlPolicy'
  { -- | Specifies whether to crawl the entire dataset again or to crawl only
    -- folders that were added since the last crawler run.
    --
    -- A value of @CRAWL_EVERYTHING@ specifies crawling the entire dataset
    -- again.
    --
    -- A value of @CRAWL_NEW_FOLDERS_ONLY@ specifies crawling only folders that
    -- were added since the last crawler run.
    --
    -- A value of @CRAWL_EVENT_MODE@ specifies crawling only the changes
    -- identified by Amazon S3 events.
    RecrawlPolicy -> Maybe RecrawlBehavior
recrawlBehavior :: Prelude.Maybe RecrawlBehavior
  }
  deriving (RecrawlPolicy -> RecrawlPolicy -> Bool
(RecrawlPolicy -> RecrawlPolicy -> Bool)
-> (RecrawlPolicy -> RecrawlPolicy -> Bool) -> Eq RecrawlPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecrawlPolicy -> RecrawlPolicy -> Bool
$c/= :: RecrawlPolicy -> RecrawlPolicy -> Bool
== :: RecrawlPolicy -> RecrawlPolicy -> Bool
$c== :: RecrawlPolicy -> RecrawlPolicy -> Bool
Prelude.Eq, ReadPrec [RecrawlPolicy]
ReadPrec RecrawlPolicy
Int -> ReadS RecrawlPolicy
ReadS [RecrawlPolicy]
(Int -> ReadS RecrawlPolicy)
-> ReadS [RecrawlPolicy]
-> ReadPrec RecrawlPolicy
-> ReadPrec [RecrawlPolicy]
-> Read RecrawlPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecrawlPolicy]
$creadListPrec :: ReadPrec [RecrawlPolicy]
readPrec :: ReadPrec RecrawlPolicy
$creadPrec :: ReadPrec RecrawlPolicy
readList :: ReadS [RecrawlPolicy]
$creadList :: ReadS [RecrawlPolicy]
readsPrec :: Int -> ReadS RecrawlPolicy
$creadsPrec :: Int -> ReadS RecrawlPolicy
Prelude.Read, Int -> RecrawlPolicy -> ShowS
[RecrawlPolicy] -> ShowS
RecrawlPolicy -> String
(Int -> RecrawlPolicy -> ShowS)
-> (RecrawlPolicy -> String)
-> ([RecrawlPolicy] -> ShowS)
-> Show RecrawlPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecrawlPolicy] -> ShowS
$cshowList :: [RecrawlPolicy] -> ShowS
show :: RecrawlPolicy -> String
$cshow :: RecrawlPolicy -> String
showsPrec :: Int -> RecrawlPolicy -> ShowS
$cshowsPrec :: Int -> RecrawlPolicy -> ShowS
Prelude.Show, (forall x. RecrawlPolicy -> Rep RecrawlPolicy x)
-> (forall x. Rep RecrawlPolicy x -> RecrawlPolicy)
-> Generic RecrawlPolicy
forall x. Rep RecrawlPolicy x -> RecrawlPolicy
forall x. RecrawlPolicy -> Rep RecrawlPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecrawlPolicy x -> RecrawlPolicy
$cfrom :: forall x. RecrawlPolicy -> Rep RecrawlPolicy x
Prelude.Generic)

-- |
-- Create a value of 'RecrawlPolicy' 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:
--
-- 'recrawlBehavior', 'recrawlPolicy_recrawlBehavior' - Specifies whether to crawl the entire dataset again or to crawl only
-- folders that were added since the last crawler run.
--
-- A value of @CRAWL_EVERYTHING@ specifies crawling the entire dataset
-- again.
--
-- A value of @CRAWL_NEW_FOLDERS_ONLY@ specifies crawling only folders that
-- were added since the last crawler run.
--
-- A value of @CRAWL_EVENT_MODE@ specifies crawling only the changes
-- identified by Amazon S3 events.
newRecrawlPolicy ::
  RecrawlPolicy
newRecrawlPolicy :: RecrawlPolicy
newRecrawlPolicy =
  RecrawlPolicy' :: Maybe RecrawlBehavior -> RecrawlPolicy
RecrawlPolicy' {$sel:recrawlBehavior:RecrawlPolicy' :: Maybe RecrawlBehavior
recrawlBehavior = Maybe RecrawlBehavior
forall a. Maybe a
Prelude.Nothing}

-- | Specifies whether to crawl the entire dataset again or to crawl only
-- folders that were added since the last crawler run.
--
-- A value of @CRAWL_EVERYTHING@ specifies crawling the entire dataset
-- again.
--
-- A value of @CRAWL_NEW_FOLDERS_ONLY@ specifies crawling only folders that
-- were added since the last crawler run.
--
-- A value of @CRAWL_EVENT_MODE@ specifies crawling only the changes
-- identified by Amazon S3 events.
recrawlPolicy_recrawlBehavior :: Lens.Lens' RecrawlPolicy (Prelude.Maybe RecrawlBehavior)
recrawlPolicy_recrawlBehavior :: (Maybe RecrawlBehavior -> f (Maybe RecrawlBehavior))
-> RecrawlPolicy -> f RecrawlPolicy
recrawlPolicy_recrawlBehavior = (RecrawlPolicy -> Maybe RecrawlBehavior)
-> (RecrawlPolicy -> Maybe RecrawlBehavior -> RecrawlPolicy)
-> Lens
     RecrawlPolicy
     RecrawlPolicy
     (Maybe RecrawlBehavior)
     (Maybe RecrawlBehavior)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecrawlPolicy' {Maybe RecrawlBehavior
recrawlBehavior :: Maybe RecrawlBehavior
$sel:recrawlBehavior:RecrawlPolicy' :: RecrawlPolicy -> Maybe RecrawlBehavior
recrawlBehavior} -> Maybe RecrawlBehavior
recrawlBehavior) (\s :: RecrawlPolicy
s@RecrawlPolicy' {} Maybe RecrawlBehavior
a -> RecrawlPolicy
s {$sel:recrawlBehavior:RecrawlPolicy' :: Maybe RecrawlBehavior
recrawlBehavior = Maybe RecrawlBehavior
a} :: RecrawlPolicy)

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

instance Prelude.Hashable RecrawlPolicy

instance Prelude.NFData RecrawlPolicy

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