{-# 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.Signer.Types.S3Source
-- 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.Signer.Types.S3Source where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the S3 bucket where you saved your unsigned code.
--
-- /See:/ 'newS3Source' smart constructor.
data S3Source = S3Source'
  { -- | Name of the S3 bucket.
    S3Source -> Text
bucketName :: Prelude.Text,
    -- | Key name of the bucket object that contains your unsigned code.
    S3Source -> Text
key :: Prelude.Text,
    -- | Version of your source image in your version enabled S3 bucket.
    S3Source -> Text
version :: Prelude.Text
  }
  deriving (S3Source -> S3Source -> Bool
(S3Source -> S3Source -> Bool)
-> (S3Source -> S3Source -> Bool) -> Eq S3Source
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Source -> S3Source -> Bool
$c/= :: S3Source -> S3Source -> Bool
== :: S3Source -> S3Source -> Bool
$c== :: S3Source -> S3Source -> Bool
Prelude.Eq, ReadPrec [S3Source]
ReadPrec S3Source
Int -> ReadS S3Source
ReadS [S3Source]
(Int -> ReadS S3Source)
-> ReadS [S3Source]
-> ReadPrec S3Source
-> ReadPrec [S3Source]
-> Read S3Source
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Source]
$creadListPrec :: ReadPrec [S3Source]
readPrec :: ReadPrec S3Source
$creadPrec :: ReadPrec S3Source
readList :: ReadS [S3Source]
$creadList :: ReadS [S3Source]
readsPrec :: Int -> ReadS S3Source
$creadsPrec :: Int -> ReadS S3Source
Prelude.Read, Int -> S3Source -> ShowS
[S3Source] -> ShowS
S3Source -> String
(Int -> S3Source -> ShowS)
-> (S3Source -> String) -> ([S3Source] -> ShowS) -> Show S3Source
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Source] -> ShowS
$cshowList :: [S3Source] -> ShowS
show :: S3Source -> String
$cshow :: S3Source -> String
showsPrec :: Int -> S3Source -> ShowS
$cshowsPrec :: Int -> S3Source -> ShowS
Prelude.Show, (forall x. S3Source -> Rep S3Source x)
-> (forall x. Rep S3Source x -> S3Source) -> Generic S3Source
forall x. Rep S3Source x -> S3Source
forall x. S3Source -> Rep S3Source x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Source x -> S3Source
$cfrom :: forall x. S3Source -> Rep S3Source x
Prelude.Generic)

-- |
-- Create a value of 'S3Source' 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:
--
-- 'bucketName', 's3Source_bucketName' - Name of the S3 bucket.
--
-- 'key', 's3Source_key' - Key name of the bucket object that contains your unsigned code.
--
-- 'version', 's3Source_version' - Version of your source image in your version enabled S3 bucket.
newS3Source ::
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  -- | 'version'
  Prelude.Text ->
  S3Source
newS3Source :: Text -> Text -> Text -> S3Source
newS3Source Text
pBucketName_ Text
pKey_ Text
pVersion_ =
  S3Source' :: Text -> Text -> Text -> S3Source
S3Source'
    { $sel:bucketName:S3Source' :: Text
bucketName = Text
pBucketName_,
      $sel:key:S3Source' :: Text
key = Text
pKey_,
      $sel:version:S3Source' :: Text
version = Text
pVersion_
    }

-- | Name of the S3 bucket.
s3Source_bucketName :: Lens.Lens' S3Source Prelude.Text
s3Source_bucketName :: (Text -> f Text) -> S3Source -> f S3Source
s3Source_bucketName = (S3Source -> Text)
-> (S3Source -> Text -> S3Source)
-> Lens S3Source S3Source Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {Text
bucketName :: Text
$sel:bucketName:S3Source' :: S3Source -> Text
bucketName} -> Text
bucketName) (\s :: S3Source
s@S3Source' {} Text
a -> S3Source
s {$sel:bucketName:S3Source' :: Text
bucketName = Text
a} :: S3Source)

-- | Key name of the bucket object that contains your unsigned code.
s3Source_key :: Lens.Lens' S3Source Prelude.Text
s3Source_key :: (Text -> f Text) -> S3Source -> f S3Source
s3Source_key = (S3Source -> Text)
-> (S3Source -> Text -> S3Source)
-> Lens S3Source S3Source Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {Text
key :: Text
$sel:key:S3Source' :: S3Source -> Text
key} -> Text
key) (\s :: S3Source
s@S3Source' {} Text
a -> S3Source
s {$sel:key:S3Source' :: Text
key = Text
a} :: S3Source)

-- | Version of your source image in your version enabled S3 bucket.
s3Source_version :: Lens.Lens' S3Source Prelude.Text
s3Source_version :: (Text -> f Text) -> S3Source -> f S3Source
s3Source_version = (S3Source -> Text)
-> (S3Source -> Text -> S3Source)
-> Lens S3Source S3Source Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {Text
version :: Text
$sel:version:S3Source' :: S3Source -> Text
version} -> Text
version) (\s :: S3Source
s@S3Source' {} Text
a -> S3Source
s {$sel:version:S3Source' :: Text
version = Text
a} :: S3Source)

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

instance Prelude.Hashable S3Source

instance Prelude.NFData S3Source

instance Core.ToJSON S3Source where
  toJSON :: S3Source -> Value
toJSON S3Source' {Text
version :: Text
key :: Text
bucketName :: Text
$sel:version:S3Source' :: S3Source -> Text
$sel:key:S3Source' :: S3Source -> Text
$sel:bucketName:S3Source' :: S3Source -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bucketName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
version)
          ]
      )