{-# 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.IoT.Types.CodeSigning
-- 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.IoT.Types.CodeSigning where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.CustomCodeSigning
import Amazonka.IoT.Types.StartSigningJobParameter
import qualified Amazonka.Prelude as Prelude

-- | Describes the method to use when code signing a file.
--
-- /See:/ 'newCodeSigning' smart constructor.
data CodeSigning = CodeSigning'
  { -- | The ID of the @AWSSignerJob@ which was created to sign the file.
    CodeSigning -> Maybe Text
awsSignerJobId :: Prelude.Maybe Prelude.Text,
    -- | A custom method for code signing a file.
    CodeSigning -> Maybe CustomCodeSigning
customCodeSigning :: Prelude.Maybe CustomCodeSigning,
    -- | Describes the code-signing job.
    CodeSigning -> Maybe StartSigningJobParameter
startSigningJobParameter :: Prelude.Maybe StartSigningJobParameter
  }
  deriving (CodeSigning -> CodeSigning -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeSigning -> CodeSigning -> Bool
$c/= :: CodeSigning -> CodeSigning -> Bool
== :: CodeSigning -> CodeSigning -> Bool
$c== :: CodeSigning -> CodeSigning -> Bool
Prelude.Eq, ReadPrec [CodeSigning]
ReadPrec CodeSigning
Int -> ReadS CodeSigning
ReadS [CodeSigning]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeSigning]
$creadListPrec :: ReadPrec [CodeSigning]
readPrec :: ReadPrec CodeSigning
$creadPrec :: ReadPrec CodeSigning
readList :: ReadS [CodeSigning]
$creadList :: ReadS [CodeSigning]
readsPrec :: Int -> ReadS CodeSigning
$creadsPrec :: Int -> ReadS CodeSigning
Prelude.Read, Int -> CodeSigning -> ShowS
[CodeSigning] -> ShowS
CodeSigning -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeSigning] -> ShowS
$cshowList :: [CodeSigning] -> ShowS
show :: CodeSigning -> String
$cshow :: CodeSigning -> String
showsPrec :: Int -> CodeSigning -> ShowS
$cshowsPrec :: Int -> CodeSigning -> ShowS
Prelude.Show, forall x. Rep CodeSigning x -> CodeSigning
forall x. CodeSigning -> Rep CodeSigning x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeSigning x -> CodeSigning
$cfrom :: forall x. CodeSigning -> Rep CodeSigning x
Prelude.Generic)

-- |
-- Create a value of 'CodeSigning' 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:
--
-- 'awsSignerJobId', 'codeSigning_awsSignerJobId' - The ID of the @AWSSignerJob@ which was created to sign the file.
--
-- 'customCodeSigning', 'codeSigning_customCodeSigning' - A custom method for code signing a file.
--
-- 'startSigningJobParameter', 'codeSigning_startSigningJobParameter' - Describes the code-signing job.
newCodeSigning ::
  CodeSigning
newCodeSigning :: CodeSigning
newCodeSigning =
  CodeSigning'
    { $sel:awsSignerJobId:CodeSigning' :: Maybe Text
awsSignerJobId = forall a. Maybe a
Prelude.Nothing,
      $sel:customCodeSigning:CodeSigning' :: Maybe CustomCodeSigning
customCodeSigning = forall a. Maybe a
Prelude.Nothing,
      $sel:startSigningJobParameter:CodeSigning' :: Maybe StartSigningJobParameter
startSigningJobParameter = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the @AWSSignerJob@ which was created to sign the file.
codeSigning_awsSignerJobId :: Lens.Lens' CodeSigning (Prelude.Maybe Prelude.Text)
codeSigning_awsSignerJobId :: Lens' CodeSigning (Maybe Text)
codeSigning_awsSignerJobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigning' {Maybe Text
awsSignerJobId :: Maybe Text
$sel:awsSignerJobId:CodeSigning' :: CodeSigning -> Maybe Text
awsSignerJobId} -> Maybe Text
awsSignerJobId) (\s :: CodeSigning
s@CodeSigning' {} Maybe Text
a -> CodeSigning
s {$sel:awsSignerJobId:CodeSigning' :: Maybe Text
awsSignerJobId = Maybe Text
a} :: CodeSigning)

