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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.CodeSigningCertificateChain
import Amazonka.IoT.Types.CodeSigningSignature
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a custom method used to code sign a file.
--
-- /See:/ 'newCustomCodeSigning' smart constructor.
data CustomCodeSigning = CustomCodeSigning'
  { -- | The signature for the file.
    CustomCodeSigning -> Maybe CodeSigningSignature
signature :: Prelude.Maybe CodeSigningSignature,
    -- | The hash algorithm used to code sign the file.
    CustomCodeSigning -> Maybe Text
hashAlgorithm :: Prelude.Maybe Prelude.Text,
    -- | The certificate chain.
    CustomCodeSigning -> Maybe CodeSigningCertificateChain
certificateChain :: Prelude.Maybe CodeSigningCertificateChain,
    -- | The signature algorithm used to code sign the file.
    CustomCodeSigning -> Maybe Text
signatureAlgorithm :: Prelude.Maybe Prelude.Text
  }
  deriving (CustomCodeSigning -> CustomCodeSigning -> Bool
(CustomCodeSigning -> CustomCodeSigning -> Bool)
-> (CustomCodeSigning -> CustomCodeSigning -> Bool)
-> Eq CustomCodeSigning
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomCodeSigning -> CustomCodeSigning -> Bool
$c/= :: CustomCodeSigning -> CustomCodeSigning -> Bool
== :: CustomCodeSigning -> CustomCodeSigning -> Bool
$c== :: CustomCodeSigning -> CustomCodeSigning -> Bool
Prelude.Eq, ReadPrec [CustomCodeSigning]
ReadPrec CustomCodeSigning
Int -> ReadS CustomCodeSigning
ReadS [CustomCodeSigning]
(Int -> ReadS CustomCodeSigning)
-> ReadS [CustomCodeSigning]
-> ReadPrec CustomCodeSigning
-> ReadPrec [CustomCodeSigning]
-> Read CustomCodeSigning
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomCodeSigning]
$creadListPrec :: ReadPrec [CustomCodeSigning]
readPrec :: ReadPrec CustomCodeSigning
$creadPrec :: ReadPrec CustomCodeSigning
readList :: ReadS [CustomCodeSigning]
$creadList :: ReadS [CustomCodeSigning]
readsPrec :: Int -> ReadS CustomCodeSigning
$creadsPrec :: Int -> ReadS CustomCodeSigning
Prelude.Read, Int -> CustomCodeSigning -> ShowS
[CustomCodeSigning] -> ShowS
CustomCodeSigning -> String
(Int -> CustomCodeSigning -> ShowS)
-> (CustomCodeSigning -> String)
-> ([CustomCodeSigning] -> ShowS)
-> Show CustomCodeSigning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomCodeSigning] -> ShowS
$cshowList :: [CustomCodeSigning] -> ShowS
show :: CustomCodeSigning -> String
$cshow :: CustomCodeSigning -> String
showsPrec :: Int -> CustomCodeSigning -> ShowS
$cshowsPrec :: Int -> CustomCodeSigning -> ShowS
Prelude.Show, (forall x. CustomCodeSigning -> Rep CustomCodeSigning x)
-> (forall x. Rep CustomCodeSigning x -> CustomCodeSigning)
-> Generic CustomCodeSigning
forall x. Rep CustomCodeSigning x -> CustomCodeSigning
forall x. CustomCodeSigning -> Rep CustomCodeSigning x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomCodeSigning x -> CustomCodeSigning
$cfrom :: forall x. CustomCodeSigning -> Rep CustomCodeSigning x
Prelude.Generic)

-- |
-- Create a value of 'CustomCodeSigning' 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:
--
-- 'signature', 'customCodeSigning_signature' - The signature for the file.
--
-- 'hashAlgorithm', 'customCodeSigning_hashAlgorithm' - The hash algorithm used to code sign the file.
--
-- 'certificateChain', 'customCodeSigning_certificateChain' - The certificate chain.
--
-- 'signatureAlgorithm', 'customCodeSigning_signatureAlgorithm' - The signature algorithm used to code sign the file.
newCustomCodeSigning ::
  CustomCodeSigning
