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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | 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,
    -- | 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
  }
  deriving (DynamoDBTarget -> DynamoDBTarget -> Bool
(DynamoDBTarget -> DynamoDBTarget -> Bool)
-> (DynamoDBTarget -> DynamoDBTarget -> Bool) -> Eq DynamoDBTarget
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]
(Int -> ReadS DynamoDBTarget)
-> ReadS [DynamoDBTarget]
-> ReadPrec DynamoDBTarget
-> ReadPrec [DynamoDBTarget]
-> Read 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
(Int -> DynamoDBTarget -> ShowS)
-> (DynamoDBTarget -> String)
-> ([DynamoDBTarget] -> ShowS)
-> Show DynamoDBTarget
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. DynamoDBTarget -> Rep DynamoDBTarget x)
-> (forall x. Rep DynamoDBTarget x -> DynamoDBTarget)
-> Generic DynamoDBTarget
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.
--
-- '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).
--
-- '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@.
newDynamoDBTarget ::
  DynamoDBTarget
newDynamoDBTarget :: DynamoDBTarget
newDynamoDBTarget =
  DynamoDBTarget' :: Maybe Text -> Maybe Double -> Maybe Bool -> DynamoDBTarget
DynamoDBTarget'
    { $sel:path:DynamoDBTarget' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scanRate:DynamoDBTarget' :: Maybe Double
scanRate = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:scanAll:DynamoDBTarget' :: Maybe Bool
scanAll = Maybe Bool
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 :: (Maybe Text -> f (Maybe Text))
-> DynamoDBTarget -> f DynamoDBTarget
dynamoDBTarget_path = (DynamoDBTarget -> Maybe Text)
-> (DynamoDBTarget -> Maybe Text -> DynamoDBTarget)
-> Lens DynamoDBTarget DynamoDBTarget (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Double -> f (Maybe Double))
-> DynamoDBTarget -> f DynamoDBTarget
dynamoDBTarget_scanRate = (DynamoDBTarget -> Maybe Double)
-> (DynamoDBTarget -> Maybe Double -> DynamoDBTarget)
-> Lens DynamoDBTarget DynamoDBTarget (Maybe Double) (Maybe Double)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> DynamoDBTarget -> f DynamoDBTarget
dynamoDBTarget_scanAll = (DynamoDBTarget -> Maybe Bool)
-> (DynamoDBTarget -> Maybe Bool -> DynamoDBTarget)
-> Lens DynamoDBTarget DynamoDBTarget (Maybe Bool) (Maybe Bool)
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)

instance Core.FromJSON DynamoDBTarget where
  parseJSON :: Value -> Parser DynamoDBTarget
parseJSON =
    String
-> (Object -> Parser DynamoDBTarget)
-> Value
-> Parser DynamoDBTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DynamoDBTarget"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> Maybe Bool -> DynamoDBTarget
DynamoDBTarget'
            (Maybe Text -> Maybe Double -> Maybe Bool -> DynamoDBTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe Bool -> DynamoDBTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Path")
            Parser (Maybe Double -> Maybe Bool -> DynamoDBTarget)
-> Parser (Maybe Double) -> Parser (Maybe Bool -> DynamoDBTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"scanRate")
            Parser (Maybe Bool -> DynamoDBTarget)
-> Parser (Maybe Bool) -> Parser DynamoDBTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"scanAll")
      )

instance Prelude.Hashable DynamoDBTarget

instance Prelude.NFData DynamoDBTarget

instance Core.ToJSON DynamoDBTarget where
  toJSON :: DynamoDBTarget -> Value
toJSON DynamoDBTarget' {Maybe Bool
Maybe Double
Maybe Text
scanAll :: Maybe Bool
scanRate :: Maybe Double
path :: Maybe Text
$sel:scanAll:DynamoDBTarget' :: DynamoDBTarget -> Maybe Bool
$sel:scanRate:DynamoDBTarget' :: DynamoDBTarget -> Maybe Double
$sel:path:DynamoDBTarget' :: DynamoDBTarget -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
path,
            (Text
"scanRate" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
scanRate,
            (Text
"scanAll" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
scanAll
          ]
      )