{-# 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.DataBrew.Types.Input
-- 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.DataBrew.Types.Input where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.DataCatalogInputDefinition
import Amazonka.DataBrew.Types.DatabaseInputDefinition
import Amazonka.DataBrew.Types.S3Location
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information on how DataBrew can find data, in either the Glue
-- Data Catalog or Amazon S3.
--
-- /See:/ 'newInput' smart constructor.
data Input = Input'
  { -- | The Glue Data Catalog parameters for the data.
    Input -> Maybe DataCatalogInputDefinition
dataCatalogInputDefinition :: Prelude.Maybe DataCatalogInputDefinition,
    -- | The Amazon S3 location where the data is stored.
    Input -> Maybe S3Location
s3InputDefinition :: Prelude.Maybe S3Location,
    -- | Connection information for dataset input files stored in a database.
    Input -> Maybe DatabaseInputDefinition
databaseInputDefinition :: Prelude.Maybe DatabaseInputDefinition
  }
  deriving (Input -> Input -> Bool
(Input -> Input -> Bool) -> (Input -> Input -> Bool) -> Eq Input
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Input -> Input -> Bool
$c/= :: Input -> Input -> Bool
== :: Input -> Input -> Bool
$c== :: Input -> Input -> Bool
Prelude.Eq, ReadPrec [Input]
ReadPrec Input
Int -> ReadS Input
ReadS [Input]
(Int -> ReadS Input)
-> ReadS [Input]
-> ReadPrec Input
-> ReadPrec [Input]
-> Read Input
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Input]
$creadListPrec :: ReadPrec [Input]
readPrec :: ReadPrec Input
$creadPrec :: ReadPrec Input
readList :: ReadS [Input]
$creadList :: ReadS [Input]
readsPrec :: Int -> ReadS Input
$creadsPrec :: Int -> ReadS Input
Prelude.Read, Int -> Input -> ShowS
[Input] -> ShowS
Input -> String
(Int -> Input -> ShowS)
-> (Input -> String) -> ([Input] -> ShowS) -> Show Input
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Input] -> ShowS
$cshowList :: [Input] -> ShowS
show :: Input -> String
$cshow :: Input -> String
showsPrec :: Int -> Input -> ShowS
$cshowsPrec :: Int -> Input -> ShowS
Prelude.Show, (forall x. Input -> Rep Input x)
-> (forall x. Rep Input x -> Input) -> Generic Input
forall x. Rep Input x -> Input
forall x. Input -> Rep Input x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Input x -> Input
$cfrom :: forall x. Input -> Rep Input x
Prelude.Generic)

-- |
-- Create a value of 'Input' 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:
--
-- 'dataCatalogInputDefinition', 'input_dataCatalogInputDefinition' - The Glue Data Catalog parameters for the data.
--
-- 's3InputDefinition', 'input_s3InputDefinition' - The Amazon S3 location where the data is stored.
--
-- 'databaseInputDefinition', 'input_databaseInputDefinition' - Connection information for dataset input files stored in a database.
newInput ::
  Input
newInput :: Input
newInput =
  Input' :: Maybe DataCatalogInputDefinition
-> Maybe S3Location -> Maybe DatabaseInputDefinition -> Input
Input'
    { $sel:dataCatalogInputDefinition:Input' :: Maybe DataCatalogInputDefinition
dataCatalogInputDefinition =
        Maybe DataCatalogInputDefinition
forall a. Maybe a
Prelude.Nothing,
      $sel:s3InputDefinition:Input' :: Maybe S3Location
s3InputDefinition = Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
      $sel:databaseInputDefinition:Input' :: Maybe DatabaseInputDefinition
databaseInputDefinition = Maybe DatabaseInputDefinition
forall a. Maybe a
Prelude.Nothing
    }

-- | The Glue Data Catalog parameters for the data.
input_dataCatalogInputDefinition :: Lens.Lens' Input (Prelude.Maybe DataCatalogInputDefinition)
input_dataCatalogInputDefinition :: (Maybe DataCatalogInputDefinition
 -> f (Maybe DataCatalogInputDefinition))
-> Input -> f Input
input_dataCatalogInputDefinition = (Input -> Maybe DataCatalogInputDefinition)
-> (Input -> Maybe DataCatalogInputDefinition -> Input)
-> Lens
     Input
     Input
     (Maybe DataCatalogInputDefinition)
     (Maybe DataCatalogInputDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe DataCatalogInputDefinition
dataCatalogInputDefinition :: Maybe DataCatalogInputDefinition
$sel:dataCatalogInputDefinition:Input' :: Input -> Maybe DataCatalogInputDefinition
dataCatalogInputDefinition} -> Maybe DataCatalogInputDefinition
dataCatalogInputDefinition) (\s :: Input
s@Input' {} Maybe DataCatalogInputDefinition
a -> Input
s {$sel:dataCatalogInputDefinition:Input' :: Maybe DataCatalogInputDefinition
dataCatalogInputDefinition = Maybe DataCatalogInputDefinition
a} :: Input)

