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

import Amazonka.CodePipeline.Types.ArtifactStoreType
import Amazonka.CodePipeline.Types.EncryptionKey
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

-- | The S3 bucket where artifacts for the pipeline are stored.
--
-- You must include either @artifactStore@ or @artifactStores@ in your
-- pipeline, but you cannot use both. If you create a cross-region action
-- in your pipeline, you must use @artifactStores@.
--
-- /See:/ 'newArtifactStore' smart constructor.
data ArtifactStore = ArtifactStore'
  { -- | The encryption key used to encrypt the data in the artifact store, such
    -- as an AWS Key Management Service (AWS KMS) key. If this is undefined,
    -- the default key for Amazon S3 is used.
    ArtifactStore -> Maybe EncryptionKey
encryptionKey :: Prelude.Maybe EncryptionKey,
    -- | The type of the artifact store, such as S3.
    ArtifactStore -> ArtifactStoreType
type' :: ArtifactStoreType,
    -- | The S3 bucket used for storing the artifacts for a pipeline. You can
    -- specify the name of an S3 bucket but not a folder in the bucket. A
    -- folder to contain the pipeline artifacts is created for you based on the
    -- name of the pipeline. You can use any S3 bucket in the same AWS Region
    -- as the pipeline to store your pipeline artifacts.
    ArtifactStore -> Text
location :: Prelude.Text
  }
  deriving (ArtifactStore -> ArtifactStore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArtifactStore -> ArtifactStore -> Bool
$c/= :: ArtifactStore -> ArtifactStore -> Bool
== :: ArtifactStore -> ArtifactStore -> Bool
$c== :: ArtifactStore -> ArtifactStore -> Bool
Prelude.Eq, ReadPrec [ArtifactStore]
ReadPrec ArtifactStore
Int -> ReadS ArtifactStore
ReadS [ArtifactStore]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArtifactStore]
$creadListPrec :: ReadPrec [ArtifactStore]
readPrec :: ReadPrec ArtifactStore
$creadPrec :: ReadPrec ArtifactStore
readList :: ReadS [ArtifactStore]
$creadList :: ReadS [ArtifactStore]
readsPrec :: Int -> ReadS ArtifactStore
$creadsPrec :: Int -> ReadS ArtifactStore
Prelude.Read, Int -> ArtifactStore -> ShowS
[ArtifactStore] -> ShowS
ArtifactStore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArtifactStore] -> ShowS
$cshowList :: [ArtifactStore] -> ShowS
show :: ArtifactStore -> String
$cshow :: ArtifactStore -> String
showsPrec :: Int -> ArtifactStore -> ShowS
$cshowsPrec :: Int -> ArtifactStore -> ShowS
Prelude.Show, forall x. Rep ArtifactStore x -> ArtifactStore
forall x. ArtifactStore -> Rep ArtifactStore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArtifactStore x -> ArtifactStore
$cfrom :: forall x. ArtifactStore -> Rep ArtifactStore x
Prelude.Generic)

-- |
-- Create a value of 'ArtifactStore' 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:
--
-- 'encryptionKey', 'artifactStore_encryptionKey' - The encryption key used to encrypt the data in the artifact store, such
-- as an AWS Key Management Service (AWS KMS) key. If this is undefined,
-- the default key for Amazon S3 is used.
--
-- 'type'', 'artifactStore_type' - The type of the artifact store, such as S3.
--
-- 'location', 'artifactStore_location' - The S3 bucket used for storing the artifacts for a pipeline. You can
-- specify the name of an S3 bucket but not a folder in the bucket. A
-- folder to contain the pipeline artifacts is created for you based on the
-- name of the pipeline. You can use any S3 bucket in the same AWS Region
-- as the pipeline to store your pipeline artifacts.
newArtifactStore ::
  -- | 'type''
  ArtifactStoreType ->
  -- | 'location'
  Prelude.Text ->
  ArtifactStore
newArtifactStore :: ArtifactStoreType -> Text -> ArtifactStore
newArtifactStore ArtifactStoreType
pType_ Text
pLocation_ =
  ArtifactStore'
    { $sel:encryptionKey:ArtifactStore' :: Maybe EncryptionKey
encryptionKey = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ArtifactStore' :: ArtifactStoreType
type' = ArtifactStoreType
pType_,
      $sel:location:ArtifactStore' :: Text
location = Text
pLocation_
    }

