{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateFunctionCode
-- 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)
--
-- Updates a Lambda function\'s code. If code signing is enabled for the
-- function, the code package must be signed by a trusted publisher. For
-- more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-trustedcode.html Configuring code signing>.
--
-- The function\'s code is locked when you publish a version. You can\'t
-- modify the code of a published version, only the unpublished version.
--
-- For a function defined as a container image, Lambda resolves the image
-- tag to an image digest. In Amazon ECR, if you update the image tag to a
-- new image, Lambda does not automatically update the function.
module Amazonka.Lambda.UpdateFunctionCode
  ( -- * Creating a Request
    UpdateFunctionCode (..),
    newUpdateFunctionCode,

    -- * Request Lenses
    updateFunctionCode_s3ObjectVersion,
    updateFunctionCode_s3Key,
    updateFunctionCode_zipFile,
    updateFunctionCode_architectures,
    updateFunctionCode_imageUri,
    updateFunctionCode_s3Bucket,
    updateFunctionCode_dryRun,
    updateFunctionCode_revisionId,
    updateFunctionCode_publish,
    updateFunctionCode_functionName,

    -- * Destructuring the Response
    FunctionConfiguration (..),
    newFunctionConfiguration,

    -- * Response Lenses
    functionConfiguration_memorySize,
    functionConfiguration_runtime,
    functionConfiguration_state,
    functionConfiguration_signingProfileVersionArn,
    functionConfiguration_lastUpdateStatus,
    functionConfiguration_functionArn,
    functionConfiguration_kmsKeyArn,
    functionConfiguration_packageType,
    functionConfiguration_fileSystemConfigs,
    functionConfiguration_environment,
    functionConfiguration_deadLetterConfig,
    functionConfiguration_architectures,
    functionConfiguration_signingJobArn,
    functionConfiguration_role,
    functionConfiguration_vpcConfig,
    functionConfiguration_version,
    functionConfiguration_functionName,
    functionConfiguration_layers,
    functionConfiguration_codeSize,
    functionConfiguration_handler,
    functionConfiguration_timeout,
    functionConfiguration_lastUpdateStatusReason,
    functionConfiguration_stateReason,
    functionConfiguration_lastModified,
    functionConfiguration_codeSha256,
    functionConfiguration_tracingConfig,
    functionConfiguration_stateReasonCode,
    functionConfiguration_imageConfigResponse,
    functionConfiguration_description,
    functionConfiguration_lastUpdateStatusReasonCode,
    functionConfiguration_revisionId,
    functionConfiguration_masterArn,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateFunctionCode' smart constructor.
data UpdateFunctionCode = UpdateFunctionCode'
  { -- | For versioned objects, the version of the deployment package object to
    -- use.
    UpdateFunctionCode -> Maybe Text
s3ObjectVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon S3 key of the deployment package.
    UpdateFunctionCode -> 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.
    UpdateFunctionCode -> Maybe (Sensitive Base64)
zipFile :: Prelude.Maybe (Core.Sensitive Core.Base64),
    -- | The instruction set architecture that the function supports. Enter a
    -- string array with one of the valid values. The default value is
    -- @x86_64@.
    UpdateFunctionCode -> Maybe (NonEmpty Architecture)
architectures :: Prelude.Maybe (Prelude.NonEmpty Architecture),
    -- | URI of a container image in the Amazon ECR registry.
    UpdateFunctionCode -> 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.
    UpdateFunctionCode -> Maybe Text
s3Bucket :: Prelude.Maybe Prelude.Text,
    -- | Set to true to validate the request parameters and access permissions
    -- without modifying the function code.
    UpdateFunctionCode -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | Only update the function if the revision ID matches the ID that\'s
    -- specified. Use this option to avoid modifying a function that has
    -- changed since you last read it.
    UpdateFunctionCode -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | Set to true to publish a new version of the function after updating the
    -- code. This has the same effect as calling PublishVersion separately.
    UpdateFunctionCode -> Maybe Bool
publish :: Prelude.Maybe Prelude.Bool,
    -- | The name of the Lambda function.
    --
    -- __Name formats__
    --
    -- -   __Function name__ - @my-function@.
    --
    -- -   __Function ARN__ -
    --     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
    --
    -- -   __Partial ARN__ - @123456789012:function:my-function@.
    --
    -- The length constraint applies only to the full ARN. If you specify only
    -- the function name, it is limited to 64 characters in length.
    UpdateFunctionCode -> Text
functionName :: Prelude.Text
  }
  deriving (UpdateFunctionCode -> UpdateFunctionCode -> Bool
(UpdateFunctionCode -> UpdateFunctionCode -> Bool)
-> (UpdateFunctionCode -> UpdateFunctionCode -> Bool)
-> Eq UpdateFunctionCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFunctionCode -> UpdateFunctionCode -> Bool
$c/= :: UpdateFunctionCode -> UpdateFunctionCode -> Bool
== :: UpdateFunctionCode -> UpdateFunctionCode -> Bool
$c== :: UpdateFunctionCode -> UpdateFunctionCode -> Bool
Prelude.Eq, Int -> UpdateFunctionCode -> ShowS
[UpdateFunctionCode] -> ShowS
UpdateFunctionCode -> String
(Int -> UpdateFunctionCode -> ShowS)
-> (UpdateFunctionCode -> String)
-> ([UpdateFunctionCode] -> ShowS)
-> Show UpdateFunctionCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFunctionCode] -> ShowS
$cshowList :: [UpdateFunctionCode] -> ShowS
show :: UpdateFunctionCode -> String
$cshow :: UpdateFunctionCode -> String
showsPrec :: Int -> UpdateFunctionCode -> ShowS
$cshowsPrec :: Int -> UpdateFunctionCode -> ShowS
Prelude.Show, (forall x. UpdateFunctionCode -> Rep UpdateFunctionCode x)
-> (forall x. Rep UpdateFunctionCode x -> UpdateFunctionCode)
-> Generic UpdateFunctionCode
forall x. Rep UpdateFunctionCode x -> UpdateFunctionCode
forall x. UpdateFunctionCode -> Rep UpdateFunctionCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFunctionCode x -> UpdateFunctionCode
$cfrom :: forall x. UpdateFunctionCode -> Rep UpdateFunctionCode x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFunctionCode' 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', 'updateFunctionCode_s3ObjectVersion' - For versioned objects, the version of the deployment package object to
-- use.
--
-- 's3Key', 'updateFunctionCode_s3Key' - The Amazon S3 key of the deployment package.
--
-- 'zipFile', 'updateFunctionCode_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.
--
-- 'architectures', 'updateFunctionCode_architectures' - The instruction set architecture that the function supports. Enter a
-- string array with one of the valid values. The default value is
-- @x86_64@.
--
-- 'imageUri', 'updateFunctionCode_imageUri' - URI of a container image in the Amazon ECR registry.
--
-- 's3Bucket', 'updateFunctionCode_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.
--
-- 'dryRun', 'updateFunctionCode_dryRun' - Set to true to validate the request parameters and access permissions
-- without modifying the function code.
--
-- 'revisionId', 'updateFunctionCode_revisionId' - Only update the function if the revision ID matches the ID that\'s
-- specified. Use this option to avoid modifying a function that has
-- changed since you last read it.
--
-- 'publish', 'updateFunctionCode_publish' - Set to true to publish a new version of the function after updating the
-- code. This has the same effect as calling PublishVersion separately.
--
-- 'functionName', 'updateFunctionCode_functionName' - The name of the Lambda function.
--
-- __Name formats__
--
-- -   __Function name__ - @my-function@.
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
--
-- -   __Partial ARN__ - @123456789012:function:my-function@.
--
-- The length constraint applies only to the full ARN. If you specify only
-- the function name, it is limited to 64 characters in length.
newUpdateFunctionCode ::
  -- | 'functionName'
  Prelude.Text ->
  UpdateFunctionCode
newUpdateFunctionCode :: Text -> UpdateFunctionCode
newUpdateFunctionCode Text
pFunctionName_ =
  UpdateFunctionCode' :: Maybe Text
-> Maybe Text
-> Maybe (Sensitive Base64)
-> Maybe (NonEmpty Architecture)
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Text
-> UpdateFunctionCode
UpdateFunctionCode'
    { $sel:s3ObjectVersion:UpdateFunctionCode' :: Maybe Text
s3ObjectVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Key:UpdateFunctionCode' :: Maybe Text
s3Key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:zipFile:UpdateFunctionCode' :: Maybe (Sensitive Base64)
zipFile = Maybe (Sensitive Base64)
forall a. Maybe a
Prelude.Nothing,
      $sel:architectures:UpdateFunctionCode' :: Maybe (NonEmpty Architecture)
architectures = Maybe (NonEmpty Architecture)
forall a. Maybe a
Prelude.Nothing,
      $sel:imageUri:UpdateFunctionCode' :: Maybe Text
imageUri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Bucket:UpdateFunctionCode' :: Maybe Text
s3Bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dryRun:UpdateFunctionCode' :: Maybe Bool
dryRun = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:UpdateFunctionCode' :: Maybe Text
revisionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:publish:UpdateFunctionCode' :: Maybe Bool
publish = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:functionName:UpdateFunctionCode' :: Text
functionName = Text
pFunctionName_
    }

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

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

-- | 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.
updateFunctionCode_zipFile :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe Prelude.ByteString)
updateFunctionCode_zipFile :: (Maybe ByteString -> f (Maybe ByteString))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_zipFile = (UpdateFunctionCode -> Maybe (Sensitive Base64))
-> (UpdateFunctionCode
    -> Maybe (Sensitive Base64) -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode
     UpdateFunctionCode
     (Maybe (Sensitive Base64))
     (Maybe (Sensitive Base64))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe (Sensitive Base64)
zipFile :: Maybe (Sensitive Base64)
$sel:zipFile:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (Sensitive Base64)
zipFile} -> Maybe (Sensitive Base64)
zipFile) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe (Sensitive Base64)
a -> UpdateFunctionCode
s {$sel:zipFile:UpdateFunctionCode' :: Maybe (Sensitive Base64)
zipFile = Maybe (Sensitive Base64)
a} :: UpdateFunctionCode) ((Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
 -> UpdateFunctionCode -> f UpdateFunctionCode)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe (Sensitive Base64) -> f (Maybe (Sensitive Base64)))
