{-# 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.CreateCodeSigningConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a code signing configuration. A
-- <https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html code signing configuration>
-- defines a list of allowed signing profiles and defines the code-signing
-- validation policy (action to be taken if deployment validation checks
-- fail).
module Amazonka.Lambda.CreateCodeSigningConfig
  ( -- * Creating a Request
    CreateCodeSigningConfig (..),
    newCreateCodeSigningConfig,

    -- * Request Lenses
    createCodeSigningConfig_codeSigningPolicies,
    createCodeSigningConfig_description,
    createCodeSigningConfig_allowedPublishers,

    -- * Destructuring the Response
    CreateCodeSigningConfigResponse (..),
    newCreateCodeSigningConfigResponse,

    -- * Response Lenses
    createCodeSigningConfigResponse_httpStatus,
    createCodeSigningConfigResponse_codeSigningConfig,
  )
where

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

-- | /See:/ 'newCreateCodeSigningConfig' smart constructor.
data CreateCodeSigningConfig = CreateCodeSigningConfig'
  { -- | The code signing policies define the actions to take if the validation
    -- checks fail.
    CreateCodeSigningConfig -> Maybe CodeSigningPolicies
codeSigningPolicies :: Prelude.Maybe CodeSigningPolicies,
    -- | Descriptive name for this code signing configuration.
    CreateCodeSigningConfig -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Signing profiles for this code signing configuration.
    CreateCodeSigningConfig -> AllowedPublishers
allowedPublishers :: AllowedPublishers
  }
  deriving (CreateCodeSigningConfig -> CreateCodeSigningConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCodeSigningConfig -> CreateCodeSigningConfig -> Bool
$c/= :: CreateCodeSigningConfig -> CreateCodeSigningConfig -> Bool
== :: CreateCodeSigningConfig -> CreateCodeSigningConfig -> Bool
$c== :: CreateCodeSigningConfig -> CreateCodeSigningConfig -> Bool
Prelude.Eq, ReadPrec [CreateCodeSigningConfig]
ReadPrec CreateCodeSigningConfig
Int -> ReadS CreateCodeSigningConfig
ReadS [CreateCodeSigningConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCodeSigningConfig]
$creadListPrec :: ReadPrec [CreateCodeSigningConfig]
readPrec :: ReadPrec CreateCodeSigningConfig
$creadPrec :: ReadPrec CreateCodeSigningConfig
readList :: ReadS [CreateCodeSigningConfig]
$creadList :: ReadS [CreateCodeSigningConfig]
readsPrec :: Int -> ReadS CreateCodeSigningConfig
$creadsPrec :: Int -> ReadS CreateCodeSigningConfig
Prelude.Read, Int -> CreateCodeSigningConfig -> ShowS
[CreateCodeSigningConfig] -> ShowS
CreateCodeSigningConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCodeSigningConfig] -> ShowS
$cshowList :: [CreateCodeSigningConfig] -> ShowS
show :: CreateCodeSigningConfig -> String
$cshow :: CreateCodeSigningConfig -> String
showsPrec :: Int -> CreateCodeSigningConfig -> ShowS
$cshowsPrec :: Int -> CreateCodeSigningConfig -> ShowS
Prelude.Show, forall x. Rep CreateCodeSigningConfig x -> CreateCodeSigningConfig
forall x. CreateCodeSigningConfig -> Rep CreateCodeSigningConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCodeSigningConfig x -> CreateCodeSigningConfig
$cfrom :: forall x. CreateCodeSigningConfig -> Rep CreateCodeSigningConfig x
Prelude.Generic)

-- |
-- Create a value of 'CreateCodeSigningConfig' 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:
--
-- 'codeSigningPolicies', 'createCodeSigningConfig_codeSigningPolicies' - The code signing policies define the actions to take if the validation
-- checks fail.
--
-- 'description', 'createCodeSigningConfig_description' - Descriptive name for this code signing configuration.
--
-- 'allowedPublishers', 'createCodeSigningConfig_allowedPublishers' - Signing profiles for this code signing configuration.
newCreateCodeSigningConfig ::
  -- | 'allowedPublishers'
  AllowedPublishers ->
  CreateCodeSigningConfig
