{-# 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.CodeSigningPolicies
-- 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.CodeSigningPolicies where

import qualified Amazonka.Core as Core
import Amazonka.Lambda.Types.CodeSigningPolicy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Code signing configuration
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html#config-codesigning-policies policies>
-- specify the validation failure action for signature mismatch or expiry.
--
-- /See:/ 'newCodeSigningPolicies' smart constructor.
data CodeSigningPolicies = CodeSigningPolicies'
  { -- | Code signing configuration policy for deployment validation failure. If
    -- you set the policy to @Enforce@, Lambda blocks the deployment request if
    -- signature validation checks fail. If you set the policy to @Warn@,
    -- Lambda allows the deployment and creates a CloudWatch log.
    --
    -- Default value: @Warn@
    CodeSigningPolicies -> Maybe CodeSigningPolicy
untrustedArtifactOnDeployment :: Prelude.Maybe CodeSigningPolicy
  }
  deriving (CodeSigningPolicies -> CodeSigningPolicies -> Bool
(CodeSigningPolicies -> CodeSigningPolicies -> Bool)
-> (CodeSigningPolicies -> CodeSigningPolicies -> Bool)
-> Eq CodeSigningPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeSigningPolicies -> CodeSigningPolicies -> Bool
$c/= :: CodeSigningPolicies -> CodeSigningPolicies -> Bool
== :: CodeSigningPolicies -> CodeSigningPolicies -> Bool
$c== :: CodeSigningPolicies -> CodeSigningPolicies -> Bool
Prelude.Eq, ReadPrec [CodeSigningPolicies]
ReadPrec CodeSigningPolicies
Int -> ReadS CodeSigningPolicies
ReadS [CodeSigningPolicies]
(Int -> ReadS CodeSigningPolicies)
-> ReadS [CodeSigningPolicies]
-> ReadPrec CodeSigningPolicies
-> ReadPrec [CodeSigningPolicies]
-> Read CodeSigningPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeSigningPolicies]
$creadListPrec :: ReadPrec [CodeSigningPolicies]
readPrec :: ReadPrec CodeSigningPolicies
$creadPrec :: ReadPrec CodeSigningPolicies
readList :: ReadS [CodeSigningPolicies]
$creadList :: ReadS [CodeSigningPolicies]
readsPrec :: Int -> ReadS CodeSigningPolicies
$creadsPrec :: Int -> ReadS CodeSigningPolicies
Prelude.Read, Int -> CodeSigningPolicies -> ShowS
[CodeSigningPolicies] -> ShowS
CodeSigningPolicies -> String
(Int -> CodeSigningPolicies -> ShowS)
-> (CodeSigningPolicies -> String)
-> ([CodeSigningPolicies] -> ShowS)
-> Show CodeSigningPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeSigningPolicies] -> ShowS
$cshowList :: [CodeSigningPolicies] -> ShowS
show :: CodeSigningPolicies -> String
$cshow :: CodeSigningPolicies -> String
showsPrec :: Int -> CodeSigningPolicies -> ShowS
$cshowsPrec :: Int -> CodeSigningPolicies -> ShowS
Prelude.Show, (forall x. CodeSigningPolicies -> Rep CodeSigningPolicies x)
-> (forall x. Rep CodeSigningPolicies x -> CodeSigningPolicies)
-> Generic CodeSigningPolicies
forall x. Rep CodeSigningPolicies x -> CodeSigningPolicies
forall x. CodeSigningPolicies -> Rep CodeSigningPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeSigningPolicies x -> CodeSigningPolicies
$cfrom :: forall x. CodeSigningPolicies -> Rep CodeSigningPolicies x
Prelude.Generic)

-- |
-- Create a value of 'CodeSigningPolicies' 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:
--
-- 'untrustedArtifactOnDeployment', 'codeSigningPolicies_untrustedArtifactOnDeployment' - Code signing configuration policy for deployment validation failure. If
-- you set the policy to @Enforce@, Lambda blocks the deployment request if
-- signature validation checks fail. If you set the policy to @Warn@,
-- Lambda allows the deployment and creates a CloudWatch log.
--
-- Default value: @Warn@
newCodeSigningPolicies ::
  CodeSigningPolicies
