{-# 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.SecurityHub.Types.AwsLambdaFunctionCode
-- 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.SecurityHub.Types.AwsLambdaFunctionCode where

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

-- | The code for the Lambda function. You can specify either an object in
-- Amazon S3, or upload a deployment package directly.
--
-- /See:/ 'newAwsLambdaFunctionCode' smart constructor.
data AwsLambdaFunctionCode = AwsLambdaFunctionCode'
  { -- | For versioned objects, the version of the deployment package object to
    -- use.
    AwsLambdaFunctionCode -> Maybe Text
s3ObjectVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 key of the deployment package.
    AwsLambdaFunctionCode -> Maybe Text
s3Key :: Prelude.Maybe Prelude.Text,
    -- | The base64-encoded contents of the deployment package. Amazon Web
    -- Services SDK and Amazon Web Services CLI clients handle the encoding for
    -- you.
    AwsLambdaFunctionCode -> Maybe Text
zipFile :: Prelude.Maybe Prelude.Text,
    -- | An Amazon S3 bucket in the same Amazon Web Services Region as your
    -- function. The bucket can be in a different Amazon Web Services account.
    AwsLambdaFunctionCode -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool
(AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool)
-> (AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool)
-> Eq AwsLambdaFunctionCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool
$c/= :: AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool
== :: AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool
$c== :: AwsLambdaFunctionCode -> AwsLambdaFunctionCode -> Bool
Prelude.Eq, ReadPrec [AwsLambdaFunctionCode]
ReadPrec AwsLambdaFunctionCode
Int -> ReadS AwsLambdaFunctionCode
ReadS [AwsLambdaFunctionCode]
(Int -> ReadS AwsLambdaFunctionCode)
-> ReadS [AwsLambdaFunctionCode]
-> ReadPrec AwsLambdaFunctionCode
-> ReadPrec [AwsLambdaFunctionCode]
-> Read AwsLambdaFunctionCode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsLambdaFunctionCode]
$creadListPrec :: ReadPrec [AwsLambdaFunctionCode]
readPrec :: ReadPrec AwsLambdaFunctionCode
$creadPrec :: ReadPrec AwsLambdaFunctionCode
readList :: ReadS [AwsLambdaFunctionCode]
$creadList :: ReadS [AwsLambdaFunctionCode]
readsPrec :: Int -> ReadS AwsLambdaFunctionCode
$creadsPrec :: Int -> ReadS AwsLambdaFunctionCode
Prelude.Read, Int -> AwsLambdaFunctionCode -> ShowS
[AwsLambdaFunctionCode] -> ShowS
AwsLambdaFunctionCode -> String
(Int -> AwsLambdaFunctionCode -> ShowS)
-> (AwsLambdaFunctionCode -> String)
-> ([AwsLambdaFunctionCode] -> ShowS)
-> Show AwsLambdaFunctionCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsLambdaFunctionCode] -> ShowS
$cshowList :: [AwsLambdaFunctionCode] -> ShowS
show :: AwsLambdaFunctionCode -> String
$cshow :: AwsLambdaFunctionCode -> String
showsPrec :: Int -> AwsLambdaFunctionCode -> ShowS
$cshowsPrec :: Int -> AwsLambdaFunctionCode -> ShowS
Prelude.Show, (forall x. AwsLambdaFunctionCode -> Rep AwsLambdaFunctionCode x)
-> (forall x. Rep AwsLambdaFunctionCode x -> AwsLambdaFunctionCode)
-> Generic AwsLambdaFunctionCode
forall x. Rep AwsLambdaFunctionCode x -> AwsLambdaFunctionCode
forall x. AwsLambdaFunctionCode -> Rep AwsLambdaFunctionCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsLambdaFunctionCode x -> AwsLambdaFunctionCode
$cfrom :: forall x. AwsLambdaFunctionCode -> Rep AwsLambdaFunctionCode x
Prelude.Generic)

