{-# 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.MongoDBTarget
-- 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.MongoDBTarget 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 DocumentDB or MongoDB data store to crawl.
--
-- /See:/ 'newMongoDBTarget' smart constructor.
data MongoDBTarget = MongoDBTarget'
  { -- | The name of the connection to use to connect to the Amazon DocumentDB or
    -- MongoDB target.
    MongoDBTarget -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | The path of the Amazon DocumentDB or MongoDB target
    -- (database\/collection).
    MongoDBTarget -> 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@.
    MongoDBTarget -> Maybe Bool
scanAll :: Prelude.Maybe Prelude.Bool
  }
  deriving (MongoDBTarget -> MongoDBTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MongoDBTarget -> MongoDBTarget -> Bool
$c/= :: MongoDBTarget -> MongoDBTarget -> Bool
== :: MongoDBTarget -> MongoDBTarget -> Bool
$c== :: MongoDBTarget -> MongoDBTarget -> Bool
Prelude.Eq, ReadPrec [MongoDBTarget]
ReadPrec MongoDBTarget
Int -> ReadS MongoDBTarget
ReadS [MongoDBTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MongoDBTarget]
$creadListPrec :: ReadPrec [MongoDBTarget]
readPrec :: ReadPrec MongoDBTarget
$creadPrec :: ReadPrec MongoDBTarget
readList :: ReadS [MongoDBTarget]
$creadList :: ReadS [MongoDBTarget]
readsPrec :: Int -> ReadS MongoDBTarget
$creadsPrec :: Int -> ReadS MongoDBTarget
Prelude.Read, Int -> MongoDBTarget -> ShowS
[MongoDBTarget] -> ShowS
MongoDBTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MongoDBTarget] -> ShowS
$cshowList :: [MongoDBTarget] -> ShowS
show :: MongoDBTarget -> String
$cshow :: MongoDBTarget -> String
showsPrec :: Int -> MongoDBTarget -> ShowS
$cshowsPrec :: Int -> MongoDBTarget -> ShowS
Prelude.Show, forall x. Rep MongoDBTarget x -> MongoDBTarget
forall x. MongoDBTarget -> Rep MongoDBTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MongoDBTarget x -> MongoDBTarget
$cfrom :: forall x. MongoDBTarget -> Rep MongoDBTarget x
Prelude.Generic)

-- |
-- Create a value of 'MongoDBTarget' 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:
--
-- 'connectionName', 'mongoDBTarget_connectionName' - The name of the connection to use to connect to the Amazon DocumentDB or
-- MongoDB target.
--
-- 'path', 'mongoDBTarget_path' - The path of the Amazon DocumentDB or MongoDB target
-- (database\/collection).
--
-- 'scanAll', 'mongoDBTarget_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@.
newMongoDBTarget ::
  MongoDBTarget
newMongoDBTarget :: MongoDBTarget
newMongoDBTarget =
  MongoDBTarget'
    { $sel:connectionName:MongoDBTarget' :: Maybe Text
connectionName = forall a. Maybe a
Prelude.Nothing,
      $sel:path:MongoDBTarget' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:scanAll:MongoDBTarget' :: Maybe Bool
scanAll = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the connection to use to connect to the Amazon DocumentDB or
-- MongoDB target.
mongoDBTarget_connectionName :: Lens.Lens' MongoDBTarget (Prelude.Maybe Prelude.Text)
mongoDBTarget_connectionName :: Lens' MongoDBTarget (Maybe Text)
mongoDBTarget_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MongoDBTarget' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:MongoDBTarget' :: MongoDBTarget -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: MongoDBTarget
s@MongoDBTarget' {} Maybe Text
a -> MongoDBTarget
s {$sel:connectionName:MongoDBTarget' :: Maybe Text
connectionName = Maybe Text
a} :: MongoDBTarget)

-- | The path of the Amazon DocumentDB or MongoDB target
-- (database\/collection).
mongoDBTarget_path :: Lens.Lens' MongoDBTarget (Prelude.Maybe Prelude.Text)
mongoDBTarget_path :: Lens' MongoDBTarget (Maybe Text)
mongoDBTarget_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MongoDBTarget' {Maybe Text
path :: Maybe Text
$sel:path:MongoDBTarget' :: MongoDBTarget -> Maybe Text
path} -> Maybe Text
path) (\s :: MongoDBTarget
s@MongoDBTarget' {} Maybe Text
a -> MongoDBTarget
s {$sel:path:MongoDBTarget' :: Maybe Text
path = Maybe Text
a} :: MongoDBTarget)

-- | 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@.
mongoDBTarget_scanAll :: Lens.Lens' MongoDBTarget (Prelude.Maybe Prelude.Bool)
mongoDBTarget_scanAll :: Lens' MongoDBTarget (Maybe Bool)
mongoDBTarget_scanAll = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MongoDBTarget' {Maybe Bool
scanAll :: Maybe Bool
$sel:scanAll:MongoDBTarget' :: MongoDBTarget -> Maybe Bool
scanAll} -> Maybe Bool
scanAll) (\s :: MongoDBTarget
s@MongoDBTarget' {} Maybe Bool
a -> MongoDBTarget
s {$sel:scanAll:MongoDBTarget' :: Maybe Bool
scanAll = Maybe Bool
a} :: MongoDBTarget)

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

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

instance Prelude.NFData MongoDBTarget where
  rnf :: MongoDBTarget -> ()
rnf MongoDBTarget' {Maybe Bool
Maybe Text
scanAll :: Maybe Bool
path :: Maybe Text
connectionName :: Maybe Text
$sel:scanAll:MongoDBTarget' :: MongoDBTarget -> Maybe Bool
$sel:path:MongoDBTarget' :: MongoDBTarget -> Maybe Text
$sel:connectionName:MongoDBTarget' :: MongoDBTarget -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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

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