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

import Amazonka.CodePipeline.Types.ArtifactStoreType
import Amazonka.CodePipeline.Types.EncryptionKey
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ArtifactStore -> ArtifactStore -> Bool)
-> (ArtifactStore -> ArtifactStore -> Bool) -> Eq ArtifactStore
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]
(Int -> ReadS ArtifactStore)
-> ReadS [ArtifactStore]
-> ReadPrec ArtifactStore
-> ReadPrec [ArtifactStore]
-> Read 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
(Int -> ArtifactStore -> ShowS)
-> (ArtifactStore -> String)
-> ([ArtifactStore] -> ShowS)
-> Show ArtifactStore
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. ArtifactStore -> Rep ArtifactStore x)
-> (forall x. Rep ArtifactStore x -> ArtifactStore)
-> Generic ArtifactStore
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' :: Maybe EncryptionKey -> ArtifactStoreType -> Text -> ArtifactStore
ArtifactStore'
    { $sel:encryptionKey:ArtifactStore' :: Maybe EncryptionKey
encryptionKey = Maybe 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 :: (Maybe EncryptionKey -> f (Maybe EncryptionKey))
-> ArtifactStore -> f ArtifactStore
artifactStore_encryptionKey = (ArtifactStore -> Maybe EncryptionKey)
-> (ArtifactStore -> Maybe EncryptionKey -> ArtifactStore)
-> Lens
     ArtifactStore
     ArtifactStore
     (Maybe EncryptionKey)
     (Maybe 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 :: (ArtifactStoreType -> f ArtifactStoreType)
-> ArtifactStore -> f ArtifactStore
artifactStore_type = (ArtifactStore -> ArtifactStoreType)
-> (ArtifactStore -> ArtifactStoreType -> ArtifactStore)
-> Lens
     ArtifactStore ArtifactStore ArtifactStoreType ArtifactStoreType
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 :: (Text -> f Text) -> ArtifactStore -> f ArtifactStore
artifactStore_location = (ArtifactStore -> Text)
-> (ArtifactStore -> Text -> ArtifactStore)
-> Lens ArtifactStore ArtifactStore Text Text
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 Core.FromJSON ArtifactStore where
  parseJSON :: Value -> Parser ArtifactStore
parseJSON =
    String
-> (Object -> Parser ArtifactStore)
-> Value
-> Parser ArtifactStore
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArtifactStore"
      ( \Object
x ->
          Maybe EncryptionKey -> ArtifactStoreType -> Text -> ArtifactStore
ArtifactStore'
            (Maybe EncryptionKey -> ArtifactStoreType -> Text -> ArtifactStore)
-> Parser (Maybe EncryptionKey)
-> Parser (ArtifactStoreType -> Text -> ArtifactStore)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionKey)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryptionKey")
            Parser (ArtifactStoreType -> Text -> ArtifactStore)
-> Parser ArtifactStoreType -> Parser (Text -> ArtifactStore)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ArtifactStoreType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
            Parser (Text -> ArtifactStore)
-> Parser Text -> Parser ArtifactStore
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"location")
      )

instance Prelude.Hashable ArtifactStore

instance Prelude.NFData ArtifactStore

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"encryptionKey" Text -> EncryptionKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EncryptionKey -> Pair) -> Maybe EncryptionKey -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionKey
encryptionKey,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> ArtifactStoreType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ArtifactStoreType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"location" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
location)
          ]
      )