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

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

-- | Specifies an Amazon DocumentDB or MongoDB data store to crawl.
--
-- /See:/ 'newMongoDBTarget' smart constructor.
data MongoDBTarget = MongoDBTarget'
  { -- | The path of the Amazon DocumentDB or MongoDB target
    -- (database\/collection).
    MongoDBTarget -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The name of the connection to use to connect to the Amazon DocumentDB or
    -- MongoDB target.
    MongoDBTarget -> Maybe Text
connectionName :: 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
(MongoDBTarget -> MongoDBTarget -> Bool)
-> (MongoDBTarget -> MongoDBTarget -> Bool) -> Eq MongoDBTarget
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]
(Int -> ReadS MongoDBTarget)
-> ReadS [MongoDBTarget]
-> ReadPrec MongoDBTarget
-> ReadPrec [MongoDBTarget]
-> Read 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
(Int -> MongoDBTarget -> ShowS)
-> (MongoDBTarget -> String)
-> ([MongoDBTarget] -> ShowS)
-> Show MongoDBTarget
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. MongoDBTarget -> Rep MongoDBTarget x)
-> (forall x. Rep MongoDBTarget x -> MongoDBTarget)
-> Generic MongoDBTarget
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:
--
-- 'path', 'mongoDBTarget_path' - The path of the Amazon DocumentDB or MongoDB target
-- (database\/collection).
--
-- 'connectionName', 'mongoDBTarget_connectionName' - The name of the connection to use to connect to the Amazon DocumentDB or
-- MongoDB target.
--
-- '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' :: Maybe Text -> Maybe Text -> Maybe Bool -> MongoDBTarget
MongoDBTarget'
    { $sel:path:MongoDBTarget' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionName:MongoDBTarget' :: Maybe Text
connectionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:scanAll:MongoDBTarget' :: Maybe Bool
scanAll = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The path of the Amazon DocumentDB or MongoDB target
-- (database\/collection).
mongoDBTarget_path :: Lens.Lens' MongoDBTarget (Prelude.Maybe Prelude.Text)
mongoDBTarget_path :: (Maybe Text -> f (Maybe Text)) -> MongoDBTarget -> f MongoDBTarget
mongoDBTarget_path = (MongoDBTarget -> Maybe Text)
-> (MongoDBTarget -> Maybe Text -> MongoDBTarget)
-> Lens MongoDBTarget MongoDBTarget (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> MongoDBTarget -> f MongoDBTarget
mongoDBTarget_connectionName = (MongoDBTarget -> Maybe Text)
-> (MongoDBTarget -> Maybe Text -> MongoDBTarget)
-> Lens MongoDBTarget MongoDBTarget (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> MongoDBTarget -> f MongoDBTarget
mongoDBTarget_scanAll = (MongoDBTarget -> Maybe Bool)
-> (MongoDBTarget -> Maybe Bool -> MongoDBTarget)
-> Lens MongoDBTarget MongoDBTarget (Maybe Bool) (Maybe Bool)
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 Core.FromJSON MongoDBTarget where
  parseJSON :: Value -> Parser MongoDBTarget
parseJSON =
    String
-> (Object -> Parser MongoDBTarget)
-> Value
-> Parser MongoDBTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MongoDBTarget"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Bool -> MongoDBTarget
MongoDBTarget'
            (Maybe Text -> Maybe Text -> Maybe Bool -> MongoDBTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Bool -> MongoDBTarget)
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 Text -> Maybe Bool -> MongoDBTarget)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> MongoDBTarget)
forall (f :: * -> *) a b. Applicative f => 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
"ConnectionName")
            Parser (Maybe Bool -> MongoDBTarget)
-> Parser (Maybe Bool) -> Parser MongoDBTarget
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 MongoDBTarget

instance Prelude.NFData MongoDBTarget

instance Core.ToJSON MongoDBTarget where
  toJSON :: MongoDBTarget -> Value
toJSON MongoDBTarget' {Maybe Bool
Maybe Text
scanAll :: Maybe Bool
connectionName :: Maybe Text
path :: Maybe Text
$sel:scanAll:MongoDBTarget' :: MongoDBTarget -> Maybe Bool
$sel:connectionName:MongoDBTarget' :: MongoDBTarget -> Maybe Text
$sel:path:MongoDBTarget' :: MongoDBTarget -> 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
"ConnectionName" 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
connectionName,
            (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
          ]
      )