{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:s3Location:ArtifactLocation' :: Maybe S3ArtifactLocation
s3Location = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ArtifactLocation' :: Maybe ArtifactLocationType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The S3 bucket that contains the artifact.
artifactLocation_s3Location :: Lens.Lens' ArtifactLocation (Prelude.Maybe S3ArtifactLocation)
artifactLocation_s3Location :: Lens' ArtifactLocation (Maybe S3ArtifactLocation)
artifactLocation_s3Location = 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 :: Lens' ArtifactLocation (Maybe ArtifactLocationType)
artifactLocation_type = 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 Data.FromJSON ArtifactLocation where
  parseJSON :: Value -> Parser ArtifactLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ArtifactLocation"
      ( \Object
x ->
          Maybe S3ArtifactLocation
-> Maybe ArtifactLocationType -> ArtifactLocation
ArtifactLocation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"s3Location")
            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
"type")
      )

instance Prelude.Hashable ArtifactLocation where
  hashWithSalt :: Int -> ArtifactLocation -> Int
hashWithSalt Int
_salt ArtifactLocation' {Maybe ArtifactLocationType
Maybe S3ArtifactLocation
type' :: Maybe ArtifactLocationType
s3Location :: Maybe S3ArtifactLocation
$sel:type':ArtifactLocation' :: ArtifactLocation -> Maybe ArtifactLocationType
$sel:s3Location:ArtifactLocation' :: ArtifactLocation -> Maybe S3ArtifactLocation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3ArtifactLocation
s3Location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ArtifactLocationType
type'

instance Prelude.NFData ArtifactLocation where
  rnf :: ArtifactLocation -> ()
rnf ArtifactLocation' {Maybe ArtifactLocationType
Maybe S3ArtifactLocation
type' :: Maybe ArtifactLocationType
s3Location :: Maybe S3ArtifactLocation
$sel:type':ArtifactLocation' :: ArtifactLocation -> Maybe ArtifactLocationType
$sel:s3Location:ArtifactLocation' :: ArtifactLocation -> Maybe S3ArtifactLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe S3ArtifactLocation
s3Location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ArtifactLocationType
type'