-> (Maybe ByteString -> f (Maybe ByteString))
-> UpdateFunctionCode
-> f UpdateFunctionCode
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)

-- | The instruction set architecture that the function supports. Enter a
-- string array with one of the valid values. The default value is
-- @x86_64@.
updateFunctionCode_architectures :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe (Prelude.NonEmpty Architecture))
updateFunctionCode_architectures :: (Maybe (NonEmpty Architecture)
 -> f (Maybe (NonEmpty Architecture)))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_architectures = (UpdateFunctionCode -> Maybe (NonEmpty Architecture))
-> (UpdateFunctionCode
    -> Maybe (NonEmpty Architecture) -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode
     UpdateFunctionCode
     (Maybe (NonEmpty Architecture))
     (Maybe (NonEmpty Architecture))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe (NonEmpty Architecture)
architectures :: Maybe (NonEmpty Architecture)
$sel:architectures:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (NonEmpty Architecture)
architectures} -> Maybe (NonEmpty Architecture)
architectures) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe (NonEmpty Architecture)
a -> UpdateFunctionCode
s {$sel:architectures:UpdateFunctionCode' :: Maybe (NonEmpty Architecture)
architectures = Maybe (NonEmpty Architecture)
a} :: UpdateFunctionCode) ((Maybe (NonEmpty Architecture)
  -> f (Maybe (NonEmpty Architecture)))
 -> UpdateFunctionCode -> f UpdateFunctionCode)
