{-# 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.Signer.Types.SigningConfigurationOverrides
-- 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.Signer.Types.SigningConfigurationOverrides where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Signer.Types.EncryptionAlgorithm
import Amazonka.Signer.Types.HashAlgorithm

-- | A signing configuration that overrides the default encryption or hash
-- algorithm of a signing job.
--
-- /See:/ 'newSigningConfigurationOverrides' smart constructor.
data SigningConfigurationOverrides = SigningConfigurationOverrides'
  { -- | A specified override of the default hash algorithm that is used in a
    -- code signing job.
    SigningConfigurationOverrides -> Maybe HashAlgorithm
hashAlgorithm :: Prelude.Maybe HashAlgorithm,
    -- | A specified override of the default encryption algorithm that is used in
    -- a code signing job.
    SigningConfigurationOverrides -> Maybe EncryptionAlgorithm
encryptionAlgorithm :: Prelude.Maybe EncryptionAlgorithm
  }
  deriving (SigningConfigurationOverrides
-> SigningConfigurationOverrides -> Bool
(SigningConfigurationOverrides
 -> SigningConfigurationOverrides -> Bool)
-> (SigningConfigurationOverrides
    -> SigningConfigurationOverrides -> Bool)
-> Eq SigningConfigurationOverrides
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SigningConfigurationOverrides
-> SigningConfigurationOverrides -> Bool
$c/= :: SigningConfigurationOverrides
-> SigningConfigurationOverrides -> Bool
== :: SigningConfigurationOverrides
-> SigningConfigurationOverrides -> Bool
$c== :: SigningConfigurationOverrides
-> SigningConfigurationOverrides -> Bool
Prelude.Eq, ReadPrec [SigningConfigurationOverrides]
ReadPrec SigningConfigurationOverrides
Int -> ReadS SigningConfigurationOverrides
ReadS [SigningConfigurationOverrides]
(Int -> ReadS SigningConfigurationOverrides)
-> ReadS [SigningConfigurationOverrides]
-> ReadPrec SigningConfigurationOverrides
-> ReadPrec [SigningConfigurationOverrides]
-> Read SigningConfigurationOverrides
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SigningConfigurationOverrides]
$creadListPrec :: ReadPrec [SigningConfigurationOverrides]
readPrec :: ReadPrec SigningConfigurationOverrides
$creadPrec :: ReadPrec SigningConfigurationOverrides
readList :: ReadS [SigningConfigurationOverrides]
$creadList :: ReadS [SigningConfigurationOverrides]
readsPrec :: Int -> ReadS SigningConfigurationOverrides
$creadsPrec :: Int -> ReadS SigningConfigurationOverrides
Prelude.Read, Int -> SigningConfigurationOverrides -> ShowS
[SigningConfigurationOverrides] -> ShowS
SigningConfigurationOverrides -> String
(Int -> SigningConfigurationOverrides -> ShowS)
-> (SigningConfigurationOverrides -> String)
-> ([SigningConfigurationOverrides] -> ShowS)
-> Show SigningConfigurationOverrides
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningConfigurationOverrides] -> ShowS
$cshowList :: [SigningConfigurationOverrides] -> ShowS
show :: SigningConfigurationOverrides -> String
$cshow :: SigningConfigurationOverrides -> String
showsPrec :: Int -> SigningConfigurationOverrides -> ShowS
$cshowsPrec :: Int -> SigningConfigurationOverrides -> ShowS
Prelude.Show, (forall x.
 SigningConfigurationOverrides
 -> Rep SigningConfigurationOverrides x)
-> (forall x.
    Rep SigningConfigurationOverrides x
    -> SigningConfigurationOverrides)
-> Generic SigningConfigurationOverrides
forall x.
Rep SigningConfigurationOverrides x
-> SigningConfigurationOverrides
forall x.
SigningConfigurationOverrides
-> Rep SigningConfigurationOverrides x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SigningConfigurationOverrides x
-> SigningConfigurationOverrides
$cfrom :: forall x.
SigningConfigurationOverrides
-> Rep SigningConfigurationOverrides x
Prelude.Generic)

-- |
-- Create a value of 'SigningConfigurationOverrides' 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:
--
-- 'hashAlgorithm', 'signingConfigurationOverrides_hashAlgorithm' - A specified override of the default hash algorithm that is used in a
-- code signing job.
--
-- 'encryptionAlgorithm', 'signingConfigurationOverrides_encryptionAlgorithm' - A specified override of the default encryption algorithm that is used in
-- a code signing job.
newSigningConfigurationOverrides ::
  SigningConfigurationOverrides
newSigningConfigurationOverrides :: SigningConfigurationOverrides
newSigningConfigurationOverrides =
  SigningConfigurationOverrides' :: Maybe HashAlgorithm
-> Maybe EncryptionAlgorithm -> SigningConfigurationOverrides
SigningConfigurationOverrides'
    { $sel:hashAlgorithm:SigningConfigurationOverrides' :: Maybe HashAlgorithm
hashAlgorithm =
        Maybe HashAlgorithm
forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionAlgorithm:SigningConfigurationOverrides' :: Maybe EncryptionAlgorithm
encryptionAlgorithm = Maybe EncryptionAlgorithm
forall a. Maybe a
Prelude.Nothing
    }

-- | A specified override of the default hash algorithm that is used in a
-- code signing job.
signingConfigurationOverrides_hashAlgorithm :: Lens.Lens' SigningConfigurationOverrides (Prelude.Maybe HashAlgorithm)
signingConfigurationOverrides_hashAlgorithm :: (Maybe HashAlgorithm -> f (Maybe HashAlgorithm))
-> SigningConfigurationOverrides -> f SigningConfigurationOverrides
signingConfigurationOverrides_hashAlgorithm = (SigningConfigurationOverrides -> Maybe HashAlgorithm)
-> (SigningConfigurationOverrides
    -> Maybe HashAlgorithm -> SigningConfigurationOverrides)
-> Lens
     SigningConfigurationOverrides
     SigningConfigurationOverrides
     (Maybe HashAlgorithm)
     (Maybe HashAlgorithm)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningConfigurationOverrides' {Maybe HashAlgorithm
hashAlgorithm :: Maybe HashAlgorithm
$sel:hashAlgorithm:SigningConfigurationOverrides' :: SigningConfigurationOverrides -> Maybe HashAlgorithm
hashAlgorithm} -> Maybe HashAlgorithm
hashAlgorithm) (\s :: SigningConfigurationOverrides
s@SigningConfigurationOverrides' {} Maybe HashAlgorithm
a -> SigningConfigurationOverrides
s {$sel:hashAlgorithm:SigningConfigurationOverrides' :: Maybe HashAlgorithm
hashAlgorithm = Maybe HashAlgorithm
a} :: SigningConfigurationOverrides)

-- | A specified override of the default encryption algorithm that is used in
-- a code signing job.
signingConfigurationOverrides_encryptionAlgorithm :: Lens.Lens' SigningConfigurationOverrides (Prelude.Maybe EncryptionAlgorithm)
signingConfigurationOverrides_encryptionAlgorithm :: (Maybe EncryptionAlgorithm -> f (Maybe EncryptionAlgorithm))
-> SigningConfigurationOverrides -> f SigningConfigurationOverrides
signingConfigurationOverrides_encryptionAlgorithm = (SigningConfigurationOverrides -> Maybe EncryptionAlgorithm)
-> (SigningConfigurationOverrides
    -> Maybe EncryptionAlgorithm -> SigningConfigurationOverrides)
-> Lens
     SigningConfigurationOverrides
     SigningConfigurationOverrides
     (Maybe EncryptionAlgorithm)
     (Maybe EncryptionAlgorithm)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningConfigurationOverrides' {Maybe EncryptionAlgorithm
encryptionAlgorithm :: Maybe EncryptionAlgorithm
$sel:encryptionAlgorithm:SigningConfigurationOverrides' :: SigningConfigurationOverrides -> Maybe EncryptionAlgorithm
encryptionAlgorithm} -> Maybe EncryptionAlgorithm
encryptionAlgorithm) (\s :: SigningConfigurationOverrides
s@SigningConfigurationOverrides' {} Maybe EncryptionAlgorithm
a -> SigningConfigurationOverrides
s {$sel:encryptionAlgorithm:SigningConfigurationOverrides' :: Maybe EncryptionAlgorithm
encryptionAlgorithm = Maybe EncryptionAlgorithm
a} :: SigningConfigurationOverrides)

instance Core.FromJSON SigningConfigurationOverrides where
  parseJSON :: Value -> Parser SigningConfigurationOverrides
parseJSON =
    String
-> (Object -> Parser SigningConfigurationOverrides)
-> Value
-> Parser SigningConfigurationOverrides
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SigningConfigurationOverrides"
      ( \Object
x ->
          Maybe HashAlgorithm
-> Maybe EncryptionAlgorithm -> SigningConfigurationOverrides
SigningConfigurationOverrides'
            (Maybe HashAlgorithm
 -> Maybe EncryptionAlgorithm -> SigningConfigurationOverrides)
-> Parser (Maybe HashAlgorithm)
-> Parser
     (Maybe EncryptionAlgorithm -> SigningConfigurationOverrides)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HashAlgorithm)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hashAlgorithm")
            Parser (Maybe EncryptionAlgorithm -> SigningConfigurationOverrides)
-> Parser (Maybe EncryptionAlgorithm)
-> Parser SigningConfigurationOverrides
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EncryptionAlgorithm)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"encryptionAlgorithm")
      )

instance
  Prelude.Hashable
    SigningConfigurationOverrides

instance Prelude.NFData SigningConfigurationOverrides

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