{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Signer.Types.S3Source where

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

-- | 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
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]
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
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. 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'
    { $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 :: Lens' S3Source Text
s3Source_bucketName = 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 :: Lens' S3Source Text
s3Source_key = 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 :: Lens' S3Source Text
s3Source_version = 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 Data.FromJSON S3Source where
  parseJSON :: Value -> Parser S3Source
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Source"
      ( \Object
x ->
          Text -> Text -> Text -> S3Source
S3Source'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"bucketName")
            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
"key")
            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
"version")
      )

instance Prelude.Hashable S3Source where
  hashWithSalt :: Int -> S3Source -> Int
hashWithSalt Int
_salt S3Source' {Text
version :: Text
key :: Text
bucketName :: Text
$sel:version:S3Source' :: S3Source -> Text
$sel:key:S3Source' :: S3Source -> Text
$sel:bucketName:S3Source' :: S3Source -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
version

instance Prelude.NFData S3Source where
  rnf :: S3Source -> ()
rnf S3Source' {Text
version :: Text
key :: Text
bucketName :: Text
$sel:version:S3Source' :: S3Source -> Text
$sel:key:S3Source' :: S3Source -> Text
$sel:bucketName:S3Source' :: S3Source -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
version

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"bucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
            forall a. a -> Maybe a
Prelude.Just (Key
"version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
version)
          ]
      )