-> ((Maybe (NonEmpty Architecture)
     -> f (Maybe (NonEmpty Architecture)))
    -> Maybe (NonEmpty Architecture)
    -> f (Maybe (NonEmpty Architecture)))
-> (Maybe (NonEmpty Architecture)
    -> f (Maybe (NonEmpty Architecture)))
-> UpdateFunctionCode
-> f UpdateFunctionCode
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Architecture)
  (NonEmpty Architecture)
  (NonEmpty Architecture)
  (NonEmpty Architecture)
-> Iso
     (Maybe (NonEmpty Architecture))
     (Maybe (NonEmpty Architecture))
     (Maybe (NonEmpty Architecture))
     (Maybe (NonEmpty Architecture))
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 AnIso
  (NonEmpty Architecture)
  (NonEmpty Architecture)
  (NonEmpty Architecture)
  (NonEmpty Architecture)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | URI of a container image in the Amazon ECR registry.
updateFunctionCode_imageUri :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe Prelude.Text)
updateFunctionCode_imageUri :: (Maybe Text -> f (Maybe Text))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_imageUri = (UpdateFunctionCode -> Maybe Text)
-> (UpdateFunctionCode -> Maybe Text -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode UpdateFunctionCode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe Text
imageUri :: Maybe Text
$sel:imageUri:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
imageUri} -> Maybe Text
imageUri) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe Text
a -> UpdateFunctionCode
s {$sel:imageUri:UpdateFunctionCode' :: Maybe Text
imageUri = Maybe Text
a} :: UpdateFunctionCode)

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