newCustomCodeSigning :: CustomCodeSigning
newCustomCodeSigning =
  CustomCodeSigning' :: Maybe CodeSigningSignature
-> Maybe Text
-> Maybe CodeSigningCertificateChain
-> Maybe Text
-> CustomCodeSigning
CustomCodeSigning'
    { $sel:signature:CustomCodeSigning' :: Maybe CodeSigningSignature
signature = Maybe CodeSigningSignature
forall a. Maybe a
Prelude.Nothing,
      $sel:hashAlgorithm:CustomCodeSigning' :: Maybe Text
hashAlgorithm = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateChain:CustomCodeSigning' :: Maybe CodeSigningCertificateChain
certificateChain = Maybe CodeSigningCertificateChain
forall a. Maybe a
Prelude.Nothing,
      $sel:signatureAlgorithm:CustomCodeSigning' :: Maybe Text
signatureAlgorithm = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The signature for the file.
customCodeSigning_signature :: Lens.Lens' CustomCodeSigning (Prelude.Maybe CodeSigningSignature)
customCodeSigning_signature :: (Maybe CodeSigningSignature -> f (Maybe CodeSigningSignature))
-> CustomCodeSigning -> f CustomCodeSigning
customCodeSigning_signature = (CustomCodeSigning -> Maybe CodeSigningSignature)
-> (CustomCodeSigning
    -> Maybe CodeSigningSignature -> CustomCodeSigning)
-> Lens
     CustomCodeSigning
     CustomCodeSigning
     (Maybe CodeSigningSignature)
     (Maybe CodeSigningSignature)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomCodeSigning' {Maybe CodeSigningSignature
signature :: Maybe CodeSigningSignature
$sel:signature:CustomCodeSigning' :: CustomCodeSigning -> Maybe CodeSigningSignature
signature} -> Maybe CodeSigningSignature
signature) (\s :: CustomCodeSigning
s@CustomCodeSigning' {} Maybe CodeSigningSignature
a -> CustomCodeSigning
s {$sel:signature:CustomCodeSigning' :: Maybe CodeSigningSignature
signature = Maybe CodeSigningSignature
a} :: CustomCodeSigning)

-- | The hash algorithm used to code sign the file.
customCodeSigning_hashAlgorithm :: Lens.Lens' CustomCodeSigning (Prelude.Maybe Prelude.Text)
customCodeSigning_hashAlgorithm :: (Maybe Text -> f (Maybe Text))
-> CustomCodeSigning -> f CustomCodeSigning
customCodeSigning_hashAlgorithm = (CustomCodeSigning -> Maybe Text)
-> (CustomCodeSigning -> Maybe Text -> CustomCodeSigning)
-> Lens
     CustomCodeSigning CustomCodeSigning (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomCodeSigning' {Maybe Text
hashAlgorithm :: Maybe Text
$sel:hashAlgorithm:CustomCodeSigning' :: CustomCodeSigning -> Maybe Text
hashAlgorithm} -> Maybe Text
hashAlgorithm) (\s :: CustomCodeSigning
s@CustomCodeSigning' {} Maybe Text
a -> CustomCodeSigning
s {$sel:hashAlgorithm:CustomCodeSigning' :: Maybe Text
hashAlgorithm = Maybe Text
a} :: CustomCodeSigning)

-- | The certificate chain.
customCodeSigning_certificateChain :: Lens.Lens' CustomCodeSigning (Prelude.Maybe CodeSigningCertificateChain)
customCodeSigning_certificateChain :: (Maybe CodeSigningCertificateChain
 -> f (Maybe CodeSigningCertificateChain))
-> CustomCodeSigning -> f CustomCodeSigning
customCodeSigning_certificateChain = (CustomCodeSigning -> Maybe CodeSigningCertificateChain)
-> (CustomCodeSigning
    -> Maybe CodeSigningCertificateChain -> CustomCodeSigning)
