{-# 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.Lambda.Types.FunctionCode
-- 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.Lambda.Types.FunctionCode 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

-- | The code for the Lambda function. You can either specify an object in
-- Amazon S3, upload a .zip file archive deployment package directly, or
-- specify the URI of a container image.
--
-- /See:/ 'newFunctionCode' smart constructor.
data FunctionCode = FunctionCode'
  { -- | URI of a
    -- <https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html container image>
    -- in the Amazon ECR registry.
    FunctionCode -> Maybe Text
imageUri :: 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.
    FunctionCode -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 key of the deployment package.
    FunctionCode -> Maybe Text
s3Key :: Prelude.Maybe Prelude.Text,
    -- | For versioned objects, the version of the deployment package object to
    -- use.
    FunctionCode -> Maybe Text
s3ObjectVersion :: Prelude.Maybe Prelude.Text,
    -- | The base64-encoded contents of the deployment package. Amazon Web
    -- Services SDK and CLI clients handle the encoding for you.
    FunctionCode -> Maybe (Sensitive Base64)
zipFile :: Prelude.Maybe (Data.Sensitive Data.Base64)
  }
  deriving (FunctionCode -> FunctionCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionCode -> FunctionCode -> Bool
$c/= :: FunctionCode -> FunctionCode -> Bool
== :: FunctionCode -> FunctionCode -> Bool
$c== :: FunctionCode -> FunctionCode -> Bool
Prelude.Eq, Int -> FunctionCode -> ShowS
[FunctionCode] -> ShowS
FunctionCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionCode] -> ShowS
$cshowList :: [FunctionCode] -> ShowS
show :: FunctionCode -> String
$cshow :: FunctionCode -> String
showsPrec :: Int -> FunctionCode -> ShowS
$cshowsPrec :: Int -> FunctionCode -> ShowS
Prelude.Show, forall x. Rep FunctionCode x -> FunctionCode
forall x. FunctionCode -> Rep FunctionCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionCode x -> FunctionCode
$cfrom :: forall x. FunctionCode -> Rep FunctionCode x
Prelude.Generic)

-- |
-- Create a value of 'FunctionCode' 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:
--
-- 'imageUri', 'functionCode_imageUri' - URI of a
-- <https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html container image>
-- in the Amazon ECR registry.
--
-- 's3Bucket', 'functionCode_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.
--
-- 's3Key', 'functionCode_s3Key' - The Amazon S3 key of the deployment package.
--
-- 's3ObjectVersion', 'functionCode_s3ObjectVersion' - For versioned objects, the version of the deployment package object to
-- use.
--
-- 'zipFile', 'functionCode_zipFile' - The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and CLI clients handle the encoding for you.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
newFunctionCode ::
  FunctionCode
newFunctionCode :: FunctionCode
newFunctionCode =
  FunctionCode'
    { $sel:imageUri:FunctionCode' :: Maybe Text
imageUri = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:FunctionCode' :: Maybe Text
s3Bucket = forall a. Maybe a
Prelude.Nothing,
      $sel:s3Key:FunctionCode' :: Maybe Text
s3Key = forall a. Maybe a
Prelude.Nothing,
      $sel:s3ObjectVersion:FunctionCode' :: Maybe Text
s3ObjectVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:zipFile:FunctionCode' :: Maybe (Sensitive Base64)
zipFile = forall a. Maybe a
Prelude.Nothing
    }

-- | URI of a
-- <https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html container image>
-- in the Amazon ECR registry.
functionCode_imageUri :: Lens.Lens' FunctionCode (Prelude.Maybe Prelude.Text)
functionCode_imageUri :: Lens' FunctionCode (Maybe Text)
functionCode_imageUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionCode' {Maybe Text
imageUri :: Maybe Text
$sel:imageUri:FunctionCode' :: FunctionCode -> Maybe Text
imageUri} -> Maybe Text
imageUri) (\s :: FunctionCode
s@FunctionCode' {} Maybe Text
a -> FunctionCode
s {$sel:imageUri:FunctionCode' :: Maybe Text
imageUri = Maybe Text
a} :: FunctionCode)

-- | 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.
functionCode_s3Bucket :: Lens.Lens' FunctionCode (Prelude.Maybe Prelude.Text)
functionCode_s3Bucket :: Lens' FunctionCode (Maybe Text)
functionCode_s3Bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionCode' {Maybe Text
s3Bucket :: Maybe Text
$sel:s3Bucket:FunctionCode' :: FunctionCode -> Maybe Text
s3Bucket} -> Maybe Text
s3Bucket) (\s :: FunctionCode
s@FunctionCode' {} Maybe Text
a -> FunctionCode
s {$sel:s3Bucket:FunctionCode' :: Maybe Text
s3Bucket = Maybe Text
a} :: FunctionCode)

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

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

-- | The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and CLI clients handle the encoding for you.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
functionCode_zipFile :: Lens.Lens' FunctionCode (Prelude.Maybe Prelude.ByteString)
functionCode_zipFile :: Lens' FunctionCode (Maybe ByteString)
functionCode_zipFile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionCode' {Maybe (Sensitive Base64)
zipFile :: Maybe (Sensitive Base64)
$sel:zipFile:FunctionCode' :: FunctionCode -> Maybe (Sensitive Base64)
zipFile} -> Maybe (Sensitive Base64)
zipFile) (\s :: FunctionCode
s@FunctionCode' {} Maybe (Sensitive Base64)
a -> FunctionCode
s {$sel:zipFile:FunctionCode' :: Maybe (Sensitive Base64)
zipFile = Maybe (Sensitive Base64)
a} :: FunctionCode) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping (forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64)

instance Prelude.Hashable FunctionCode where
  hashWithSalt :: Int -> FunctionCode -> Int
hashWithSalt Int
_salt FunctionCode' {Maybe Text
Maybe (Sensitive Base64)
zipFile :: Maybe (Sensitive Base64)
s3ObjectVersion :: Maybe Text
s3Key :: Maybe Text
s3Bucket :: Maybe Text
imageUri :: Maybe Text
$sel:zipFile:FunctionCode' :: FunctionCode -> Maybe (Sensitive Base64)
$sel:s3ObjectVersion:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Key:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Bucket:FunctionCode' :: FunctionCode -> Maybe Text
$sel:imageUri:FunctionCode' :: FunctionCode -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
imageUri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3Bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3Key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3ObjectVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Base64)
zipFile

instance Prelude.NFData FunctionCode where
  rnf :: FunctionCode -> ()
rnf FunctionCode' {Maybe Text
Maybe (Sensitive Base64)
zipFile :: Maybe (Sensitive Base64)
s3ObjectVersion :: Maybe Text
s3Key :: Maybe Text
s3Bucket :: Maybe Text
imageUri :: Maybe Text
$sel:zipFile:FunctionCode' :: FunctionCode -> Maybe (Sensitive Base64)
$sel:s3ObjectVersion:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Key:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Bucket:FunctionCode' :: FunctionCode -> Maybe Text
$sel:imageUri:FunctionCode' :: FunctionCode -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imageUri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3Bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3Key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3ObjectVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Base64)
zipFile

instance Data.ToJSON FunctionCode where
  toJSON :: FunctionCode -> Value
toJSON FunctionCode' {Maybe Text
Maybe (Sensitive Base64)
zipFile :: Maybe (Sensitive Base64)
s3ObjectVersion :: Maybe Text
s3Key :: Maybe Text
s3Bucket :: Maybe Text
imageUri :: Maybe Text
$sel:zipFile:FunctionCode' :: FunctionCode -> Maybe (Sensitive Base64)
$sel:s3ObjectVersion:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Key:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3Bucket:FunctionCode' :: FunctionCode -> Maybe Text
$sel:imageUri:FunctionCode' :: FunctionCode -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ImageUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
imageUri,
            (Key
"S3Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
s3Bucket,
            (Key
"S3Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
s3Key,
            (Key
"S3ObjectVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
s3ObjectVersion,
            (Key
"ZipFile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Base64)
zipFile
          ]
      )