-- | A custom method for code signing a file.
codeSigning_customCodeSigning :: Lens.Lens' CodeSigning (Prelude.Maybe CustomCodeSigning)
codeSigning_customCodeSigning :: Lens' CodeSigning (Maybe CustomCodeSigning)
codeSigning_customCodeSigning = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigning' {Maybe CustomCodeSigning
customCodeSigning :: Maybe CustomCodeSigning
$sel:customCodeSigning:CodeSigning' :: CodeSigning -> Maybe CustomCodeSigning
customCodeSigning} -> Maybe CustomCodeSigning
customCodeSigning) (\s :: CodeSigning
s@CodeSigning' {} Maybe CustomCodeSigning
a -> CodeSigning
s {$sel:customCodeSigning:CodeSigning' :: Maybe CustomCodeSigning
customCodeSigning = Maybe CustomCodeSigning
a} :: CodeSigning)

-- | Describes the code-signing job.
codeSigning_startSigningJobParameter :: Lens.Lens' CodeSigning (Prelude.Maybe StartSigningJobParameter)
codeSigning_startSigningJobParameter :: Lens' CodeSigning (Maybe StartSigningJobParameter)
codeSigning_startSigningJobParameter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigning' {Maybe StartSigningJobParameter
startSigningJobParameter :: Maybe StartSigningJobParameter
$sel:startSigningJobParameter:CodeSigning' :: CodeSigning -> Maybe StartSigningJobParameter
startSigningJobParameter} -> Maybe StartSigningJobParameter
startSigningJobParameter) (\s :: CodeSigning
s@CodeSigning' {} Maybe StartSigningJobParameter
a -> CodeSigning
s {$sel:startSigningJobParameter:CodeSigning' :: Maybe StartSigningJobParameter
startSigningJobParameter = Maybe StartSigningJobParameter
a} :: CodeSigning)

instance Data.FromJSON CodeSigning where
  parseJSON :: Value -> Parser CodeSigning
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CodeSigning"
      ( \Object
x ->
          Maybe Text
-> Maybe CustomCodeSigning
-> Maybe StartSigningJobParameter
-> CodeSigning
CodeSigning'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"awsSignerJobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"customCodeSigning")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"startSigningJobParameter")
      )

instance Prelude.Hashable CodeSigning where
  hashWithSalt :: Int -> CodeSigning -> Int
hashWithSalt Int
_salt CodeSigning' {Maybe Text
Maybe CustomCodeSigning
Maybe StartSigningJobParameter
startSigningJobParameter :: Maybe StartSigningJobParameter
customCodeSigning :: Maybe CustomCodeSigning
awsSignerJobId :: Maybe Text
$sel:startSigningJobParameter:CodeSigning' :: CodeSigning -> Maybe StartSigningJobParameter
$sel:customCodeSigning:CodeSigning' :: CodeSigning -> Maybe CustomCodeSigning
$sel:awsSignerJobId:CodeSigning' :: CodeSigning -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
awsSignerJobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomCodeSigning
customCodeSigning
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StartSigningJobParameter
startSigningJobParameter

instance Prelude.NFData CodeSigning where
  rnf :: CodeSigning -> ()
rnf CodeSigning' {Maybe Text
Maybe CustomCodeSigning
Maybe StartSigningJobParameter
startSigningJobParameter :: Maybe StartSigningJobParameter
customCodeSigning :: Maybe CustomCodeSigning
awsSignerJobId :: Maybe Text
$sel:startSigningJobParameter:CodeSigning' :: CodeSigning -> Maybe StartSigningJobParameter
$sel:customCodeSigning:CodeSigning' :: CodeSigning -> Maybe CustomCodeSigning
$sel:awsSignerJobId:CodeSigning' :: CodeSigning -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
awsSignerJobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomCodeSigning
customCodeSigning
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StartSigningJobParameter
startSigningJobParameter

instance Data.ToJSON CodeSigning where
  toJSON :: CodeSigning -> Value
toJSON CodeSigning' {Maybe Text
Maybe CustomCodeSigning
Maybe StartSigningJobParameter
startSigningJobParameter :: Maybe StartSigningJobParameter
customCodeSigning :: Maybe CustomCodeSigning
awsSignerJobId :: Maybe Text
$sel:startSigningJobParameter:CodeSigning' :: CodeSigning -> Maybe StartSigningJobParameter
$sel:customCodeSigning:CodeSigning' :: CodeSigning -> Maybe CustomCodeSigning
$sel:awsSignerJobId:CodeSigning' :: CodeSigning -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"awsSignerJobId" 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
awsSignerJobId,
            (Key
"customCodeSigning" 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 CustomCodeSigning
customCodeSigning,
            (Key
"startSigningJobParameter" 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 StartSigningJobParameter
startSigningJobParameter
          ]
      )