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

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

-- | Describes the method to use when code signing a file.
--
-- /See:/ 'newCodeSigning' smart constructor.
data CodeSigning = CodeSigning'
  { -- | 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,
    -- | The ID of the @AWSSignerJob@ which was created to sign the file.
    CodeSigning -> Maybe Text
awsSignerJobId :: Prelude.Maybe Prelude.Text
  }
  deriving (CodeSigning -> CodeSigning -> Bool
(CodeSigning -> CodeSigning -> Bool)
-> (CodeSigning -> CodeSigning -> Bool) -> Eq CodeSigning
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]
(Int -> ReadS CodeSigning)
-> ReadS [CodeSigning]
-> ReadPrec CodeSigning
-> ReadPrec [CodeSigning]
-> Read 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
(Int -> CodeSigning -> ShowS)
-> (CodeSigning -> String)
-> ([CodeSigning] -> ShowS)
-> Show CodeSigning
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. CodeSigning -> Rep CodeSigning x)
-> (forall x. Rep CodeSigning x -> CodeSigning)
-> Generic CodeSigning
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:
--
-- 'customCodeSigning', 'codeSigning_customCodeSigning' - A custom method for code signing a file.
--
-- 'startSigningJobParameter', 'codeSigning_startSigningJobParameter' - Describes the code-signing job.
--
-- 'awsSignerJobId', 'codeSigning_awsSignerJobId' - The ID of the @AWSSignerJob@ which was created to sign the file.
newCodeSigning ::
  CodeSigning
newCodeSigning :: CodeSigning
newCodeSigning =
  CodeSigning' :: Maybe CustomCodeSigning
-> Maybe StartSigningJobParameter -> Maybe Text -> CodeSigning
CodeSigning'
    { $sel:customCodeSigning:CodeSigning' :: Maybe CustomCodeSigning
customCodeSigning = Maybe CustomCodeSigning
forall a. Maybe a
Prelude.Nothing,
      $sel:startSigningJobParameter:CodeSigning' :: Maybe StartSigningJobParameter
startSigningJobParameter = Maybe StartSigningJobParameter
forall a. Maybe a
Prelude.Nothing,
      $sel:awsSignerJobId:CodeSigning' :: Maybe Text
awsSignerJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A custom method for code signing a file.
codeSigning_customCodeSigning :: Lens.Lens' CodeSigning (Prelude.Maybe CustomCodeSigning)
codeSigning_customCodeSigning :: (Maybe CustomCodeSigning -> f (Maybe CustomCodeSigning))
-> CodeSigning -> f CodeSigning
codeSigning_customCodeSigning = (CodeSigning -> Maybe CustomCodeSigning)
-> (CodeSigning -> Maybe CustomCodeSigning -> CodeSigning)
-> Lens
     CodeSigning
     CodeSigning
     (Maybe CustomCodeSigning)
     (Maybe 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 :: (Maybe StartSigningJobParameter
 -> f (Maybe StartSigningJobParameter))
-> CodeSigning -> f CodeSigning
codeSigning_startSigningJobParameter = (CodeSigning -> Maybe StartSigningJobParameter)
-> (CodeSigning -> Maybe StartSigningJobParameter -> CodeSigning)
-> Lens
     CodeSigning
     CodeSigning
     (Maybe StartSigningJobParameter)
     (Maybe 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)

-- | The ID of the @AWSSignerJob@ which was created to sign the file.
codeSigning_awsSignerJobId :: Lens.Lens' CodeSigning (Prelude.Maybe Prelude.Text)
codeSigning_awsSignerJobId :: (Maybe Text -> f (Maybe Text)) -> CodeSigning -> f CodeSigning
codeSigning_awsSignerJobId = (CodeSigning -> Maybe Text)
-> (CodeSigning -> Maybe Text -> CodeSigning)
-> Lens CodeSigning CodeSigning (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable CodeSigning

instance Prelude.NFData CodeSigning

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