newCreateCodeSigningConfig :: AllowedPublishers -> CreateCodeSigningConfig
newCreateCodeSigningConfig AllowedPublishers
pAllowedPublishers_ =
  CreateCodeSigningConfig'
    { $sel:codeSigningPolicies:CreateCodeSigningConfig' :: Maybe CodeSigningPolicies
codeSigningPolicies =
        forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateCodeSigningConfig' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:allowedPublishers:CreateCodeSigningConfig' :: AllowedPublishers
allowedPublishers = AllowedPublishers
pAllowedPublishers_
    }

-- | The code signing policies define the actions to take if the validation
-- checks fail.
createCodeSigningConfig_codeSigningPolicies :: Lens.Lens' CreateCodeSigningConfig (Prelude.Maybe CodeSigningPolicies)
createCodeSigningConfig_codeSigningPolicies :: Lens' CreateCodeSigningConfig (Maybe CodeSigningPolicies)
createCodeSigningConfig_codeSigningPolicies = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeSigningConfig' {Maybe CodeSigningPolicies
codeSigningPolicies :: Maybe CodeSigningPolicies
$sel:codeSigningPolicies:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe CodeSigningPolicies
codeSigningPolicies} -> Maybe CodeSigningPolicies
codeSigningPolicies) (\s :: CreateCodeSigningConfig
s@CreateCodeSigningConfig' {} Maybe CodeSigningPolicies
a -> CreateCodeSigningConfig
s {$sel:codeSigningPolicies:CreateCodeSigningConfig' :: Maybe CodeSigningPolicies
codeSigningPolicies = Maybe CodeSigningPolicies
a} :: CreateCodeSigningConfig)

-- | Descriptive name for this code signing configuration.
createCodeSigningConfig_description :: Lens.Lens' CreateCodeSigningConfig (Prelude.Maybe Prelude.Text)
createCodeSigningConfig_description :: Lens' CreateCodeSigningConfig (Maybe Text)
createCodeSigningConfig_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeSigningConfig' {Maybe Text
description :: Maybe Text
$sel:description:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateCodeSigningConfig
s@CreateCodeSigningConfig' {} Maybe Text
a -> CreateCodeSigningConfig
s {$sel:description:CreateCodeSigningConfig' :: Maybe Text
description = Maybe Text
a} :: CreateCodeSigningConfig)

-- | Signing profiles for this code signing configuration.
createCodeSigningConfig_allowedPublishers :: Lens.Lens' CreateCodeSigningConfig AllowedPublishers
createCodeSigningConfig_allowedPublishers :: Lens' CreateCodeSigningConfig AllowedPublishers
createCodeSigningConfig_allowedPublishers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeSigningConfig' {AllowedPublishers
allowedPublishers :: AllowedPublishers
$sel:allowedPublishers:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> AllowedPublishers
allowedPublishers} -> AllowedPublishers
allowedPublishers) (\s :: CreateCodeSigningConfig
s@CreateCodeSigningConfig' {} AllowedPublishers
a -> CreateCodeSigningConfig
s {$sel:allowedPublishers:CreateCodeSigningConfig' :: AllowedPublishers
allowedPublishers = AllowedPublishers
a} :: CreateCodeSigningConfig)

instance Core.AWSRequest CreateCodeSigningConfig where
  type
    AWSResponse CreateCodeSigningConfig =
      CreateCodeSigningConfigResponse
  request :: (Service -> Service)
-> CreateCodeSigningConfig -> Request CreateCodeSigningConfig
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateCodeSigningConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateCodeSigningConfig)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> CodeSigningConfig -> CreateCodeSigningConfigResponse
CreateCodeSigningConfigResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"CodeSigningConfig")
      )

instance Prelude.Hashable CreateCodeSigningConfig where
  hashWithSalt :: Int -> CreateCodeSigningConfig -> Int