-- |
-- Create a value of 'AwsLambdaFunctionCode' 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:
--
-- 's3ObjectVersion', 'awsLambdaFunctionCode_s3ObjectVersion' - For versioned objects, the version of the deployment package object to
-- use.
--
-- 's3Key', 'awsLambdaFunctionCode_s3Key' - The Amazon S3 key of the deployment package.
--
-- 'zipFile', 'awsLambdaFunctionCode_zipFile' - The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and Amazon Web Services CLI clients handle the encoding for
-- you.
--
-- 's3Bucket', 'awsLambdaFunctionCode_s3Bucket' - An Amazon S3 bucket in the same Amazon Web Services Region as your
-- function. The bucket can be in a different Amazon Web Services account.
newAwsLambdaFunctionCode ::
  AwsLambdaFunctionCode
newAwsLambdaFunctionCode :: AwsLambdaFunctionCode
newAwsLambdaFunctionCode =
  AwsLambdaFunctionCode' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AwsLambdaFunctionCode
AwsLambdaFunctionCode'
    { $sel:s3ObjectVersion:AwsLambdaFunctionCode' :: Maybe Text
s3ObjectVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Key:AwsLambdaFunctionCode' :: Maybe Text
s3Key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:zipFile:AwsLambdaFunctionCode' :: Maybe Text
zipFile = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:AwsLambdaFunctionCode' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | For versioned objects, the version of the deployment package object to
-- use.
awsLambdaFunctionCode_s3ObjectVersion :: Lens.Lens' AwsLambdaFunctionCode (Prelude.Maybe Prelude.Text)
awsLambdaFunctionCode_s3ObjectVersion :: (Maybe Text -> f (Maybe Text))
-> AwsLambdaFunctionCode -> f AwsLambdaFunctionCode
awsLambdaFunctionCode_s3ObjectVersion = (AwsLambdaFunctionCode -> Maybe Text)
-> (AwsLambdaFunctionCode -> Maybe Text -> AwsLambdaFunctionCode)
-> Lens
     AwsLambdaFunctionCode
     AwsLambdaFunctionCode
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionCode' {Maybe Text
s3ObjectVersion :: Maybe Text
$sel:s3ObjectVersion:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
s3ObjectVersion} -> Maybe Text
s3ObjectVersion) (\s :: AwsLambdaFunctionCode
s@AwsLambdaFunctionCode' {} Maybe Text
a -> AwsLambdaFunctionCode
s {$sel:s3ObjectVersion:AwsLambdaFunctionCode' :: Maybe Text
s3ObjectVersion = Maybe Text
a} :: AwsLambdaFunctionCode)

-- | The Amazon S3 key of the deployment package.
awsLambdaFunctionCode_s3Key :: Lens.Lens' AwsLambdaFunctionCode (Prelude.Maybe Prelude.Text)
awsLambdaFunctionCode_s3Key :: (Maybe Text -> f (Maybe Text))
-> AwsLambdaFunctionCode -> f AwsLambdaFunctionCode
awsLambdaFunctionCode_s3Key = (AwsLambdaFunctionCode -> Maybe Text)
-> (AwsLambdaFunctionCode -> Maybe Text -> AwsLambdaFunctionCode)
-> Lens
     AwsLambdaFunctionCode
     AwsLambdaFunctionCode
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionCode' {Maybe Text
s3Key :: Maybe Text
$sel:s3Key:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
s3Key} -> Maybe Text
s3Key) (\s :: AwsLambdaFunctionCode
s@AwsLambdaFunctionCode' {} Maybe Text
a -> AwsLambdaFunctionCode
s {$sel:s3Key:AwsLambdaFunctionCode' :: Maybe Text
s3Key = Maybe Text
a} :: AwsLambdaFunctionCode)