newCodeSigningPolicies :: CodeSigningPolicies
newCodeSigningPolicies =
  CodeSigningPolicies' :: Maybe CodeSigningPolicy -> CodeSigningPolicies
CodeSigningPolicies'
    { $sel:untrustedArtifactOnDeployment:CodeSigningPolicies' :: Maybe CodeSigningPolicy
untrustedArtifactOnDeployment =
        Maybe CodeSigningPolicy
forall a. Maybe a
Prelude.Nothing
    }

-- | Code signing configuration policy for deployment validation failure. If
-- you set the policy to @Enforce@, Lambda blocks the deployment request if
-- signature validation checks fail. If you set the policy to @Warn@,
-- Lambda allows the deployment and creates a CloudWatch log.
--
-- Default value: @Warn@
codeSigningPolicies_untrustedArtifactOnDeployment :: Lens.Lens' CodeSigningPolicies (Prelude.Maybe CodeSigningPolicy)
codeSigningPolicies_untrustedArtifactOnDeployment :: (Maybe CodeSigningPolicy -> f (Maybe CodeSigningPolicy))
-> CodeSigningPolicies -> f CodeSigningPolicies
codeSigningPolicies_untrustedArtifactOnDeployment = (CodeSigningPolicies -> Maybe CodeSigningPolicy)
-> (CodeSigningPolicies
    -> Maybe CodeSigningPolicy -> CodeSigningPolicies)
-> Lens
     CodeSigningPolicies
     CodeSigningPolicies
     (Maybe CodeSigningPolicy)
     (Maybe CodeSigningPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigningPolicies' {Maybe CodeSigningPolicy
untrustedArtifactOnDeployment :: Maybe CodeSigningPolicy
$sel:untrustedArtifactOnDeployment:CodeSigningPolicies' :: CodeSigningPolicies -> Maybe CodeSigningPolicy
untrustedArtifactOnDeployment} -> Maybe CodeSigningPolicy
untrustedArtifactOnDeployment) (\s :: CodeSigningPolicies
s@CodeSigningPolicies' {} Maybe CodeSigningPolicy
a -> CodeSigningPolicies
s {$sel:untrustedArtifactOnDeployment:CodeSigningPolicies' :: Maybe CodeSigningPolicy
untrustedArtifactOnDeployment = Maybe CodeSigningPolicy
a} :: CodeSigningPolicies)

instance Core.FromJSON CodeSigningPolicies where
  parseJSON :: Value -> Parser CodeSigningPolicies
parseJSON =
    String
-> (Object -> Parser CodeSigningPolicies)
-> Value
-> Parser CodeSigningPolicies
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeSigningPolicies"
      ( \Object
x ->
          Maybe CodeSigningPolicy -> CodeSigningPolicies
CodeSigningPolicies'
            (Maybe CodeSigningPolicy -> CodeSigningPolicies)
-> Parser (Maybe CodeSigningPolicy) -> Parser CodeSigningPolicies
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CodeSigningPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UntrustedArtifactOnDeployment")
      )

instance Prelude.Hashable CodeSigningPolicies

instance Prelude.NFData CodeSigningPolicies

instance Core.ToJSON CodeSigningPolicies where
  toJSON :: CodeSigningPolicies -> Value
toJSON CodeSigningPolicies' {Maybe CodeSigningPolicy
untrustedArtifactOnDeployment :: Maybe CodeSigningPolicy
$sel:untrustedArtifactOnDeployment:CodeSigningPolicies' :: CodeSigningPolicies -> Maybe CodeSigningPolicy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UntrustedArtifactOnDeployment" Text -> CodeSigningPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CodeSigningPolicy -> Pair)
-> Maybe CodeSigningPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CodeSigningPolicy
untrustedArtifactOnDeployment
          ]
      )