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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.UpdateCatalogBehavior
import qualified Amazonka.Prelude as Prelude

-- | A policy that specifies update behavior for the crawler.
--
-- /See:/ 'newDirectSchemaChangePolicy' smart constructor.
data DirectSchemaChangePolicy = DirectSchemaChangePolicy'
  { -- | Specifies the database that the schema change policy applies to.
    DirectSchemaChangePolicy -> Maybe Text
database :: Prelude.Maybe Prelude.Text,
    -- | Whether to use the specified update behavior when the crawler finds a
    -- changed schema.
    DirectSchemaChangePolicy -> Maybe Bool
enableUpdateCatalog :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the table in the database that the schema change policy
    -- applies to.
    DirectSchemaChangePolicy -> Maybe Text
table :: Prelude.Maybe Prelude.Text,
    -- | The update behavior when the crawler finds a changed schema.
    DirectSchemaChangePolicy -> Maybe UpdateCatalogBehavior
updateBehavior :: Prelude.Maybe UpdateCatalogBehavior
  }
  deriving (DirectSchemaChangePolicy -> DirectSchemaChangePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectSchemaChangePolicy -> DirectSchemaChangePolicy -> Bool
$c/= :: DirectSchemaChangePolicy -> DirectSchemaChangePolicy -> Bool
== :: DirectSchemaChangePolicy -> DirectSchemaChangePolicy -> Bool
$c== :: DirectSchemaChangePolicy -> DirectSchemaChangePolicy -> Bool
Prelude.Eq, ReadPrec [DirectSchemaChangePolicy]
ReadPrec DirectSchemaChangePolicy
Int -> ReadS DirectSchemaChangePolicy
ReadS [DirectSchemaChangePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DirectSchemaChangePolicy]
$creadListPrec :: ReadPrec [DirectSchemaChangePolicy]
readPrec :: ReadPrec DirectSchemaChangePolicy
$creadPrec :: ReadPrec DirectSchemaChangePolicy
readList :: ReadS [DirectSchemaChangePolicy]
$creadList :: ReadS [DirectSchemaChangePolicy]
readsPrec :: Int -> ReadS DirectSchemaChangePolicy
$creadsPrec :: Int -> ReadS DirectSchemaChangePolicy
Prelude.Read, Int -> DirectSchemaChangePolicy -> ShowS
[DirectSchemaChangePolicy] -> ShowS
DirectSchemaChangePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DirectSchemaChangePolicy] -> ShowS
$cshowList :: [DirectSchemaChangePolicy] -> ShowS
show :: DirectSchemaChangePolicy -> String
$cshow :: DirectSchemaChangePolicy -> String
showsPrec :: Int -> DirectSchemaChangePolicy -> ShowS
$cshowsPrec :: Int -> DirectSchemaChangePolicy -> ShowS
Prelude.Show, forall x.
Rep DirectSchemaChangePolicy x -> DirectSchemaChangePolicy
forall x.
DirectSchemaChangePolicy -> Rep DirectSchemaChangePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DirectSchemaChangePolicy x -> DirectSchemaChangePolicy
$cfrom :: forall x.
DirectSchemaChangePolicy -> Rep DirectSchemaChangePolicy x
Prelude.Generic)

-- |
-- Create a value of 'DirectSchemaChangePolicy' 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:
--
-- 'database', 'directSchemaChangePolicy_database' - Specifies the database that the schema change policy applies to.
--
-- 'enableUpdateCatalog', 'directSchemaChangePolicy_enableUpdateCatalog' - Whether to use the specified update behavior when the crawler finds a
-- changed schema.
--
-- 'table', 'directSchemaChangePolicy_table' - Specifies the table in the database that the schema change policy
-- applies to.
--
-- 'updateBehavior', 'directSchemaChangePolicy_updateBehavior' - The update behavior when the crawler finds a changed schema.
newDirectSchemaChangePolicy ::
  DirectSchemaChangePolicy
newDirectSchemaChangePolicy :: DirectSchemaChangePolicy
newDirectSchemaChangePolicy =
  DirectSchemaChangePolicy'
    { $sel:database:DirectSchemaChangePolicy' :: Maybe Text
database =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: Maybe Bool
enableUpdateCatalog = forall a. Maybe a
Prelude.Nothing,
      $sel:table:DirectSchemaChangePolicy' :: Maybe Text
table = forall a. Maybe a
Prelude.Nothing,
      $sel:updateBehavior:DirectSchemaChangePolicy' :: Maybe UpdateCatalogBehavior
updateBehavior = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the database that the schema change policy applies to.
directSchemaChangePolicy_database :: Lens.Lens' DirectSchemaChangePolicy (Prelude.Maybe Prelude.Text)
directSchemaChangePolicy_database :: Lens' DirectSchemaChangePolicy (Maybe Text)
directSchemaChangePolicy_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectSchemaChangePolicy' {Maybe Text
database :: Maybe Text
$sel:database:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
database} -> Maybe Text
database) (\s :: DirectSchemaChangePolicy
s@DirectSchemaChangePolicy' {} Maybe Text
a -> DirectSchemaChangePolicy
s {$sel:database:DirectSchemaChangePolicy' :: Maybe Text
database = Maybe Text
a} :: DirectSchemaChangePolicy)

