{-# 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.CodeDeploy.Types.S3Location
-- 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.CodeDeploy.Types.S3Location where

import Amazonka.CodeDeploy.Types.BundleType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the location of application artifacts stored in Amazon
-- S3.
--
-- /See:/ 'newS3Location' smart constructor.
data S3Location = S3Location'
  { -- | The file type of the application revision. Must be one of the following:
    --
    -- -   @tar@: A tar archive file.
    --
    -- -   @tgz@: A compressed tar archive file.
    --
    -- -   @zip@: A zip archive file.
    S3Location -> Maybe BundleType
bundleType :: Prelude.Maybe BundleType,
    -- | The ETag of the Amazon S3 object that represents the bundled artifacts
    -- for the application revision.
    --
    -- If the ETag is not specified as an input parameter, ETag validation of
    -- the object is skipped.
    S3Location -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 bucket where the application revision is
    -- stored.
    S3Location -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon S3 object that represents the bundled artifacts
    -- for the application revision.
    S3Location -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | A specific version of the Amazon S3 object that represents the bundled
    -- artifacts for the application revision.
    --
    -- If the version is not specified, the system uses the most recent version
    -- by default.
    S3Location -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Location -> S3Location -> Bool
(S3Location -> S3Location -> Bool)
-> (S3Location -> S3Location -> Bool) -> Eq S3Location
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Location -> S3Location -> Bool
$c/= :: S3Location -> S3Location -> Bool
== :: S3Location -> S3Location -> Bool
$c== :: S3Location -> S3Location -> Bool
Prelude.Eq, ReadPrec [S3Location]
ReadPrec S3Location
Int -> ReadS S3Location
ReadS [S3Location]
(Int -> ReadS S3Location)
-> ReadS [S3Location]
-> ReadPrec S3Location
-> ReadPrec [S3Location]
-> Read S3Location
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Location]
$creadListPrec :: ReadPrec [S3Location]
readPrec :: ReadPrec S3Location
$creadPrec :: ReadPrec S3Location
readList :: ReadS [S3Location]
$creadList :: ReadS [S3Location]
readsPrec :: Int -> ReadS S3Location
$creadsPrec :: Int -> ReadS S3Location
Prelude.Read, Int -> S3Location -> ShowS
[S3Location] -> ShowS
S3Location -> String
(Int -> S3Location -> ShowS)
-> (S3Location -> String)
-> ([S3Location] -> ShowS)
-> Show S3Location
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Location] -> ShowS
$cshowList :: [S3Location] -> ShowS
show :: S3Location -> String
$cshow :: S3Location -> String
showsPrec :: Int -> S3Location -> ShowS
$cshowsPrec :: Int -> S3Location -> ShowS
Prelude.Show, (forall x. S3Location -> Rep S3Location x)
-> (forall x. Rep S3Location x -> S3Location) -> Generic S3Location
forall x. Rep S3Location x -> S3Location
forall x. S3Location -> Rep S3Location x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Location x -> S3Location
$cfrom :: forall x. S3Location -> Rep S3Location x
Prelude.Generic)

-- |
-- Create a value of 'S3Location' 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:
--
-- 'bundleType', 's3Location_bundleType' - The file type of the application revision. Must be one of the following:
--
-- -   @tar@: A tar archive file.
--
-- -   @tgz@: A compressed tar archive file.
--
-- -   @zip@: A zip archive file.
--
-- 'eTag', 's3Location_eTag' - The ETag of the Amazon S3 object that represents the bundled artifacts
-- for the application revision.
--
-- If the ETag is not specified as an input parameter, ETag validation of
-- the object is skipped.
--
-- 'bucket', 's3Location_bucket' - The name of the Amazon S3 bucket where the application revision is
-- stored.
--
-- 'key', 's3Location_key' - The name of the Amazon S3 object that represents the bundled artifacts
-- for the application revision.
--
-- 'version', 's3Location_version' - A specific version of the Amazon S3 object that represents the bundled
-- artifacts for the application revision.
--
-- If the version is not specified, the system uses the most recent version
-- by default.
newS3Location ::
  S3Location
newS3Location :: S3Location
newS3Location =
  S3Location' :: Maybe BundleType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> S3Location