-- | Set to true to validate the request parameters and access permissions
-- without modifying the function code.
updateFunctionCode_dryRun :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe Prelude.Bool)
updateFunctionCode_dryRun :: (Maybe Bool -> f (Maybe Bool))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_dryRun = (UpdateFunctionCode -> Maybe Bool)
-> (UpdateFunctionCode -> Maybe Bool -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode UpdateFunctionCode (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe Bool
a -> UpdateFunctionCode
s {$sel:dryRun:UpdateFunctionCode' :: Maybe Bool
dryRun = Maybe Bool
a} :: UpdateFunctionCode)

-- | Only update the function if the revision ID matches the ID that\'s
-- specified. Use this option to avoid modifying a function that has
-- changed since you last read it.
updateFunctionCode_revisionId :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe Prelude.Text)
updateFunctionCode_revisionId :: (Maybe Text -> f (Maybe Text))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_revisionId = (UpdateFunctionCode -> Maybe Text)
-> (UpdateFunctionCode -> Maybe Text -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode UpdateFunctionCode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe Text
a -> UpdateFunctionCode
s {$sel:revisionId:UpdateFunctionCode' :: Maybe Text
revisionId = Maybe Text
a} :: UpdateFunctionCode)

-- | Set to true to publish a new version of the function after updating the
-- code. This has the same effect as calling PublishVersion separately.
updateFunctionCode_publish :: Lens.Lens' UpdateFunctionCode (Prelude.Maybe Prelude.Bool)
updateFunctionCode_publish :: (Maybe Bool -> f (Maybe Bool))
-> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_publish = (UpdateFunctionCode -> Maybe Bool)
-> (UpdateFunctionCode -> Maybe Bool -> UpdateFunctionCode)
-> Lens
     UpdateFunctionCode UpdateFunctionCode (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Maybe Bool
publish :: Maybe Bool
$sel:publish:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
publish} -> Maybe Bool
publish) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Maybe Bool
a -> UpdateFunctionCode
s {$sel:publish:UpdateFunctionCode' :: Maybe Bool
publish = Maybe Bool
a} :: UpdateFunctionCode)

-- | The name of the Lambda function.
--
-- __Name formats__
--
-- -   __Function name__ - @my-function@.
--
-- -   __Function ARN__ -
--     @arn:aws:lambda:us-west-2:123456789012:function:my-function@.
--
-- -   __Partial ARN__ - @123456789012:function:my-function@.
--
-- The length constraint applies only to the full ARN. If you specify only
-- the function name, it is limited to 64 characters in length.
updateFunctionCode_functionName :: Lens.Lens' UpdateFunctionCode Prelude.Text
updateFunctionCode_functionName :: (Text -> f Text) -> UpdateFunctionCode -> f UpdateFunctionCode
updateFunctionCode_functionName = (UpdateFunctionCode -> Text)
-> (UpdateFunctionCode -> Text -> UpdateFunctionCode)
-> Lens UpdateFunctionCode UpdateFunctionCode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFunctionCode' {Text
functionName :: Text
$sel:functionName:UpdateFunctionCode' :: UpdateFunctionCode -> Text
functionName} -> Text
functionName) (\s :: UpdateFunctionCode
s@UpdateFunctionCode' {} Text
a -> UpdateFunctionCode
s {$sel:functionName:UpdateFunctionCode' :: Text
functionName = Text
a} :: UpdateFunctionCode)

