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

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

-- | Represents information about an artifact to be worked on, such as a test
-- or build artifact.
--
-- /See:/ 'newInputArtifact' smart constructor.
data InputArtifact = InputArtifact'
  { -- | The name of the artifact to be worked on (for example, \"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.
    InputArtifact -> Text
name :: Prelude.Text
  }
  deriving (InputArtifact -> InputArtifact -> Bool
(InputArtifact -> InputArtifact -> Bool)
-> (InputArtifact -> InputArtifact -> Bool) -> Eq InputArtifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputArtifact -> InputArtifact -> Bool
$c/= :: InputArtifact -> InputArtifact -> Bool
== :: InputArtifact -> InputArtifact -> Bool
$c== :: InputArtifact -> InputArtifact -> Bool
Prelude.Eq, ReadPrec [InputArtifact]
ReadPrec InputArtifact
Int -> ReadS InputArtifact
ReadS [InputArtifact]
(Int -> ReadS InputArtifact)
-> ReadS [InputArtifact]
-> ReadPrec InputArtifact
-> ReadPrec [InputArtifact]
-> Read InputArtifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputArtifact]
$creadListPrec :: ReadPrec [InputArtifact]
readPrec :: ReadPrec InputArtifact
$creadPrec :: ReadPrec InputArtifact
readList :: ReadS [InputArtifact]
$creadList :: ReadS [InputArtifact]
readsPrec :: Int -> ReadS InputArtifact
$creadsPrec :: Int -> ReadS InputArtifact
Prelude.Read, Int -> InputArtifact -> ShowS
[InputArtifact] -> ShowS
InputArtifact -> String
(Int -> InputArtifact -> ShowS)
-> (InputArtifact -> String)
-> ([InputArtifact] -> ShowS)
-> Show InputArtifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputArtifact] -> ShowS
$cshowList :: [InputArtifact] -> ShowS
show :: InputArtifact -> String
$cshow :: InputArtifact -> String
showsPrec :: Int -> InputArtifact -> ShowS
$cshowsPrec :: Int -> InputArtifact -> ShowS
Prelude.Show, (forall x. InputArtifact -> Rep InputArtifact x)
-> (forall x. Rep InputArtifact x -> InputArtifact)
-> Generic InputArtifact
forall x. Rep InputArtifact x -> InputArtifact
forall x. InputArtifact -> Rep InputArtifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputArtifact x -> InputArtifact
$cfrom :: forall x. InputArtifact -> Rep InputArtifact x
Prelude.Generic)

-- |
-- Create a value of 'InputArtifact' 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', 'inputArtifact_name' - The name of the artifact to be worked on (for example, \"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.
newInputArtifact ::
  -- | 'name'
  Prelude.Text ->
  InputArtifact
newInputArtifact :: Text -> InputArtifact
newInputArtifact Text
pName_ =
  InputArtifact' :: Text -> InputArtifact
InputArtifact' {$sel:name:InputArtifact' :: Text
name = Text
pName_}

-- | The name of the artifact to be worked on (for example, \"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.
inputArtifact_name :: Lens.Lens' InputArtifact Prelude.Text
inputArtifact_name :: (Text -> f Text) -> InputArtifact -> f InputArtifact
inputArtifact_name = (InputArtifact -> Text)
-> (InputArtifact -> Text -> InputArtifact)
-> Lens InputArtifact InputArtifact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputArtifact' {Text
name :: Text
$sel:name:InputArtifact' :: InputArtifact -> Text
name} -> Text
name) (\s :: InputArtifact
s@InputArtifact' {} Text
a -> InputArtifact
s {$sel:name:InputArtifact' :: Text
name = Text
a} :: InputArtifact)

instance Core.FromJSON InputArtifact where
  parseJSON :: Value -> Parser InputArtifact
parseJSON =
    String
-> (Object -> Parser InputArtifact)
-> Value
-> Parser InputArtifact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputArtifact"
      ( \Object
x ->
          Text -> InputArtifact
InputArtifact' (Text -> InputArtifact) -> Parser Text -> Parser InputArtifact
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 InputArtifact

instance Prelude.NFData InputArtifact

instance Core.ToJSON InputArtifact where
  toJSON :: InputArtifact -> Value
toJSON InputArtifact' {Text
name :: Text
$sel:name:InputArtifact' :: InputArtifact -> 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)]
      )