-- | The encryption key used to encrypt the data in the artifact store, such
-- as an AWS Key Management Service (AWS KMS) key. If this is undefined,
-- the default key for Amazon S3 is used.
artifactStore_encryptionKey :: Lens.Lens' ArtifactStore (Prelude.Maybe EncryptionKey)
artifactStore_encryptionKey :: Lens' ArtifactStore (Maybe EncryptionKey)
artifactStore_encryptionKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactStore' {Maybe EncryptionKey
encryptionKey :: Maybe EncryptionKey
$sel:encryptionKey:ArtifactStore' :: ArtifactStore -> Maybe EncryptionKey
encryptionKey} -> Maybe EncryptionKey
encryptionKey) (\s :: ArtifactStore
s@ArtifactStore' {} Maybe EncryptionKey
a -> ArtifactStore
s {$sel:encryptionKey:ArtifactStore' :: Maybe EncryptionKey
encryptionKey = Maybe EncryptionKey
a} :: ArtifactStore)

-- | The type of the artifact store, such as S3.
artifactStore_type :: Lens.Lens' ArtifactStore ArtifactStoreType
artifactStore_type :: Lens' ArtifactStore ArtifactStoreType
artifactStore_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactStore' {ArtifactStoreType
type' :: ArtifactStoreType
$sel:type':ArtifactStore' :: ArtifactStore -> ArtifactStoreType
type'} -> ArtifactStoreType
type') (\s :: ArtifactStore
s@ArtifactStore' {} ArtifactStoreType
a -> ArtifactStore
s {$sel:type':ArtifactStore' :: ArtifactStoreType
type' = ArtifactStoreType
a} :: ArtifactStore)

-- | The S3 bucket used for storing the artifacts for a pipeline. You can
-- specify the name of an S3 bucket but not a folder in the bucket. A
-- folder to contain the pipeline artifacts is created for you based on the
-- name of the pipeline. You can use any S3 bucket in the same AWS Region
-- as the pipeline to store your pipeline artifacts.
artifactStore_location :: Lens.Lens' ArtifactStore Prelude.Text
artifactStore_location :: Lens' ArtifactStore Text
artifactStore_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArtifactStore' {Text
location :: Text
$sel:location:ArtifactStore' :: ArtifactStore -> Text
location} -> Text
location) (\s :: ArtifactStore
s@ArtifactStore' {} Text
a -> ArtifactStore
s {$sel:location:ArtifactStore' :: Text
location = Text
a} :: ArtifactStore)

instance Data.FromJSON ArtifactStore where
  parseJSON :: Value -> Parser ArtifactStore
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ArtifactStore"
      ( \Object
x ->
          Maybe EncryptionKey -> ArtifactStoreType -> Text -> ArtifactStore
ArtifactStore'
            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
"encryptionKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"location")
      )

instance Prelude.Hashable ArtifactStore where
  hashWithSalt :: Int -> ArtifactStore -> Int
hashWithSalt Int
_salt ArtifactStore' {Maybe EncryptionKey
Text
ArtifactStoreType
location :: Text
type' :: ArtifactStoreType
encryptionKey :: Maybe EncryptionKey
$sel:location:ArtifactStore' :: ArtifactStore -> Text
$sel:type':ArtifactStore' :: ArtifactStore -> ArtifactStoreType
$sel:encryptionKey:ArtifactStore' :: ArtifactStore -> Maybe EncryptionKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionKey
encryptionKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ArtifactStoreType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
location

instance Prelude.NFData ArtifactStore where
  rnf :: ArtifactStore -> ()
rnf ArtifactStore' {Maybe EncryptionKey
Text
ArtifactStoreType
location :: Text
type' :: ArtifactStoreType
encryptionKey :: Maybe EncryptionKey
$sel:location:ArtifactStore' :: ArtifactStore -> Text
$sel:type':ArtifactStore' :: ArtifactStore -> ArtifactStoreType
$sel:encryptionKey:ArtifactStore' :: ArtifactStore -> Maybe EncryptionKey
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionKey
encryptionKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ArtifactStoreType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
location

instance Data.ToJSON ArtifactStore where
  toJSON :: ArtifactStore -> Value
toJSON ArtifactStore' {Maybe EncryptionKey
Text
ArtifactStoreType
location :: Text
type' :: ArtifactStoreType
encryptionKey :: Maybe EncryptionKey
$sel:location:ArtifactStore' :: ArtifactStore -> Text
$sel:type':ArtifactStore' :: ArtifactStore -> ArtifactStoreType
$sel:encryptionKey:ArtifactStore' :: ArtifactStore -> Maybe EncryptionKey
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"encryptionKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionKey
encryptionKey,
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ArtifactStoreType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"location" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
location)
          ]
      )