-- | Whether to use the specified update behavior when the crawler finds a
-- changed schema.
directSchemaChangePolicy_enableUpdateCatalog :: Lens.Lens' DirectSchemaChangePolicy (Prelude.Maybe Prelude.Bool)
directSchemaChangePolicy_enableUpdateCatalog :: Lens' DirectSchemaChangePolicy (Maybe Bool)
directSchemaChangePolicy_enableUpdateCatalog = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectSchemaChangePolicy' {Maybe Bool
enableUpdateCatalog :: Maybe Bool
$sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Bool
enableUpdateCatalog} -> Maybe Bool
enableUpdateCatalog) (\s :: DirectSchemaChangePolicy
s@DirectSchemaChangePolicy' {} Maybe Bool
a -> DirectSchemaChangePolicy
s {$sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: Maybe Bool
enableUpdateCatalog = Maybe Bool
a} :: DirectSchemaChangePolicy)

-- | Specifies the table in the database that the schema change policy
-- applies to.
directSchemaChangePolicy_table :: Lens.Lens' DirectSchemaChangePolicy (Prelude.Maybe Prelude.Text)
directSchemaChangePolicy_table :: Lens' DirectSchemaChangePolicy (Maybe Text)
directSchemaChangePolicy_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectSchemaChangePolicy' {Maybe Text
table :: Maybe Text
$sel:table:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
table} -> Maybe Text
table) (\s :: DirectSchemaChangePolicy
s@DirectSchemaChangePolicy' {} Maybe Text
a -> DirectSchemaChangePolicy
s {$sel:table:DirectSchemaChangePolicy' :: Maybe Text
table = Maybe Text
a} :: DirectSchemaChangePolicy)

-- | The update behavior when the crawler finds a changed schema.
directSchemaChangePolicy_updateBehavior :: Lens.Lens' DirectSchemaChangePolicy (Prelude.Maybe UpdateCatalogBehavior)
directSchemaChangePolicy_updateBehavior :: Lens' DirectSchemaChangePolicy (Maybe UpdateCatalogBehavior)
directSchemaChangePolicy_updateBehavior = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DirectSchemaChangePolicy' {Maybe UpdateCatalogBehavior
updateBehavior :: Maybe UpdateCatalogBehavior
$sel:updateBehavior:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe UpdateCatalogBehavior
updateBehavior} -> Maybe UpdateCatalogBehavior
updateBehavior) (\s :: DirectSchemaChangePolicy
s@DirectSchemaChangePolicy' {} Maybe UpdateCatalogBehavior
a -> DirectSchemaChangePolicy
s {$sel:updateBehavior:DirectSchemaChangePolicy' :: Maybe UpdateCatalogBehavior
updateBehavior = Maybe UpdateCatalogBehavior
a} :: DirectSchemaChangePolicy)

instance Data.FromJSON DirectSchemaChangePolicy where
  parseJSON :: Value -> Parser DirectSchemaChangePolicy
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DirectSchemaChangePolicy"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe UpdateCatalogBehavior
-> DirectSchemaChangePolicy
DirectSchemaChangePolicy'
            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
"Database")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EnableUpdateCatalog")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Table")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UpdateBehavior")
      )

instance Prelude.Hashable DirectSchemaChangePolicy where
  hashWithSalt :: Int -> DirectSchemaChangePolicy -> Int
hashWithSalt Int
_salt DirectSchemaChangePolicy' {Maybe Bool
Maybe Text
Maybe UpdateCatalogBehavior
updateBehavior :: Maybe UpdateCatalogBehavior
table :: Maybe Text
enableUpdateCatalog :: Maybe Bool
database :: Maybe Text
$sel:updateBehavior:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe UpdateCatalogBehavior
$sel:table:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
$sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Bool
$sel:database:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
database
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableUpdateCatalog
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
table
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateCatalogBehavior
updateBehavior

instance Prelude.NFData DirectSchemaChangePolicy where
  rnf :: DirectSchemaChangePolicy -> ()
rnf DirectSchemaChangePolicy' {Maybe Bool
Maybe Text
Maybe UpdateCatalogBehavior
updateBehavior :: Maybe UpdateCatalogBehavior
table :: Maybe Text
enableUpdateCatalog :: Maybe Bool
database :: Maybe Text
$sel:updateBehavior:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe UpdateCatalogBehavior
$sel:table:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
$sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Bool
$sel:database:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
database
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableUpdateCatalog
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
table
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateCatalogBehavior
updateBehavior

instance Data.ToJSON DirectSchemaChangePolicy where
  toJSON :: DirectSchemaChangePolicy -> Value
toJSON DirectSchemaChangePolicy' {Maybe Bool
Maybe Text
Maybe UpdateCatalogBehavior
updateBehavior :: Maybe UpdateCatalogBehavior
table :: Maybe Text
enableUpdateCatalog :: Maybe Bool
database :: Maybe Text
$sel:updateBehavior:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe UpdateCatalogBehavior
$sel:table:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
$sel:enableUpdateCatalog:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Bool
$sel:database:DirectSchemaChangePolicy' :: DirectSchemaChangePolicy -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Database" 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 Text
database,
            (Key
"EnableUpdateCatalog" 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
enableUpdateCatalog,
            (Key
"Table" 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 Text
table,
            (Key
"UpdateBehavior" 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 UpdateCatalogBehavior
updateBehavior
          ]
      )