hashWithSalt Int
_salt CreateCodeSigningConfig' {Maybe Text
Maybe CodeSigningPolicies
AllowedPublishers
allowedPublishers :: AllowedPublishers
description :: Maybe Text
codeSigningPolicies :: Maybe CodeSigningPolicies
$sel:allowedPublishers:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> AllowedPublishers
$sel:description:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe Text
$sel:codeSigningPolicies:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe CodeSigningPolicies
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CodeSigningPolicies
codeSigningPolicies
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AllowedPublishers
allowedPublishers

instance Prelude.NFData CreateCodeSigningConfig where
  rnf :: CreateCodeSigningConfig -> ()
rnf CreateCodeSigningConfig' {Maybe Text
Maybe CodeSigningPolicies
AllowedPublishers
allowedPublishers :: AllowedPublishers
description :: Maybe Text
codeSigningPolicies :: Maybe CodeSigningPolicies
$sel:allowedPublishers:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> AllowedPublishers
$sel:description:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe Text
$sel:codeSigningPolicies:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe CodeSigningPolicies
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CodeSigningPolicies
codeSigningPolicies
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AllowedPublishers
allowedPublishers

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

instance Data.ToJSON CreateCodeSigningConfig where
  toJSON :: CreateCodeSigningConfig -> Value
toJSON CreateCodeSigningConfig' {Maybe Text
Maybe CodeSigningPolicies
AllowedPublishers
allowedPublishers :: AllowedPublishers
description :: Maybe Text
codeSigningPolicies :: Maybe CodeSigningPolicies
$sel:allowedPublishers:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> AllowedPublishers
$sel:description:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe Text
$sel:codeSigningPolicies:CreateCodeSigningConfig' :: CreateCodeSigningConfig -> Maybe CodeSigningPolicies
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CodeSigningPolicies" 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 CodeSigningPolicies
codeSigningPolicies,
            (Key
"Description" 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
description,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AllowedPublishers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AllowedPublishers
allowedPublishers)
          ]
      )

instance Data.ToPath CreateCodeSigningConfig where
  toPath :: CreateCodeSigningConfig -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const ByteString
"/2020-04-22/code-signing-configs/"

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

-- | /See:/ 'newCreateCodeSigningConfigResponse' smart constructor.
data CreateCodeSigningConfigResponse = CreateCodeSigningConfigResponse'
  { -- | The response's http status code.
    CreateCodeSigningConfigResponse -> Int
httpStatus :: Prelude.Int,
    -- | The code signing configuration.
    CreateCodeSigningConfigResponse -> CodeSigningConfig
codeSigningConfig :: CodeSigningConfig
  }
  deriving (CreateCodeSigningConfigResponse
-> CreateCodeSigningConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCodeSigningConfigResponse
-> CreateCodeSigningConfigResponse -> Bool
$c/= :: CreateCodeSigningConfigResponse
-> CreateCodeSigningConfigResponse -> Bool
== :: CreateCodeSigningConfigResponse
-> CreateCodeSigningConfigResponse -> Bool
$c== :: CreateCodeSigningConfigResponse
-> CreateCodeSigningConfigResponse -> Bool
Prelude.Eq, ReadPrec [CreateCodeSigningConfigResponse]
ReadPrec CreateCodeSigningConfigResponse
Int -> ReadS CreateCodeSigningConfigResponse
ReadS [CreateCodeSigningConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCodeSigningConfigResponse]
$creadListPrec :: ReadPrec [CreateCodeSigningConfigResponse]
readPrec :: ReadPrec CreateCodeSigningConfigResponse
$creadPrec :: ReadPrec CreateCodeSigningConfigResponse
readList :: ReadS [CreateCodeSigningConfigResponse]
$creadList :: ReadS [CreateCodeSigningConfigResponse]
readsPrec :: Int -> ReadS CreateCodeSigningConfigResponse
$creadsPrec :: Int -> ReadS CreateCodeSigningConfigResponse
Prelude.Read, Int -> CreateCodeSigningConfigResponse -> ShowS
[CreateCodeSigningConfigResponse] -> ShowS
CreateCodeSigningConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCodeSigningConfigResponse] -> ShowS
$cshowList :: [CreateCodeSigningConfigResponse] -> ShowS
show :: CreateCodeSigningConfigResponse -> String
$cshow :: CreateCodeSigningConfigResponse -> String
showsPrec :: Int -> CreateCodeSigningConfigResponse -> ShowS
$cshowsPrec :: Int -> CreateCodeSigningConfigResponse -> ShowS
Prelude.Show, forall x.
Rep CreateCodeSigningConfigResponse x
-> CreateCodeSigningConfigResponse
forall x.
CreateCodeSigningConfigResponse
-> Rep CreateCodeSigningConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCodeSigningConfigResponse x
-> CreateCodeSigningConfigResponse
$cfrom :: forall x.
CreateCodeSigningConfigResponse
-> Rep CreateCodeSigningConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateCodeSigningConfigResponse' 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:
--
-- 'httpStatus', 'createCodeSigningConfigResponse_httpStatus' - The response's http status code.
--
-- 'codeSigningConfig', 'createCodeSigningConfigResponse_codeSigningConfig' - The code signing configuration.
newCreateCodeSigningConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'codeSigningConfig'
  CodeSigningConfig ->
  CreateCodeSigningConfigResponse
