{-# 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.CodePipeline.Types.OutputArtifact
-- 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.CodePipeline.Types.OutputArtifact where

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

-- | Represents information about the output of an action.
--
-- /See:/ 'newOutputArtifact' smart constructor.
data OutputArtifact = OutputArtifact'
  { -- | The name of the output of an artifact, such as \"My App\".
    --
    -- The input artifact of an action must exactly match the output artifact
    -- declared in a preceding action, but the input artifact does not have to
    -- be the next action in strict sequence from the action that provided the
    -- output artifact. Actions in parallel can declare different output
    -- artifacts, which are in turn consumed by different following actions.
    --
    -- Output artifact names must be unique within a pipeline.
    OutputArtifact -> Text
name :: Prelude.Text
  }
  deriving (OutputArtifact -> OutputArtifact -> Bool
(OutputArtifact -> OutputArtifact -> Bool)
-> (OutputArtifact -> OutputArtifact -> Bool) -> Eq OutputArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputArtifact -> OutputArtifact -> Bool
$c/= :: OutputArtifact -> OutputArtifact -> Bool
== :: OutputArtifact -> OutputArtifact -> Bool
$c== :: OutputArtifact -> OutputArtifact -> Bool
Prelude.Eq, ReadPrec [OutputArtifact]
ReadPrec OutputArtifact
Int -> ReadS OutputArtifact
ReadS [OutputArtifact]
(Int -> ReadS OutputArtifact)
-> ReadS [OutputArtifact]
-> ReadPrec OutputArtifact
-> ReadPrec [OutputArtifact]
-> Read OutputArtifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputArtifact]
$creadListPrec :: ReadPrec [OutputArtifact]
readPrec :: ReadPrec OutputArtifact
$creadPrec :: ReadPrec OutputArtifact
readList :: ReadS [OutputArtifact]
$creadList :: ReadS [OutputArtifact]
readsPrec :: Int -> ReadS OutputArtifact
$creadsPrec :: Int -> ReadS OutputArtifact
Prelude.Read, Int -> OutputArtifact -> ShowS
[OutputArtifact] -> ShowS
OutputArtifact -> String
(Int -> OutputArtifact -> ShowS)
-> (OutputArtifact -> String)
-> ([OutputArtifact] -> ShowS)
-> Show OutputArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputArtifact] -> ShowS
$cshowList :: [OutputArtifact] -> ShowS
show :: OutputArtifact -> String
$cshow :: OutputArtifact -> String
showsPrec :: Int -> OutputArtifact -> ShowS
$cshowsPrec :: Int -> OutputArtifact -> ShowS
Prelude.Show, (forall x. OutputArtifact -> Rep OutputArtifact x)
-> (forall x. Rep OutputArtifact x -> OutputArtifact)
-> Generic OutputArtifact
forall x. Rep OutputArtifact x -> OutputArtifact
forall x. OutputArtifact -> Rep OutputArtifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputArtifact x -> OutputArtifact
$cfrom :: forall x. OutputArtifact -> Rep OutputArtifact x
Prelude.Generic)

-- |
-- Create a value of 'OutputArtifact' 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', 'outputArtifact_name' - The name of the output of an artifact, such as \"My App\".
--
-- The input artifact of an action must exactly match the output artifact
-- declared in a preceding action, but the input artifact does not have to
-- be the next action in strict sequence from the action that provided the
-- output artifact. Actions in parallel can declare different output
-- artifacts, which are in turn consumed by different following actions.
--
-- Output artifact names must be unique within a pipeline.
newOutputArtifact ::
  -- | 'name'
  Prelude.Text ->
  OutputArtifact
newOutputArtifact :: Text -> OutputArtifact
newOutputArtifact Text
pName_ =
  OutputArtifact' :: Text -> OutputArtifact
OutputArtifact' {$sel:name:OutputArtifact' :: Text
name = Text
pName_}

-- | The name of the output of an artifact, such as \"My App\".
--
-- The input artifact of an action must exactly match the output artifact
-- declared in a preceding action, but the input artifact does not have to
-- be the next action in strict sequence from the action that provided the
-- output artifact. Actions in parallel can declare different output
-- artifacts, which are in turn consumed by different following actions.
--
-- Output artifact names must be unique within a pipeline.
outputArtifact_name :: Lens.Lens' OutputArtifact Prelude.Text
outputArtifact_name :: (Text -> f Text) -> OutputArtifact -> f OutputArtifact
outputArtifact_name = (OutputArtifact -> Text)
-> (OutputArtifact -> Text -> OutputArtifact)
-> Lens OutputArtifact OutputArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputArtifact' {Text
name :: Text
$sel:name:OutputArtifact' :: OutputArtifact -> Text
name} -> Text
name) (\s :: OutputArtifact
s@OutputArtifact' {} Text
a -> OutputArtifact
s {$sel:name:OutputArtifact' :: Text
name = Text
a} :: OutputArtifact)

instance Core.FromJSON OutputArtifact where
  parseJSON :: Value -> Parser OutputArtifact
parseJSON =
    String
-> (Object -> Parser OutputArtifact)
-> Value
-> Parser OutputArtifact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OutputArtifact"
      ( \Object
x ->
          Text -> OutputArtifact
OutputArtifact' (Text -> OutputArtifact) -> Parser Text -> Parser OutputArtifact
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
      )

instance Prelude.Hashable OutputArtifact

instance Prelude.NFData OutputArtifact

instance Core.ToJSON OutputArtifact where
  toJSON :: OutputArtifact -> Value
toJSON OutputArtifact' {Text
name :: Text
$sel:name:OutputArtifact' :: OutputArtifact -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )