{-# 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-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.Lambda.Types.FunctionCode 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, upload a .zip file archive deployment package directly, or
-- specify the URI of a container image.
--
-- /See:/ 'newFunctionCode' smart constructor.
data FunctionCode = FunctionCode'
  { -- | For versioned objects, the version of the deployment package object to
    -- use.
    FunctionCode -> Maybe Text
s3ObjectVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 key of the deployment package.
    FunctionCode -> 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.
    FunctionCode -> Maybe (Sensitive Base64)
zipFile :: Prelude.Maybe (Core.Sensitive Core.Base64),
    -- | 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
  }
  deriving (FunctionCode -> FunctionCode -> Bool
(FunctionCode -> FunctionCode -> Bool)
-> (FunctionCode -> FunctionCode -> Bool) -> Eq FunctionCode
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
(Int -> FunctionCode -> ShowS)
-> (FunctionCode -> String)
-> ([FunctionCode] -> ShowS)
-> Show FunctionCode
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. FunctionCode -> Rep FunctionCode x)
-> (forall x. Rep FunctionCode x -> FunctionCode)
-> Generic FunctionCode
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:
--
-- 's3ObjectVersion', 'functionCode_s3ObjectVersion' - For versioned objects, the version of the deployment package object to
-- use.
--
-- 's3Key', 'functionCode_s3Key' - The Amazon S3 key of the deployment package.
--
-- 'zipFile', 'functionCode_zipFile' - The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and Amazon Web Services 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.
--
-- '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.
newFunctionCode ::
  FunctionCode
newFunctionCode :: FunctionCode
newFunctionCode =
  FunctionCode' :: Maybe Text
-> Maybe Text
-> Maybe (Sensitive Base64)
-> Maybe Text
-> Maybe Text
-> FunctionCode
FunctionCode'
    { $sel:s3ObjectVersion:FunctionCode' :: Maybe Text
s3ObjectVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Key:FunctionCode' :: Maybe Text
s3Key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:zipFile:FunctionCode' :: Maybe (Sensitive Base64)
zipFile = Maybe (Sensitive Base64)
forall a. Maybe a
Prelude.Nothing,
      $sel:imageUri:FunctionCode' :: Maybe Text
imageUri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:FunctionCode' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | For versioned objects, the version of the deployment package object to
-- use.
functionCode_s3ObjectVersion :: Lens.Lens' FunctionCode (Prelude.Maybe Prelude.Text)
functionCode_s3ObjectVersion :: (Maybe Text -> f (Maybe Text)) -> FunctionCode -> f FunctionCode
functionCode_s3ObjectVersion = (FunctionCode -> Maybe Text)
-> (FunctionCode -> Maybe Text -> FunctionCode)
-> Lens FunctionCode FunctionCode (Maybe Text) (Maybe Text)
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 Amazon S3 key of the deployment package.
functionCode_s3Key :: Lens.Lens' FunctionCode (Prelude.Maybe Prelude.Text)
functionCode_s3Key :: (Maybe Text -> f (Maybe Text)) -> FunctionCode -> f FunctionCode
functionCode_s3Key = (FunctionCode -> Maybe Text)
-> (FunctionCode -> Maybe Text -> FunctionCode)
-> Lens FunctionCode FunctionCode (Maybe Text) (Maybe Text)
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)

-- | The base64-encoded contents of the deployment package. Amazon Web
-- Services SDK and Amazon Web Services 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 :: (Maybe ByteString -> f (Maybe ByteString))
-> FunctionCode -> f FunctionCode
functionCode_zipFile = (FunctionCode -> Maybe (Sensitive Base64))
-> (FunctionCode -> Maybe (Sensitive Base64) -> FunctionCode)
-> Lens
     FunctionCode
     FunctionCode
     (Maybe (Sensitive Base64))
     (Maybe (Sensitive Base64))
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) ((Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
 -> FunctionCode -> f FunctionCode)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
-> (Maybe ByteString -> f (Maybe ByteString))
-> FunctionCode
-> f FunctionCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Base64) (Sensitive Base64) ByteString ByteString
-> Iso
     (Maybe (Sensitive Base64))
     (Maybe (Sensitive Base64))
     (Maybe ByteString)
     (Maybe ByteString)
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 (Exchange ByteString ByteString Base64 (Identity Base64)
-> Exchange
     ByteString
     ByteString
     (Sensitive Base64)
     (Identity (Sensitive Base64))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Exchange ByteString ByteString Base64 (Identity Base64)
 -> Exchange
      ByteString
      ByteString
      (Sensitive Base64)
      (Identity (Sensitive Base64)))
-> (Exchange ByteString ByteString ByteString (Identity ByteString)
    -> Exchange ByteString ByteString Base64 (Identity Base64))
-> AnIso
     (Sensitive Base64) (Sensitive Base64) ByteString ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange ByteString ByteString ByteString (Identity ByteString)
-> Exchange ByteString ByteString Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> FunctionCode -> f FunctionCode
functionCode_imageUri = (FunctionCode -> Maybe Text)
-> (FunctionCode -> Maybe Text -> FunctionCode)
-> Lens FunctionCode FunctionCode (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> FunctionCode -> f FunctionCode
functionCode_s3Bucket = (FunctionCode -> Maybe Text)
-> (FunctionCode -> Maybe Text -> FunctionCode)
-> Lens FunctionCode FunctionCode (Maybe Text) (Maybe Text)
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)

instance Prelude.Hashable FunctionCode

instance Prelude.NFData FunctionCode

instance Core.ToJSON FunctionCode where
  toJSON :: FunctionCode -> Value
toJSON FunctionCode' {Maybe Text
Maybe (Sensitive Base64)
s3Bucket :: Maybe Text
imageUri :: Maybe Text
zipFile :: Maybe (Sensitive Base64)
s3Key :: Maybe Text
s3ObjectVersion :: Maybe Text
$sel:s3Bucket:FunctionCode' :: FunctionCode -> Maybe Text
$sel:imageUri:FunctionCode' :: FunctionCode -> Maybe Text
$sel:zipFile:FunctionCode' :: FunctionCode -> Maybe (Sensitive Base64)
$sel:s3Key:FunctionCode' :: FunctionCode -> Maybe Text
$sel:s3ObjectVersion:FunctionCode' :: FunctionCode -> 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 -> Sensitive Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Base64 -> Pair)
-> Maybe (Sensitive Base64) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Base64)
zipFile,
            (Text
"ImageUri" 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
imageUri,
            (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
          ]
      )