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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(HashAlgorithmOptions -> HashAlgorithmOptions -> Bool)
-> (HashAlgorithmOptions -> HashAlgorithmOptions -> Bool)
-> Eq HashAlgorithmOptions
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]
(Int -> ReadS HashAlgorithmOptions)
-> ReadS [HashAlgorithmOptions]
-> ReadPrec HashAlgorithmOptions
-> ReadPrec [HashAlgorithmOptions]
-> Read 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
(Int -> HashAlgorithmOptions -> ShowS)
-> (HashAlgorithmOptions -> String)
-> ([HashAlgorithmOptions] -> ShowS)
-> Show HashAlgorithmOptions
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. HashAlgorithmOptions -> Rep HashAlgorithmOptions x)
-> (forall x. Rep HashAlgorithmOptions x -> HashAlgorithmOptions)
-> Generic HashAlgorithmOptions
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' :: [HashAlgorithm] -> HashAlgorithm -> HashAlgorithmOptions
HashAlgorithmOptions'
    { $sel:allowedValues:HashAlgorithmOptions' :: [HashAlgorithm]
allowedValues =
        [HashAlgorithm]
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 :: ([HashAlgorithm] -> f [HashAlgorithm])
-> HashAlgorithmOptions -> f HashAlgorithmOptions
hashAlgorithmOptions_allowedValues = (HashAlgorithmOptions -> [HashAlgorithm])
-> (HashAlgorithmOptions
    -> [HashAlgorithm] -> HashAlgorithmOptions)
-> Lens
     HashAlgorithmOptions
     HashAlgorithmOptions
     [HashAlgorithm]
     [HashAlgorithm]
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) (([HashAlgorithm] -> f [HashAlgorithm])
 -> HashAlgorithmOptions -> f HashAlgorithmOptions)
-> (([HashAlgorithm] -> f [HashAlgorithm])
    -> [HashAlgorithm] -> f [HashAlgorithm])
-> ([HashAlgorithm] -> f [HashAlgorithm])
-> HashAlgorithmOptions
-> f HashAlgorithmOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([HashAlgorithm] -> f [HashAlgorithm])
-> [HashAlgorithm] -> f [HashAlgorithm]
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 :: (HashAlgorithm -> f HashAlgorithm)
-> HashAlgorithmOptions -> f HashAlgorithmOptions
hashAlgorithmOptions_defaultValue = (HashAlgorithmOptions -> HashAlgorithm)
-> (HashAlgorithmOptions -> HashAlgorithm -> HashAlgorithmOptions)
-> Lens
     HashAlgorithmOptions
     HashAlgorithmOptions
     HashAlgorithm
     HashAlgorithm
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 Core.FromJSON HashAlgorithmOptions where
  parseJSON :: Value -> Parser HashAlgorithmOptions
parseJSON =
    String
-> (Object -> Parser HashAlgorithmOptions)
-> Value
-> Parser HashAlgorithmOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HashAlgorithmOptions"
      ( \Object
x ->
          [HashAlgorithm] -> HashAlgorithm -> HashAlgorithmOptions
HashAlgorithmOptions'
            ([HashAlgorithm] -> HashAlgorithm -> HashAlgorithmOptions)
-> Parser [HashAlgorithm]
-> Parser (HashAlgorithm -> HashAlgorithmOptions)
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
"allowedValues" Parser (Maybe [HashAlgorithm])
-> [HashAlgorithm] -> Parser [HashAlgorithm]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [HashAlgorithm]
forall a. Monoid a => a
Prelude.mempty)
            Parser (HashAlgorithm -> HashAlgorithmOptions)
-> Parser HashAlgorithm -> Parser HashAlgorithmOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser HashAlgorithm
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"defaultValue")
      )

instance Prelude.Hashable HashAlgorithmOptions

instance Prelude.NFData HashAlgorithmOptions