{-# 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.DataPipeline.Types.PipelineObject
-- 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.DataPipeline.Types.PipelineObject where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataPipeline.Types.Field
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a pipeline object. This can be a logical,
-- physical, or physical attempt pipeline object. The complete set of
-- components of a pipeline defines the pipeline.
--
-- /See:/ 'newPipelineObject' smart constructor.
data PipelineObject = PipelineObject'
  { -- | The ID of the object.
    PipelineObject -> Text
id :: Prelude.Text,
    -- | The name of the object.
    PipelineObject -> Text
name :: Prelude.Text,
    -- | Key-value pairs that define the properties of the object.
    PipelineObject -> [Field]
fields :: [Field]
  }
  deriving (PipelineObject -> PipelineObject -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipelineObject -> PipelineObject -> Bool
$c/= :: PipelineObject -> PipelineObject -> Bool
== :: PipelineObject -> PipelineObject -> Bool
$c== :: PipelineObject -> PipelineObject -> Bool
Prelude.Eq, ReadPrec [PipelineObject]
ReadPrec PipelineObject
Int -> ReadS PipelineObject
ReadS [PipelineObject]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipelineObject]
$creadListPrec :: ReadPrec [PipelineObject]
readPrec :: ReadPrec PipelineObject
$creadPrec :: ReadPrec PipelineObject
readList :: ReadS [PipelineObject]
$creadList :: ReadS [PipelineObject]
readsPrec :: Int -> ReadS PipelineObject
$creadsPrec :: Int -> ReadS PipelineObject
Prelude.Read, Int -> PipelineObject -> ShowS
[PipelineObject] -> ShowS
PipelineObject -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipelineObject] -> ShowS
$cshowList :: [PipelineObject] -> ShowS
show :: PipelineObject -> String
$cshow :: PipelineObject -> String
showsPrec :: Int -> PipelineObject -> ShowS
$cshowsPrec :: Int -> PipelineObject -> ShowS
Prelude.Show, forall x. Rep PipelineObject x -> PipelineObject
forall x. PipelineObject -> Rep PipelineObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PipelineObject x -> PipelineObject
$cfrom :: forall x. PipelineObject -> Rep PipelineObject x
Prelude.Generic)

-- |
-- Create a value of 'PipelineObject' 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:
--
-- 'id', 'pipelineObject_id' - The ID of the object.
--
-- 'name', 'pipelineObject_name' - The name of the object.
--
-- 'fields', 'pipelineObject_fields' - Key-value pairs that define the properties of the object.
newPipelineObject ::
  -- | 'id'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  PipelineObject
newPipelineObject :: Text -> Text -> PipelineObject
newPipelineObject Text
pId_ Text
pName_ =
  PipelineObject'
    { $sel:id:PipelineObject' :: Text
id = Text
pId_,
      $sel:name:PipelineObject' :: Text
name = Text
pName_,
      $sel:fields:PipelineObject' :: [Field]
fields = forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the object.
pipelineObject_id :: Lens.Lens' PipelineObject Prelude.Text
pipelineObject_id :: Lens' PipelineObject Text
pipelineObject_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineObject' {Text
id :: Text
$sel:id:PipelineObject' :: PipelineObject -> Text
id} -> Text
id) (\s :: PipelineObject
s@PipelineObject' {} Text
a -> PipelineObject
s {$sel:id:PipelineObject' :: Text
id = Text
a} :: PipelineObject)

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

-- | Key-value pairs that define the properties of the object.
pipelineObject_fields :: Lens.Lens' PipelineObject [Field]
pipelineObject_fields :: Lens' PipelineObject [Field]
pipelineObject_fields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineObject' {[Field]
fields :: [Field]
$sel:fields:PipelineObject' :: PipelineObject -> [Field]
fields} -> [Field]
fields) (\s :: PipelineObject
s@PipelineObject' {} [Field]
a -> PipelineObject
s {$sel:fields:PipelineObject' :: [Field]
fields = [Field]
a} :: PipelineObject) 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 PipelineObject where
  parseJSON :: Value -> Parser PipelineObject
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PipelineObject"
      ( \Object
x ->
          Text -> Text -> [Field] -> PipelineObject
PipelineObject'
            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
"id")
            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
"name")
            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
"fields" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PipelineObject where
  hashWithSalt :: Int -> PipelineObject -> Int
hashWithSalt Int
_salt PipelineObject' {[Field]
Text
fields :: [Field]
name :: Text
id :: Text
$sel:fields:PipelineObject' :: PipelineObject -> [Field]
$sel:name:PipelineObject' :: PipelineObject -> Text
$sel:id:PipelineObject' :: PipelineObject -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Field]
fields

instance Prelude.NFData PipelineObject where
  rnf :: PipelineObject -> ()
rnf PipelineObject' {[Field]
Text
fields :: [Field]
name :: Text
id :: Text
$sel:fields:PipelineObject' :: PipelineObject -> [Field]
$sel:name:PipelineObject' :: PipelineObject -> Text
$sel:id:PipelineObject' :: PipelineObject -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 [Field]
fields

instance Data.ToJSON PipelineObject where
  toJSON :: PipelineObject -> Value
toJSON PipelineObject' {[Field]
Text
fields :: [Field]
name :: Text
id :: Text
$sel:fields:PipelineObject' :: PipelineObject -> [Field]
$sel:name:PipelineObject' :: PipelineObject -> Text
$sel:id:PipelineObject' :: PipelineObject -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            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
"fields" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Field]
fields)
          ]
      )