instance Core.AWSRequest UpdateFunctionCode where
  type
    AWSResponse UpdateFunctionCode =
      FunctionConfiguration
  request :: UpdateFunctionCode -> Request UpdateFunctionCode
request = Service -> UpdateFunctionCode -> Request UpdateFunctionCode
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateFunctionCode
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateFunctionCode)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateFunctionCode))
-> Logger
-> Service
-> Proxy UpdateFunctionCode
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateFunctionCode)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String FunctionConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateFunctionCode

instance Prelude.NFData UpdateFunctionCode

instance Core.ToHeaders UpdateFunctionCode where
  toHeaders :: UpdateFunctionCode -> ResponseHeaders
toHeaders = ResponseHeaders -> UpdateFunctionCode -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON UpdateFunctionCode where
  toJSON :: UpdateFunctionCode -> Value
toJSON UpdateFunctionCode' {Maybe Bool
Maybe (NonEmpty Architecture)
Maybe Text
Maybe (Sensitive Base64)
Text
functionName :: Text
publish :: Maybe Bool
revisionId :: Maybe Text
dryRun :: Maybe Bool
s3Bucket :: Maybe Text
imageUri :: Maybe Text
architectures :: Maybe (NonEmpty Architecture)
zipFile :: Maybe (Sensitive Base64)
s3Key :: Maybe Text
s3ObjectVersion :: Maybe Text
$sel:functionName:UpdateFunctionCode' :: UpdateFunctionCode -> Text
$sel:publish:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
$sel:revisionId:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:dryRun:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
$sel:s3Bucket:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:imageUri:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:architectures:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (NonEmpty Architecture)
$sel:zipFile:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (Sensitive Base64)
$sel:s3Key:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:s3ObjectVersion:UpdateFunctionCode' :: UpdateFunctionCode -> 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
"Architectures" Text -> NonEmpty Architecture -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Architecture -> Pair)
-> Maybe (NonEmpty Architecture) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Architecture)
architectures,
            (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,
            (Text
"DryRun" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
dryRun,
            (Text
"RevisionId" 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
revisionId,
            (Text
"Publish" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
publish
          ]
      )

instance Core.ToPath UpdateFunctionCode where
  toPath :: UpdateFunctionCode -> ByteString
toPath UpdateFunctionCode' {Maybe Bool
Maybe (NonEmpty Architecture)
Maybe Text
Maybe (Sensitive Base64)
Text
functionName :: Text
publish :: Maybe Bool
revisionId :: Maybe Text
dryRun :: Maybe Bool
s3Bucket :: Maybe Text
imageUri :: Maybe Text
architectures :: Maybe (NonEmpty Architecture)
zipFile :: Maybe (Sensitive Base64)
s3Key :: Maybe Text
s3ObjectVersion :: Maybe Text
$sel:functionName:UpdateFunctionCode' :: UpdateFunctionCode -> Text
$sel:publish:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
$sel:revisionId:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:dryRun:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Bool
$sel:s3Bucket:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:imageUri:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:architectures:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (NonEmpty Architecture)
$sel:zipFile:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe (Sensitive Base64)
$sel:s3Key:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
$sel:s3ObjectVersion:UpdateFunctionCode' :: UpdateFunctionCode -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-03-31/functions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
functionName,
        ByteString
"/code"
      ]

instance Core.ToQuery UpdateFunctionCode where
  toQuery :: UpdateFunctionCode -> QueryString
toQuery = QueryString -> UpdateFunctionCode -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty