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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Signer.Types.HashAlgorithm

-- | The hash algorithms that are available to a code signing job.
--
-- /See:/ 'newHashAlgorithmOptions' smart constructor.
data HashAlgorithmOptions = HashAlgorithmOptions'
  { -- | The set of accepted hash algorithms allowed in a code signing job.
    HashAlgorithmOptions -> [HashAlgorithm]
allowedValues :: [HashAlgorithm],
    -- | The default hash algorithm that is used in a code signing job.
    HashAlgorithmOptions -> HashAlgorithm
defaultValue :: HashAlgorithm
  }
  deriving (HashAlgorithmOptions -> HashAlgorithmOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HashAlgorithmOptions -> HashAlgorithmOptions -> Bool
$c/= :: HashAlgorithmOptions -> HashAlgorithmOptions -> Bool
== :: HashAlgorithmOptions -> HashAlgorithmOptions -> Bool
$c== :: HashAlgorithmOptions -> HashAlgorithmOptions -> Bool
Prelude.Eq, ReadPrec [HashAlgorithmOptions]
ReadPrec HashAlgorithmOptions
Int -> ReadS HashAlgorithmOptions
ReadS [HashAlgorithmOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HashAlgorithmOptions]
$creadListPrec :: ReadPrec [HashAlgorithmOptions]
readPrec :: ReadPrec HashAlgorithmOptions
$creadPrec :: ReadPrec HashAlgorithmOptions
readList :: ReadS [HashAlgorithmOptions]
$creadList :: ReadS [HashAlgorithmOptions]
readsPrec :: Int -> ReadS HashAlgorithmOptions
$creadsPrec :: Int -> ReadS HashAlgorithmOptions
Prelude.Read, Int -> HashAlgorithmOptions -> ShowS
[HashAlgorithmOptions] -> ShowS
HashAlgorithmOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HashAlgorithmOptions] -> ShowS
$cshowList :: [HashAlgorithmOptions] -> ShowS
show :: HashAlgorithmOptions -> String
$cshow :: HashAlgorithmOptions -> String
showsPrec :: Int -> HashAlgorithmOptions -> ShowS
$cshowsPrec :: Int -> HashAlgorithmOptions -> ShowS
Prelude.Show, forall x. Rep HashAlgorithmOptions x -> HashAlgorithmOptions
forall x. HashAlgorithmOptions -> Rep HashAlgorithmOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HashAlgorithmOptions x -> HashAlgorithmOptions
$cfrom :: forall x. HashAlgorithmOptions -> Rep HashAlgorithmOptions x
Prelude.Generic)

-- |
-- Create a value of 'HashAlgorithmOptions' 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:
--
-- 'allowedValues', 'hashAlgorithmOptions_allowedValues' - The set of accepted hash algorithms allowed in a code signing job.
--
-- 'defaultValue', 'hashAlgorithmOptions_defaultValue' - The default hash algorithm that is used in a code signing job.
newHashAlgorithmOptions ::
  -- | 'defaultValue'
  HashAlgorithm ->
  HashAlgorithmOptions
newHashAlgorithmOptions :: HashAlgorithm -> HashAlgorithmOptions
newHashAlgorithmOptions HashAlgorithm
pDefaultValue_ =
  HashAlgorithmOptions'
    { $sel:allowedValues:HashAlgorithmOptions' :: [HashAlgorithm]
allowedValues =
        forall a. Monoid a => a
Prelude.mempty,
      $sel:defaultValue:HashAlgorithmOptions' :: HashAlgorithm
defaultValue = HashAlgorithm
pDefaultValue_
    }

-- | The set of accepted hash algorithms allowed in a code signing job.
hashAlgorithmOptions_allowedValues :: Lens.Lens' HashAlgorithmOptions [HashAlgorithm]
hashAlgorithmOptions_allowedValues :: Lens' HashAlgorithmOptions [HashAlgorithm]
hashAlgorithmOptions_allowedValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HashAlgorithmOptions' {[HashAlgorithm]
allowedValues :: [HashAlgorithm]
$sel:allowedValues:HashAlgorithmOptions' :: HashAlgorithmOptions -> [HashAlgorithm]
allowedValues} -> [HashAlgorithm]
allowedValues) (\s :: HashAlgorithmOptions
s@HashAlgorithmOptions' {} [HashAlgorithm]
a -> HashAlgorithmOptions
s {$sel:allowedValues:HashAlgorithmOptions' :: [HashAlgorithm]
allowedValues = [HashAlgorithm]
a} :: HashAlgorithmOptions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The default hash algorithm that is used in a code signing job.
hashAlgorithmOptions_defaultValue :: Lens.Lens' HashAlgorithmOptions HashAlgorithm
hashAlgorithmOptions_defaultValue :: Lens' HashAlgorithmOptions HashAlgorithm
hashAlgorithmOptions_defaultValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HashAlgorithmOptions' {HashAlgorithm
defaultValue :: HashAlgorithm
$sel:defaultValue:HashAlgorithmOptions' :: HashAlgorithmOptions -> HashAlgorithm
defaultValue} -> HashAlgorithm
defaultValue) (\s :: HashAlgorithmOptions
s@HashAlgorithmOptions' {} HashAlgorithm
a -> HashAlgorithmOptions
s {$sel:defaultValue:HashAlgorithmOptions' :: HashAlgorithm
defaultValue = HashAlgorithm
a} :: HashAlgorithmOptions)

instance Data.FromJSON HashAlgorithmOptions where
  parseJSON :: Value -> Parser HashAlgorithmOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HashAlgorithmOptions"
      ( \Object
x ->
          [HashAlgorithm] -> HashAlgorithm -> HashAlgorithmOptions
HashAlgorithmOptions'
            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
"allowedValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"defaultValue")
      )

instance Prelude.Hashable HashAlgorithmOptions where
  hashWithSalt :: Int -> HashAlgorithmOptions -> Int
hashWithSalt Int
_salt HashAlgorithmOptions' {[HashAlgorithm]
HashAlgorithm
defaultValue :: HashAlgorithm
allowedValues :: [HashAlgorithm]
$sel:defaultValue:HashAlgorithmOptions' :: HashAlgorithmOptions -> HashAlgorithm
$sel:allowedValues:HashAlgorithmOptions' :: HashAlgorithmOptions -> [HashAlgorithm]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [HashAlgorithm]
allowedValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashAlgorithm
defaultValue

instance Prelude.NFData HashAlgorithmOptions where
  rnf :: HashAlgorithmOptions -> ()
rnf HashAlgorithmOptions' {[HashAlgorithm]
HashAlgorithm
defaultValue :: HashAlgorithm
allowedValues :: [HashAlgorithm]
$sel:defaultValue:HashAlgorithmOptions' :: HashAlgorithmOptions -> HashAlgorithm
$sel:allowedValues:HashAlgorithmOptions' :: HashAlgorithmOptions -> [HashAlgorithm]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [HashAlgorithm]
allowedValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashAlgorithm
defaultValue