S3Location'
    { $sel:bundleType:S3Location' :: Maybe BundleType
bundleType = Maybe BundleType
forall a. Maybe a
Prelude.Nothing,
      $sel:eTag:S3Location' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:S3Location' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:S3Location' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:S3Location' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The file type of the application revision. Must be one of the following:
--
-- -   @tar@: A tar archive file.
--
-- -   @tgz@: A compressed tar archive file.
--
-- -   @zip@: A zip archive file.
s3Location_bundleType :: Lens.Lens' S3Location (Prelude.Maybe BundleType)
s3Location_bundleType :: (Maybe BundleType -> f (Maybe BundleType))
-> S3Location -> f S3Location
s3Location_bundleType = (S3Location -> Maybe BundleType)
-> (S3Location -> Maybe BundleType -> S3Location)
-> Lens S3Location S3Location (Maybe BundleType) (Maybe BundleType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe BundleType
bundleType :: Maybe BundleType
$sel:bundleType:S3Location' :: S3Location -> Maybe BundleType
bundleType} -> Maybe BundleType
bundleType) (\s :: S3Location
s@S3Location' {} Maybe BundleType
a -> S3Location
s {$sel:bundleType:S3Location' :: Maybe BundleType
bundleType = Maybe BundleType
a} :: S3Location)

-- | The ETag of the Amazon S3 object that represents the bundled artifacts
-- for the application revision.
--
-- If the ETag is not specified as an input parameter, ETag validation of
-- the object is skipped.
s3Location_eTag :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_eTag :: (Maybe Text -> f (Maybe Text)) -> S3Location -> f S3Location
s3Location_eTag = (S3Location -> Maybe Text)
-> (S3Location -> Maybe Text -> S3Location)
-> Lens S3Location S3Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
eTag :: Maybe Text
$sel:eTag:S3Location' :: S3Location -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:eTag:S3Location' :: Maybe Text
eTag = Maybe Text
a} :: S3Location)

-- | The name of the Amazon S3 bucket where the application revision is
-- stored.
s3Location_bucket :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_bucket :: (Maybe Text -> f (Maybe Text)) -> S3Location -> f S3Location
s3Location_bucket = (S3Location -> Maybe Text)
-> (S3Location -> Maybe Text -> S3Location)
-> Lens S3Location S3Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:bucket:S3Location' :: Maybe Text
bucket = Maybe Text
a} :: S3Location)

-- | The name of the Amazon S3 object that represents the bundled artifacts
-- for the application revision.
s3Location_key :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_key :: (Maybe Text -> f (Maybe Text)) -> S3Location -> f S3Location
s3Location_key = (S3Location -> Maybe Text)
-> (S3Location -> Maybe Text -> S3Location)
-> Lens S3Location S3Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
key :: Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
key} -> Maybe Text
key) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:key:S3Location' :: Maybe Text
key = Maybe Text
a} :: S3Location)

-- | A specific version of the Amazon S3 object that represents the bundled
-- artifacts for the application revision.
--
-- If the version is not specified, the system uses the most recent version
-- by default.
s3Location_version :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_version :: (Maybe Text -> f (Maybe Text)) -> S3Location -> f S3Location
s3Location_version = (S3Location -> Maybe Text)
-> (S3Location -> Maybe Text -> S3Location)
-> Lens S3Location S3Location (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
version :: Maybe Text
$sel:version:S3Location' :: S3Location -> Maybe Text
version} -> Maybe Text
version) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:version:S3Location' :: Maybe Text
version = Maybe Text
a} :: S3Location)

instance Core.FromJSON S3Location where
  parseJSON :: Value -> Parser S3Location
parseJSON =
    String
-> (Object -> Parser S3Location) -> Value -> Parser S3Location
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Location"
      ( \Object
x ->
          Maybe BundleType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> S3Location
S3Location'
            (Maybe BundleType
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> S3Location)
-> Parser (Maybe BundleType)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> S3Location)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BundleType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bundleType")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> S3Location)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> S3Location)
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
"eTag")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> S3Location)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> S3Location)
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
"bucket")
            Parser (Maybe Text -> Maybe Text -> S3Location)
-> Parser (Maybe Text) -> Parser (Maybe Text -> S3Location)
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
"key")
            Parser (Maybe Text -> S3Location)
-> Parser (Maybe Text) -> Parser S3Location
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
"version")
      )

instance Prelude.Hashable S3Location

instance Prelude.NFData S3Location

instance Core.ToJSON S3Location where
  toJSON :: S3Location -> Value
toJSON S3Location' {Maybe Text
Maybe BundleType
version :: Maybe Text
key :: Maybe Text
bucket :: Maybe Text
eTag :: Maybe Text
bundleType :: Maybe BundleType
$sel:version:S3Location' :: S3Location -> Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
$sel:eTag:S3Location' :: S3Location -> Maybe Text
$sel:bundleType:S3Location' :: S3Location -> Maybe BundleType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"bundleType" Text -> BundleType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BundleType -> Pair) -> Maybe BundleType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BundleType
bundleType,
            (Text
"eTag" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
eTag,
            (Text
"bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucket,
            (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version
          ]
      )