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

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

-- | Specifies an Amazon DynamoDB table to crawl.
--
-- /See:/ 'newDynamoDBTarget' smart constructor.
data DynamoDBTarget = DynamoDBTarget'
  { -- | The name of the DynamoDB table to crawl.
    DynamoDBTarget -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether to scan all the records, or to sample rows from the
    -- table. Scanning all the records can take a long time when the table is
    -- not a high throughput table.
    --
    -- A value of @true@ means to scan all records, while a value of @false@
    -- means to sample the records. If no value is specified, the value
    -- defaults to @true@.
    DynamoDBTarget -> Maybe Bool
scanAll :: Prelude.Maybe Prelude.Bool,
    -- | The percentage of the configured read capacity units to use by the Glue
    -- crawler. Read capacity units is a term defined by DynamoDB, and is a
    -- numeric value that acts as rate limiter for the number of reads that can
    -- be performed on that table per second.
    --
    -- The valid values are null or a value between 0.1 to 1.5. A null value is
    -- used when user does not provide a value, and defaults to 0.5 of the
    -- configured Read Capacity Unit (for provisioned tables), or 0.25 of the
    -- max configured Read Capacity Unit (for tables using on-demand mode).
    DynamoDBTarget -> Maybe Double
scanRate :: Prelude.Maybe Prelude.Double
  }
  deriving (DynamoDBTarget -> DynamoDBTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DynamoDBTarget -> DynamoDBTarget -> Bool
$c/= :: DynamoDBTarget -> DynamoDBTarget -> Bool
== :: DynamoDBTarget -> DynamoDBTarget -> Bool
$c== :: DynamoDBTarget -> DynamoDBTarget -> Bool
Prelude.Eq, ReadPrec [DynamoDBTarget]
ReadPrec DynamoDBTarget
Int -> ReadS DynamoDBTarget
ReadS [DynamoDBTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DynamoDBTarget]
$creadListPrec :: ReadPrec [DynamoDBTarget]
readPrec :: ReadPrec DynamoDBTarget
$creadPrec :: ReadPrec DynamoDBTarget
readList :: ReadS [DynamoDBTarget]
$creadList :: ReadS [DynamoDBTarget]
readsPrec :: Int -> ReadS DynamoDBTarget
$creadsPrec :: Int -> ReadS DynamoDBTarget
Prelude.Read, Int -> DynamoDBTarget -> ShowS
[DynamoDBTarget] -> ShowS
DynamoDBTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DynamoDBTarget] -> ShowS
$cshowList :: [DynamoDBTarget] -> ShowS
show :: DynamoDBTarget -> String
$cshow :: DynamoDBTarget -> String
showsPrec :: Int -> DynamoDBTarget -> ShowS
$cshowsPrec :: Int -> DynamoDBTarget -> ShowS
Prelude.Show, forall x. Rep DynamoDBTarget x -> DynamoDBTarget
forall x. DynamoDBTarget -> Rep DynamoDBTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DynamoDBTarget x -> DynamoDBTarget
$cfrom :: forall x. DynamoDBTarget -> Rep DynamoDBTarget x
Prelude.Generic)

-- |
-- Create a value of 'DynamoDBTarget' 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:
--
-- 'path', 'dynamoDBTarget_path' - The name of the DynamoDB table to crawl.
--
-- 'scanAll', 'dynamoDBTarget_scanAll' - Indicates whether to scan all the records, or to sample rows from the
-- table. Scanning all the records can take a long time when the table is
-- not a high throughput table.
--
-- A value of @true@ means to scan all records, while a value of @false@
-- means to sample the records. If no value is specified, the value
-- defaults to @true@.
--
-- 'scanRate', 'dynamoDBTarget_scanRate' - The percentage of the configured read capacity units to use by the Glue
-- crawler. Read capacity units is a term defined by DynamoDB, and is a
-- numeric value that acts as rate limiter for the number of reads that can
-- be performed on that table per second.
--
-- The valid values are null or a value between 0.1 to 1.5. A null value is
-- used when user does not provide a value, and defaults to 0.5 of the
-- configured Read Capacity Unit (for provisioned tables), or 0.25 of the
-- max configured Read Capacity Unit (for tables using on-demand mode).
newDynamoDBTarget ::
  DynamoDBTarget
newDynamoDBTarget :: DynamoDBTarget
newDynamoDBTarget =
  DynamoDBTarget'
    { $sel:path:DynamoDBTarget' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:scanAll:DynamoDBTarget' :: Maybe Bool
scanAll = forall a. Maybe a
Prelude.Nothing,
      $sel:scanRate:DynamoDBTarget' :: Maybe Double
scanRate = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the DynamoDB table to crawl.
dynamoDBTarget_path :: Lens.Lens' DynamoDBTarget (Prelude.Maybe Prelude.Text)
dynamoDBTarget_path :: Lens' DynamoDBTarget (Maybe Text)
dynamoDBTarget_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBTarget' {Maybe Text
path :: Maybe Text
$sel:path:DynamoDBTarget' :: DynamoDBTarget -> Maybe Text
path} -> Maybe Text
path) (\s :: DynamoDBTarget
s@DynamoDBTarget' {} Maybe Text
a -> DynamoDBTarget
s {$sel:path:DynamoDBTarget' :: Maybe Text
path = Maybe Text
a} :: DynamoDBTarget)