-> Lens
     CustomCodeSigning
     CustomCodeSigning
     (Maybe CodeSigningCertificateChain)
     (Maybe CodeSigningCertificateChain)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomCodeSigning' {Maybe CodeSigningCertificateChain
certificateChain :: Maybe CodeSigningCertificateChain
$sel:certificateChain:CustomCodeSigning' :: CustomCodeSigning -> Maybe CodeSigningCertificateChain
certificateChain} -> Maybe CodeSigningCertificateChain
certificateChain) (\s :: CustomCodeSigning
s@CustomCodeSigning' {} Maybe CodeSigningCertificateChain
a -> CustomCodeSigning
s {$sel:certificateChain:CustomCodeSigning' :: Maybe CodeSigningCertificateChain
certificateChain = Maybe CodeSigningCertificateChain
a} :: CustomCodeSigning)

-- | The signature algorithm used to code sign the file.
customCodeSigning_signatureAlgorithm :: Lens.Lens' CustomCodeSigning (Prelude.Maybe Prelude.Text)
customCodeSigning_signatureAlgorithm :: (Maybe Text -> f (Maybe Text))
-> CustomCodeSigning -> f CustomCodeSigning
customCodeSigning_signatureAlgorithm = (CustomCodeSigning -> Maybe Text)
-> (CustomCodeSigning -> Maybe Text -> CustomCodeSigning)
-> Lens
     CustomCodeSigning CustomCodeSigning (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomCodeSigning' {Maybe Text
signatureAlgorithm :: Maybe Text
$sel:signatureAlgorithm:CustomCodeSigning' :: CustomCodeSigning -> Maybe Text
signatureAlgorithm} -> Maybe Text
signatureAlgorithm) (\s :: CustomCodeSigning
s@CustomCodeSigning' {} Maybe Text
a -> CustomCodeSigning
s {$sel:signatureAlgorithm:CustomCodeSigning' :: Maybe Text
signatureAlgorithm = Maybe Text
a} :: CustomCodeSigning)

instance Core.FromJSON CustomCodeSigning where
  parseJSON :: Value -> Parser CustomCodeSigning
parseJSON =
    String
-> (Object -> Parser CustomCodeSigning)
-> Value
-> Parser CustomCodeSigning
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomCodeSigning"
      ( \Object
x ->
          Maybe CodeSigningSignature
-> Maybe Text
-> Maybe CodeSigningCertificateChain
-> Maybe Text
-> CustomCodeSigning
CustomCodeSigning'
            (Maybe CodeSigningSignature
 -> Maybe Text
 -> Maybe CodeSigningCertificateChain
 -> Maybe Text
 -> CustomCodeSigning)
-> Parser (Maybe CodeSigningSignature)
-> Parser
     (Maybe Text
      -> Maybe CodeSigningCertificateChain
      -> Maybe Text
      -> CustomCodeSigning)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CodeSigningSignature)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"signature")
            Parser
  (Maybe Text
   -> Maybe CodeSigningCertificateChain
   -> Maybe Text
   -> CustomCodeSigning)
-> Parser (Maybe Text)
-> Parser
     (Maybe CodeSigningCertificateChain
      -> Maybe Text -> CustomCodeSigning)
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
"hashAlgorithm")
            Parser
  (Maybe CodeSigningCertificateChain
   -> Maybe Text -> CustomCodeSigning)
-> Parser (Maybe CodeSigningCertificateChain)
-> Parser (Maybe Text -> CustomCodeSigning)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CodeSigningCertificateChain)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"certificateChain")
            Parser (Maybe Text -> CustomCodeSigning)
-> Parser (Maybe Text) -> Parser CustomCodeSigning
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
"signatureAlgorithm")
      )

instance Prelude.Hashable CustomCodeSigning

instance Prelude.NFData CustomCodeSigning

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