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

import Amazonka.CodePipeline.Types.ArtifactLocation
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about an artifact that is worked on by actions in
-- the pipeline.
--
-- /See:/ 'newArtifact' smart constructor.
data Artifact = Artifact'
  { -- | The location of an artifact.
    Artifact -> Maybe ArtifactLocation
location :: Prelude.Maybe ArtifactLocation,
    -- | The artifact\'s name.
    Artifact -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The artifact\'s revision ID. Depending on the type of object, this could
    -- be a commit ID (GitHub) or a revision ID (Amazon S3).
    Artifact -> Maybe Text
revision :: Prelude.Maybe Prelude.Text
  }
  deriving (Artifact -> Artifact -> Bool
(Artifact -> Artifact -> Bool)
-> (Artifact -> Artifact -> Bool) -> Eq Artifact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Artifact -> Artifact -> Bool
$c/= :: Artifact -> Artifact -> Bool
== :: Artifact -> Artifact -> Bool
$c== :: Artifact -> Artifact -> Bool
Prelude.Eq, ReadPrec [Artifact]
ReadPrec Artifact
Int -> ReadS Artifact
ReadS [Artifact]
(Int -> ReadS Artifact)
-> ReadS [Artifact]
-> ReadPrec Artifact
-> ReadPrec [Artifact]
-> Read Artifact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Artifact]
$creadListPrec :: ReadPrec [Artifact]
readPrec :: ReadPrec Artifact
$creadPrec :: ReadPrec Artifact
readList :: ReadS [Artifact]
$creadList :: ReadS [Artifact]
readsPrec :: Int -> ReadS Artifact
$creadsPrec :: Int -> ReadS Artifact
Prelude.Read, Int -> Artifact -> ShowS
[Artifact] -> ShowS
Artifact -> String
(Int -> Artifact -> ShowS)
-> (Artifact -> String) -> ([Artifact] -> ShowS) -> Show Artifact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Artifact] -> ShowS
$cshowList :: [Artifact] -> ShowS
show :: Artifact -> String
$cshow :: Artifact -> String
showsPrec :: Int -> Artifact -> ShowS
$cshowsPrec :: Int -> Artifact -> ShowS
Prelude.Show, (forall x. Artifact -> Rep Artifact x)
-> (forall x. Rep Artifact x -> Artifact) -> Generic Artifact
forall x. Rep Artifact x -> Artifact
forall x. Artifact -> Rep Artifact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Artifact x -> Artifact
$cfrom :: forall x. Artifact -> Rep Artifact x
Prelude.Generic)

-- |
-- Create a value of 'Artifact' 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:
--
-- 'location', 'artifact_location' - The location of an artifact.
--
-- 'name', 'artifact_name' - The artifact\'s name.
--
-- 'revision', 'artifact_revision' - The artifact\'s revision ID. Depending on the type of object, this could
-- be a commit ID (GitHub) or a revision ID (Amazon S3).
newArtifact ::
  Artifact
newArtifact :: Artifact
newArtifact =
  Artifact' :: Maybe ArtifactLocation -> Maybe Text -> Maybe Text -> Artifact
Artifact'
    { $sel:location:Artifact' :: Maybe ArtifactLocation
location = Maybe ArtifactLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Artifact' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:revision:Artifact' :: Maybe Text
revision = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The location of an artifact.
artifact_location :: Lens.Lens' Artifact (Prelude.Maybe ArtifactLocation)
artifact_location :: (Maybe ArtifactLocation -> f (Maybe ArtifactLocation))
-> Artifact -> f Artifact
artifact_location = (Artifact -> Maybe ArtifactLocation)
-> (Artifact -> Maybe ArtifactLocation -> Artifact)
-> Lens
     Artifact Artifact (Maybe ArtifactLocation) (Maybe ArtifactLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Artifact' {Maybe ArtifactLocation
location :: Maybe ArtifactLocation
$sel:location:Artifact' :: Artifact -> Maybe ArtifactLocation
location} -> Maybe ArtifactLocation
location) (\s :: Artifact
s@Artifact' {} Maybe ArtifactLocation
a -> Artifact
s {$sel:location:Artifact' :: Maybe ArtifactLocation
location = Maybe ArtifactLocation
a} :: Artifact)

-- | The artifact\'s name.
artifact_name :: Lens.Lens' Artifact (Prelude.Maybe Prelude.Text)
artifact_name :: (Maybe Text -> f (Maybe Text)) -> Artifact -> f Artifact
artifact_name = (Artifact -> Maybe Text)
-> (Artifact -> Maybe Text -> Artifact)
-> Lens Artifact Artifact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Artifact' {Maybe Text
name :: Maybe Text
$sel:name:Artifact' :: Artifact -> Maybe Text
name} -> Maybe Text
name) (\s :: Artifact
s@Artifact' {} Maybe Text
a -> Artifact
s {$sel:name:Artifact' :: Maybe Text
name = Maybe Text
a} :: Artifact)

-- | The artifact\'s revision ID. Depending on the type of object, this could
-- be a commit ID (GitHub) or a revision ID (Amazon S3).
artifact_revision :: Lens.Lens' Artifact (Prelude.Maybe Prelude.Text)
artifact_revision :: (Maybe Text -> f (Maybe Text)) -> Artifact -> f Artifact
artifact_revision = (Artifact -> Maybe Text)
-> (Artifact -> Maybe Text -> Artifact)
-> Lens Artifact Artifact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Artifact' {Maybe Text
revision :: Maybe Text
$sel:revision:Artifact' :: Artifact -> Maybe Text
revision} -> Maybe Text
revision) (\s :: Artifact
s@Artifact' {} Maybe Text
a -> Artifact
s {$sel:revision:Artifact' :: Maybe Text
revision = Maybe Text
a} :: Artifact)

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

instance Prelude.Hashable Artifact

instance Prelude.NFData Artifact