-- | The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and Amazon Web Services CLI clients handle the encoding for
-- you.
awsLambdaFunctionCode_zipFile :: Lens.Lens' AwsLambdaFunctionCode (Prelude.Maybe Prelude.Text)
awsLambdaFunctionCode_zipFile :: (Maybe Text -> f (Maybe Text))
-> AwsLambdaFunctionCode -> f AwsLambdaFunctionCode
awsLambdaFunctionCode_zipFile = (AwsLambdaFunctionCode -> Maybe Text)
-> (AwsLambdaFunctionCode -> Maybe Text -> AwsLambdaFunctionCode)
-> Lens
     AwsLambdaFunctionCode
     AwsLambdaFunctionCode
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionCode' {Maybe Text
zipFile :: Maybe Text
$sel:zipFile:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
zipFile} -> Maybe Text
zipFile) (\s :: AwsLambdaFunctionCode
s@AwsLambdaFunctionCode' {} Maybe Text
a -> AwsLambdaFunctionCode
s {$sel:zipFile:AwsLambdaFunctionCode' :: Maybe Text
zipFile = Maybe Text
a} :: AwsLambdaFunctionCode)

-- | An Amazon S3 bucket in the same Amazon Web Services Region as your
-- function. The bucket can be in a different Amazon Web Services account.
awsLambdaFunctionCode_s3Bucket :: Lens.Lens' AwsLambdaFunctionCode (Prelude.Maybe Prelude.Text)
awsLambdaFunctionCode_s3Bucket :: (Maybe Text -> f (Maybe Text))
-> AwsLambdaFunctionCode -> f AwsLambdaFunctionCode
awsLambdaFunctionCode_s3Bucket = (AwsLambdaFunctionCode -> Maybe Text)
-> (AwsLambdaFunctionCode -> Maybe Text -> AwsLambdaFunctionCode)
-> Lens
     AwsLambdaFunctionCode
     AwsLambdaFunctionCode
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsLambdaFunctionCode' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: AwsLambdaFunctionCode
s@AwsLambdaFunctionCode' {} Maybe Text
a -> AwsLambdaFunctionCode
s {$sel:s3Bucket:AwsLambdaFunctionCode' :: Maybe Text
s3Bucket = Maybe Text
a} :: AwsLambdaFunctionCode)

instance Core.FromJSON AwsLambdaFunctionCode where
  parseJSON :: Value -> Parser AwsLambdaFunctionCode
parseJSON =
    String
-> (Object -> Parser AwsLambdaFunctionCode)
-> Value
-> Parser AwsLambdaFunctionCode
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsLambdaFunctionCode"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> AwsLambdaFunctionCode
AwsLambdaFunctionCode'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> AwsLambdaFunctionCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> AwsLambdaFunctionCode)
forall (f :: * -> *) a b. Functor 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
"S3ObjectVersion")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> AwsLambdaFunctionCode)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AwsLambdaFunctionCode)
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
"S3Key")
            Parser (Maybe Text -> Maybe Text -> AwsLambdaFunctionCode)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsLambdaFunctionCode)
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
"ZipFile")
            Parser (Maybe Text -> AwsLambdaFunctionCode)
-> Parser (Maybe Text) -> Parser AwsLambdaFunctionCode
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
"S3Bucket")
      )

instance Prelude.Hashable AwsLambdaFunctionCode

instance Prelude.NFData AwsLambdaFunctionCode

instance Core.ToJSON AwsLambdaFunctionCode where
  toJSON :: AwsLambdaFunctionCode -> Value
toJSON AwsLambdaFunctionCode' {Maybe Text
s3Bucket :: Maybe Text
zipFile :: Maybe Text
s3Key :: Maybe Text
s3ObjectVersion :: Maybe Text
$sel:s3Bucket:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
$sel:zipFile:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
$sel:s3Key:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
$sel:s3ObjectVersion:AwsLambdaFunctionCode' :: AwsLambdaFunctionCode -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3ObjectVersion" 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
s3ObjectVersion,
            (Text
"S3Key" 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
s3Key,
            (Text
"ZipFile" 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
zipFile,
            (Text
"S3Bucket" 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
s3Bucket
          ]
      )