-- | The Amazon S3 location where the data is stored.
input_s3InputDefinition :: Lens.Lens' Input (Prelude.Maybe S3Location)
input_s3InputDefinition :: (Maybe S3Location -> f (Maybe S3Location)) -> Input -> f Input
input_s3InputDefinition = (Input -> Maybe S3Location)
-> (Input -> Maybe S3Location -> Input)
-> Lens Input Input (Maybe S3Location) (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe S3Location
s3InputDefinition :: Maybe S3Location
$sel:s3InputDefinition:Input' :: Input -> Maybe S3Location
s3InputDefinition} -> Maybe S3Location
s3InputDefinition) (\s :: Input
s@Input' {} Maybe S3Location
a -> Input
s {$sel:s3InputDefinition:Input' :: Maybe S3Location
s3InputDefinition = Maybe S3Location
a} :: Input)

-- | Connection information for dataset input files stored in a database.
input_databaseInputDefinition :: Lens.Lens' Input (Prelude.Maybe DatabaseInputDefinition)
input_databaseInputDefinition :: (Maybe DatabaseInputDefinition
 -> f (Maybe DatabaseInputDefinition))
-> Input -> f Input
input_databaseInputDefinition = (Input -> Maybe DatabaseInputDefinition)
-> (Input -> Maybe DatabaseInputDefinition -> Input)
-> Lens
     Input
     Input
     (Maybe DatabaseInputDefinition)
     (Maybe DatabaseInputDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe DatabaseInputDefinition
databaseInputDefinition :: Maybe DatabaseInputDefinition
$sel:databaseInputDefinition:Input' :: Input -> Maybe DatabaseInputDefinition
databaseInputDefinition} -> Maybe DatabaseInputDefinition
databaseInputDefinition) (\s :: Input
s@Input' {} Maybe DatabaseInputDefinition
a -> Input
s {$sel:databaseInputDefinition:Input' :: Maybe DatabaseInputDefinition
databaseInputDefinition = Maybe DatabaseInputDefinition
a} :: Input)

instance Core.FromJSON Input where
  parseJSON :: Value -> Parser Input
parseJSON =
    String -> (Object -> Parser Input) -> Value -> Parser Input
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Input"
      ( \Object
x ->
          Maybe DataCatalogInputDefinition
-> Maybe S3Location -> Maybe DatabaseInputDefinition -> Input
Input'
            (Maybe DataCatalogInputDefinition
 -> Maybe S3Location -> Maybe DatabaseInputDefinition -> Input)
-> Parser (Maybe DataCatalogInputDefinition)
-> Parser
     (Maybe S3Location -> Maybe DatabaseInputDefinition -> Input)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe DataCatalogInputDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataCatalogInputDefinition")
            Parser (Maybe S3Location -> Maybe DatabaseInputDefinition -> Input)
-> Parser (Maybe S3Location)
-> Parser (Maybe DatabaseInputDefinition -> Input)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3InputDefinition")
            Parser (Maybe DatabaseInputDefinition -> Input)
-> Parser (Maybe DatabaseInputDefinition) -> Parser Input
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DatabaseInputDefinition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DatabaseInputDefinition")
      )

instance Prelude.Hashable Input

instance Prelude.NFData Input

instance Core.ToJSON Input where
  toJSON :: Input -> Value
toJSON Input' {Maybe S3Location
Maybe DatabaseInputDefinition
Maybe DataCatalogInputDefinition
databaseInputDefinition :: Maybe DatabaseInputDefinition
s3InputDefinition :: Maybe S3Location
dataCatalogInputDefinition :: Maybe DataCatalogInputDefinition
$sel:databaseInputDefinition:Input' :: Input -> Maybe DatabaseInputDefinition
$sel:s3InputDefinition:Input' :: Input -> Maybe S3Location
$sel:dataCatalogInputDefinition:Input' :: Input -> Maybe DataCatalogInputDefinition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DataCatalogInputDefinition" Text -> DataCatalogInputDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DataCatalogInputDefinition -> Pair)
-> Maybe DataCatalogInputDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DataCatalogInputDefinition
dataCatalogInputDefinition,
            (Text
"S3InputDefinition" Text -> S3Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3Location -> Pair) -> Maybe S3Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
s3InputDefinition,
            (Text
"DatabaseInputDefinition" Text -> DatabaseInputDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DatabaseInputDefinition -> Pair)
-> Maybe DatabaseInputDefinition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatabaseInputDefinition
databaseInputDefinition
          ]
      )