-- | Indicates whether to scan all the records, or to sample rows from the
-- table. Scanning all the records can take a long time when the table is
-- not a high throughput table.
--
-- A value of @true@ means to scan all records, while a value of @false@
-- means to sample the records. If no value is specified, the value
-- defaults to @true@.
dynamoDBTarget_scanAll :: Lens.Lens' DynamoDBTarget (Prelude.Maybe Prelude.Bool)
dynamoDBTarget_scanAll :: Lens' DynamoDBTarget (Maybe Bool)
dynamoDBTarget_scanAll = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBTarget' {Maybe Bool
scanAll :: Maybe Bool
$sel:scanAll:DynamoDBTarget' :: DynamoDBTarget -> Maybe Bool
scanAll} -> Maybe Bool
scanAll) (\s :: DynamoDBTarget
s@DynamoDBTarget' {} Maybe Bool
a -> DynamoDBTarget
s {$sel:scanAll:DynamoDBTarget' :: Maybe Bool
scanAll = Maybe Bool
a} :: DynamoDBTarget)

-- | The percentage of the configured read capacity units to use by the Glue
-- crawler. Read capacity units is a term defined by DynamoDB, and is a
-- numeric value that acts as rate limiter for the number of reads that can
-- be performed on that table per second.
--
-- The valid values are null or a value between 0.1 to 1.5. A null value is
-- used when user does not provide a value, and defaults to 0.5 of the
-- configured Read Capacity Unit (for provisioned tables), or 0.25 of the
-- max configured Read Capacity Unit (for tables using on-demand mode).
dynamoDBTarget_scanRate :: Lens.Lens' DynamoDBTarget (Prelude.Maybe Prelude.Double)
dynamoDBTarget_scanRate :: Lens' DynamoDBTarget (Maybe Double)
dynamoDBTarget_scanRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DynamoDBTarget' {Maybe Double
scanRate :: Maybe Double
$sel:scanRate:DynamoDBTarget' :: DynamoDBTarget -> Maybe Double
scanRate} -> Maybe Double
scanRate) (\s :: DynamoDBTarget
s@DynamoDBTarget' {} Maybe Double
a -> DynamoDBTarget
s {$sel:scanRate:DynamoDBTarget' :: Maybe Double
scanRate = Maybe Double
a} :: DynamoDBTarget)

instance Data.FromJSON DynamoDBTarget where
  parseJSON :: Value -> Parser DynamoDBTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DynamoDBTarget"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> Maybe Double -> DynamoDBTarget
DynamoDBTarget'
            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
"Path")
            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
"scanAll")
            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
"scanRate")
      )

instance Prelude.Hashable DynamoDBTarget where
  hashWithSalt :: Int -> DynamoDBTarget -> Int
hashWithSalt Int
_salt DynamoDBTarget' {Maybe Bool
Maybe Double
Maybe Text
scanRate :: Maybe Double
scanAll :: Maybe Bool
path :: Maybe Text
$sel:scanRate:DynamoDBTarget' :: DynamoDBTarget -> Maybe Double
$sel:scanAll:DynamoDBTarget' :: DynamoDBTarget -> Maybe Bool
$sel:path:DynamoDBTarget' :: DynamoDBTarget -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
scanAll
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
scanRate

instance Prelude.NFData DynamoDBTarget where
  rnf :: DynamoDBTarget -> ()
rnf DynamoDBTarget' {Maybe Bool
Maybe Double
Maybe Text
scanRate :: Maybe Double
scanAll :: Maybe Bool
path :: Maybe Text
$sel:scanRate:DynamoDBTarget' :: DynamoDBTarget -> Maybe Double
$sel:scanAll:DynamoDBTarget' :: DynamoDBTarget -> Maybe Bool
$sel:path:DynamoDBTarget' :: DynamoDBTarget -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
scanAll
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
scanRate

instance Data.ToJSON DynamoDBTarget where
  toJSON :: DynamoDBTarget -> Value
toJSON DynamoDBTarget' {Maybe Bool
Maybe Double
Maybe Text
scanRate :: Maybe Double
scanAll :: Maybe Bool
path :: Maybe Text
$sel:scanRate:DynamoDBTarget' :: DynamoDBTarget -> Maybe Double
$sel:scanAll:DynamoDBTarget' :: DynamoDBTarget -> Maybe Bool
$sel:path:DynamoDBTarget' :: DynamoDBTarget -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Path" 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
path,
            (Key
"scanAll" 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
scanAll,
            (Key
"scanRate" 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 Double
scanRate
          ]
      )