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

import Amazonka.CodePipeline.Types.ArtifactLocationType
import Amazonka.CodePipeline.Types.S3ArtifactLocation
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about the location of an artifact.
--
-- /See:/ 'newArtifactLocation' smart constructor.
data ArtifactLocation = ArtifactLocation'
  { -- | The S3 bucket that contains the artifact.
    ArtifactLocation -> Maybe S3ArtifactLocation
s3Location :: Prelude.Maybe S3ArtifactLocation,
    -- | The type of artifact in the location.
    ArtifactLocation -> Maybe ArtifactLocationType
type' :: Prelude.Maybe ArtifactLocationType
  }
  deriving (ArtifactLocation -> ArtifactLocation -> Bool
(ArtifactLocation -> ArtifactLocation -> Bool)
-> (ArtifactLocation -> ArtifactLocation -> Bool)
-> Eq ArtifactLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArtifactLocation -> ArtifactLocation -> Bool
$c/= :: ArtifactLocation -> ArtifactLocation -> Bool
== :: ArtifactLocation -> ArtifactLocation -> Bool
$c== :: ArtifactLocation -> ArtifactLocation -> Bool
Prelude.Eq, ReadPrec [ArtifactLocation]
ReadPrec ArtifactLocation
Int -> ReadS ArtifactLocation
ReadS [ArtifactLocation]
(Int -> ReadS ArtifactLocation)
-> ReadS [ArtifactLocation]
-> ReadPrec ArtifactLocation
-> ReadPrec [ArtifactLocation]
-> Read ArtifactLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArtifactLocation]
$creadListPrec :: ReadPrec [ArtifactLocation]
readPrec :: ReadPrec ArtifactLocation
$creadPrec :: ReadPrec ArtifactLocation
readList :: ReadS [ArtifactLocation]
$creadList :: ReadS [ArtifactLocation]
readsPrec :: Int -> ReadS ArtifactLocation
$creadsPrec :: Int -> ReadS ArtifactLocation
Prelude.Read, Int -> ArtifactLocation -> ShowS
[ArtifactLocation] -> ShowS
ArtifactLocation -> String
(Int -> ArtifactLocation -> ShowS)
-> (ArtifactLocation -> String)
-> ([ArtifactLocation] -> ShowS)
-> Show ArtifactLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArtifactLocation] -> ShowS
$cshowList :: [ArtifactLocation] -> ShowS
show :: ArtifactLocation -> String
$cshow :: ArtifactLocation -> String
showsPrec :: Int -> ArtifactLocation -> ShowS
$cshowsPrec :: Int -> ArtifactLocation -> ShowS
Prelude.Show, (forall x. ArtifactLocation -> Rep ArtifactLocation x)
-> (forall x. Rep ArtifactLocation x -> ArtifactLocation)
-> Generic ArtifactLocation
forall x. Rep ArtifactLocation x -> ArtifactLocation
forall x. ArtifactLocation -> Rep ArtifactLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArtifactLocation x -> ArtifactLocation
$cfrom :: forall x. ArtifactLocation -> Rep ArtifactLocation x
Prelude.Generic)

-- |
-- Create a value of 'ArtifactLocation' 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:
--
-- 's3Location', 'artifactLocation_s3Location' - The S3 bucket that contains the artifact.
--
-- 'type'', 'artifactLocation_type' - The type of artifact in the location.
newArtifactLocation ::
  ArtifactLocation
newArtifactLocation :: ArtifactLocation
newArtifactLocation =
  ArtifactLocation' :: Maybe S3ArtifactLocation
-> Maybe ArtifactLocationType -> ArtifactLocation
ArtifactLocation'
    { $sel:s3Location:ArtifactLocation' :: Maybe S3ArtifactLocation
s3Location = Maybe S3ArtifactLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ArtifactLocation' :: Maybe ArtifactLocationType
type' = Maybe ArtifactLocationType
forall a. Maybe a
Prelude.Nothing
    }

-- | The S3 bucket that contains the artifact.
artifactLocation_s3Location :: Lens.Lens' ArtifactLocation (Prelude.Maybe S3ArtifactLocation)
artifactLocation_s3Location :: (Maybe S3ArtifactLocation -> f (Maybe S3ArtifactLocation))
-> ArtifactLocation -> f ArtifactLocation
artifactLocation_s3Location = (ArtifactLocation -> Maybe S3ArtifactLocation)
-> (ArtifactLocation
    -> Maybe S3ArtifactLocation -> ArtifactLocation)
-> Lens
     ArtifactLocation
     ArtifactLocation
     (Maybe S3ArtifactLocation)
     (Maybe S3ArtifactLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactLocation' {Maybe S3ArtifactLocation
s3Location :: Maybe S3ArtifactLocation
$sel:s3Location:ArtifactLocation' :: ArtifactLocation -> Maybe S3ArtifactLocation
s3Location} -> Maybe S3ArtifactLocation
s3Location) (\s :: ArtifactLocation
s@ArtifactLocation' {} Maybe S3ArtifactLocation
a -> ArtifactLocation
s {$sel:s3Location:ArtifactLocation' :: Maybe S3ArtifactLocation
s3Location = Maybe S3ArtifactLocation
a} :: ArtifactLocation)

-- | The type of artifact in the location.
artifactLocation_type :: Lens.Lens' ArtifactLocation (Prelude.Maybe ArtifactLocationType)
artifactLocation_type :: (Maybe ArtifactLocationType -> f (Maybe ArtifactLocationType))
-> ArtifactLocation -> f ArtifactLocation
artifactLocation_type = (ArtifactLocation -> Maybe ArtifactLocationType)
-> (ArtifactLocation
    -> Maybe ArtifactLocationType -> ArtifactLocation)
-> Lens
     ArtifactLocation
     ArtifactLocation
     (Maybe ArtifactLocationType)
     (Maybe ArtifactLocationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactLocation' {Maybe ArtifactLocationType
type' :: Maybe ArtifactLocationType
$sel:type':ArtifactLocation' :: ArtifactLocation -> Maybe ArtifactLocationType
type'} -> Maybe ArtifactLocationType
type') (\s :: ArtifactLocation
s@ArtifactLocation' {} Maybe ArtifactLocationType
a -> ArtifactLocation
s {$sel:type':ArtifactLocation' :: Maybe ArtifactLocationType
type' = Maybe ArtifactLocationType
a} :: ArtifactLocation)

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

instance Prelude.Hashable ArtifactLocation

instance Prelude.NFData ArtifactLocation