newCreateCodeSigningConfigResponse :: Int -> CodeSigningConfig -> CreateCodeSigningConfigResponse
newCreateCodeSigningConfigResponse
  Int
pHttpStatus_
  CodeSigningConfig
pCodeSigningConfig_ =
    CreateCodeSigningConfigResponse'
      { $sel:httpStatus:CreateCodeSigningConfigResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:codeSigningConfig:CreateCodeSigningConfigResponse' :: CodeSigningConfig
codeSigningConfig = CodeSigningConfig
pCodeSigningConfig_
      }

-- | The response's http status code.
createCodeSigningConfigResponse_httpStatus :: Lens.Lens' CreateCodeSigningConfigResponse Prelude.Int
createCodeSigningConfigResponse_httpStatus :: Lens' CreateCodeSigningConfigResponse Int
createCodeSigningConfigResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeSigningConfigResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCodeSigningConfigResponse' :: CreateCodeSigningConfigResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCodeSigningConfigResponse
s@CreateCodeSigningConfigResponse' {} Int
a -> CreateCodeSigningConfigResponse
s {$sel:httpStatus:CreateCodeSigningConfigResponse' :: Int
httpStatus = Int
a} :: CreateCodeSigningConfigResponse)

-- | The code signing configuration.
createCodeSigningConfigResponse_codeSigningConfig :: Lens.Lens' CreateCodeSigningConfigResponse CodeSigningConfig
createCodeSigningConfigResponse_codeSigningConfig :: Lens' CreateCodeSigningConfigResponse CodeSigningConfig
createCodeSigningConfigResponse_codeSigningConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCodeSigningConfigResponse' {CodeSigningConfig
codeSigningConfig :: CodeSigningConfig
$sel:codeSigningConfig:CreateCodeSigningConfigResponse' :: CreateCodeSigningConfigResponse -> CodeSigningConfig
codeSigningConfig} -> CodeSigningConfig
codeSigningConfig) (\s :: CreateCodeSigningConfigResponse
s@CreateCodeSigningConfigResponse' {} CodeSigningConfig
a -> CreateCodeSigningConfigResponse
s {$sel:codeSigningConfig:CreateCodeSigningConfigResponse' :: CodeSigningConfig
codeSigningConfig = CodeSigningConfig
a} :: CreateCodeSigningConfigResponse)

instance
  Prelude.NFData
    CreateCodeSigningConfigResponse
  where
  rnf :: CreateCodeSigningConfigResponse -> ()
rnf CreateCodeSigningConfigResponse' {Int
CodeSigningConfig
codeSigningConfig :: CodeSigningConfig
httpStatus :: Int
$sel:codeSigningConfig:CreateCodeSigningConfigResponse' :: CreateCodeSigningConfigResponse -> CodeSigningConfig
$sel:httpStatus:CreateCodeSigningConfigResponse' :: CreateCodeSigningConfigResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CodeSigningConfig
codeSigningConfig