{-# 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.DropFields
-- 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.DropFields 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 a transform that chooses the data property keys that you want
-- to drop.
--
-- /See:/ 'newDropFields' smart constructor.
data DropFields = DropFields'
  { -- | The name of the transform node.
    DropFields -> Text
name :: Prelude.Text,
    -- | The data inputs identified by their node names.
    DropFields -> NonEmpty Text
inputs :: Prelude.NonEmpty Prelude.Text,
    -- | A JSON path to a variable in the data structure.
    DropFields -> [[Text]]
paths :: [[Prelude.Text]]
  }
  deriving (DropFields -> DropFields -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DropFields -> DropFields -> Bool
$c/= :: DropFields -> DropFields -> Bool
== :: DropFields -> DropFields -> Bool
$c== :: DropFields -> DropFields -> Bool
Prelude.Eq, ReadPrec [DropFields]
ReadPrec DropFields
Int -> ReadS DropFields
ReadS [DropFields]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DropFields]
$creadListPrec :: ReadPrec [DropFields]
readPrec :: ReadPrec DropFields
$creadPrec :: ReadPrec DropFields
readList :: ReadS [DropFields]
$creadList :: ReadS [DropFields]
readsPrec :: Int -> ReadS DropFields
$creadsPrec :: Int -> ReadS DropFields
Prelude.Read, Int -> DropFields -> ShowS
[DropFields] -> ShowS
DropFields -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DropFields] -> ShowS
$cshowList :: [DropFields] -> ShowS
show :: DropFields -> String
$cshow :: DropFields -> String
showsPrec :: Int -> DropFields -> ShowS
$cshowsPrec :: Int -> DropFields -> ShowS
Prelude.Show, forall x. Rep DropFields x -> DropFields
forall x. DropFields -> Rep DropFields x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DropFields x -> DropFields
$cfrom :: forall x. DropFields -> Rep DropFields x
Prelude.Generic)

-- |
-- Create a value of 'DropFields' 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:
--
-- 'name', 'dropFields_name' - The name of the transform node.
--
-- 'inputs', 'dropFields_inputs' - The data inputs identified by their node names.
--
-- 'paths', 'dropFields_paths' - A JSON path to a variable in the data structure.
newDropFields ::
  -- | 'name'
  Prelude.Text ->
  -- | 'inputs'
  Prelude.NonEmpty Prelude.Text ->
  DropFields
newDropFields :: Text -> NonEmpty Text -> DropFields
newDropFields Text
pName_ NonEmpty Text
pInputs_ =
  DropFields'
    { $sel:name:DropFields' :: Text
name = Text
pName_,
      $sel:inputs:DropFields' :: NonEmpty Text
inputs = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pInputs_,
      $sel:paths:DropFields' :: [[Text]]
paths = forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the transform node.
dropFields_name :: Lens.Lens' DropFields Prelude.Text
dropFields_name :: Lens' DropFields Text
dropFields_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropFields' {Text
name :: Text
$sel:name:DropFields' :: DropFields -> Text
name} -> Text
name) (\s :: DropFields
s@DropFields' {} Text
a -> DropFields
s {$sel:name:DropFields' :: Text
name = Text
a} :: DropFields)

-- | The data inputs identified by their node names.
dropFields_inputs :: Lens.Lens' DropFields (Prelude.NonEmpty Prelude.Text)
dropFields_inputs :: Lens' DropFields (NonEmpty Text)
dropFields_inputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropFields' {NonEmpty Text
inputs :: NonEmpty Text
$sel:inputs:DropFields' :: DropFields -> NonEmpty Text
inputs} -> NonEmpty Text
inputs) (\s :: DropFields
s@DropFields' {} NonEmpty Text
a -> DropFields
s {$sel:inputs:DropFields' :: NonEmpty Text
inputs = NonEmpty Text
a} :: DropFields) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A JSON path to a variable in the data structure.
dropFields_paths :: Lens.Lens' DropFields [[Prelude.Text]]
dropFields_paths :: Lens' DropFields [[Text]]
dropFields_paths = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DropFields' {[[Text]]
paths :: [[Text]]
$sel:paths:DropFields' :: DropFields -> [[Text]]
paths} -> [[Text]]
paths) (\s :: DropFields
s@DropFields' {} [[Text]]
a -> DropFields
s {$sel:paths:DropFields' :: [[Text]]
paths = [[Text]]
a} :: DropFields) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON DropFields where
  parseJSON :: Value -> Parser DropFields
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DropFields"
      ( \Object
x ->
          Text -> NonEmpty Text -> [[Text]] -> DropFields
DropFields'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Inputs")
            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
"Paths" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable DropFields where
  hashWithSalt :: Int -> DropFields -> Int
hashWithSalt Int
_salt DropFields' {[[Text]]
NonEmpty Text
Text
paths :: [[Text]]
inputs :: NonEmpty Text
name :: Text
$sel:paths:DropFields' :: DropFields -> [[Text]]
$sel:inputs:DropFields' :: DropFields -> NonEmpty Text
$sel:name:DropFields' :: DropFields -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
inputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [[Text]]
paths

instance Prelude.NFData DropFields where
  rnf :: DropFields -> ()
rnf DropFields' {[[Text]]
NonEmpty Text
Text
paths :: [[Text]]
inputs :: NonEmpty Text
name :: Text
$sel:paths:DropFields' :: DropFields -> [[Text]]
$sel:inputs:DropFields' :: DropFields -> NonEmpty Text
$sel:name:DropFields' :: DropFields -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
inputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [[Text]]
paths

instance Data.ToJSON DropFields where
  toJSON :: DropFields -> Value
toJSON DropFields' {[[Text]]
NonEmpty Text
Text
paths :: [[Text]]
inputs :: NonEmpty Text
name :: Text
$sel:paths:DropFields' :: DropFields -> [[Text]]
$sel:inputs:DropFields' :: DropFields -> NonEmpty Text
$sel:name:DropFields' :: DropFields -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Inputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
inputs),
            forall a. a -> Maybe a
Prelude.Just (Key
"Paths" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [[Text]]
paths)
          ]
      )