{-# 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.LicenseManager.Types.Issuer
-- 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.LicenseManager.Types.Issuer where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details about the issuer of a license.
--
-- /See:/ 'newIssuer' smart constructor.
data Issuer = Issuer'
  { -- | Asymmetric KMS key from Key Management Service. The KMS key must have a
    -- key usage of sign and verify, and support the RSASSA-PSS SHA-256 signing
    -- algorithm.
    Issuer -> Maybe Text
signKey :: Prelude.Maybe Prelude.Text,
    -- | Issuer name.
    Issuer -> Text
name :: Prelude.Text
  }
  deriving (Issuer -> Issuer -> Bool
(Issuer -> Issuer -> Bool)
-> (Issuer -> Issuer -> Bool) -> Eq Issuer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Issuer -> Issuer -> Bool
$c/= :: Issuer -> Issuer -> Bool
== :: Issuer -> Issuer -> Bool
$c== :: Issuer -> Issuer -> Bool
Prelude.Eq, ReadPrec [Issuer]
ReadPrec Issuer
Int -> ReadS Issuer
ReadS [Issuer]
(Int -> ReadS Issuer)
-> ReadS [Issuer]
-> ReadPrec Issuer
-> ReadPrec [Issuer]
-> Read Issuer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Issuer]
$creadListPrec :: ReadPrec [Issuer]
readPrec :: ReadPrec Issuer
$creadPrec :: ReadPrec Issuer
readList :: ReadS [Issuer]
$creadList :: ReadS [Issuer]
readsPrec :: Int -> ReadS Issuer
$creadsPrec :: Int -> ReadS Issuer
Prelude.Read, Int -> Issuer -> ShowS
[Issuer] -> ShowS
Issuer -> String
(Int -> Issuer -> ShowS)
-> (Issuer -> String) -> ([Issuer] -> ShowS) -> Show Issuer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Issuer] -> ShowS
$cshowList :: [Issuer] -> ShowS
show :: Issuer -> String
$cshow :: Issuer -> String
showsPrec :: Int -> Issuer -> ShowS
$cshowsPrec :: Int -> Issuer -> ShowS
Prelude.Show, (forall x. Issuer -> Rep Issuer x)
-> (forall x. Rep Issuer x -> Issuer) -> Generic Issuer
forall x. Rep Issuer x -> Issuer
forall x. Issuer -> Rep Issuer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Issuer x -> Issuer
$cfrom :: forall x. Issuer -> Rep Issuer x
Prelude.Generic)

-- |
-- Create a value of 'Issuer' 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:
--
-- 'signKey', 'issuer_signKey' - Asymmetric KMS key from Key Management Service. The KMS key must have a
-- key usage of sign and verify, and support the RSASSA-PSS SHA-256 signing
-- algorithm.
--
-- 'name', 'issuer_name' - Issuer name.
newIssuer ::
  -- | 'name'
  Prelude.Text ->
  Issuer
newIssuer :: Text -> Issuer
newIssuer Text
pName_ =
  Issuer' :: Maybe Text -> Text -> Issuer
Issuer' {$sel:signKey:Issuer' :: Maybe Text
signKey = Maybe Text
forall a. Maybe a
Prelude.Nothing, $sel:name:Issuer' :: Text
name = Text
pName_}

-- | Asymmetric KMS key from Key Management Service. The KMS key must have a
-- key usage of sign and verify, and support the RSASSA-PSS SHA-256 signing
-- algorithm.
issuer_signKey :: Lens.Lens' Issuer (Prelude.Maybe Prelude.Text)
issuer_signKey :: (Maybe Text -> f (Maybe Text)) -> Issuer -> f Issuer
issuer_signKey = (Issuer -> Maybe Text)
-> (Issuer -> Maybe Text -> Issuer)
-> Lens Issuer Issuer (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Issuer' {Maybe Text
signKey :: Maybe Text
$sel:signKey:Issuer' :: Issuer -> Maybe Text
signKey} -> Maybe Text
signKey) (\s :: Issuer
s@Issuer' {} Maybe Text
a -> Issuer
s {$sel:signKey:Issuer' :: Maybe Text
signKey = Maybe Text
a} :: Issuer)

-- | Issuer name.
issuer_name :: Lens.Lens' Issuer Prelude.Text
issuer_name :: (Text -> f Text) -> Issuer -> f Issuer
issuer_name = (Issuer -> Text)
-> (Issuer -> Text -> Issuer) -> Lens Issuer Issuer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Issuer' {Text
name :: Text
$sel:name:Issuer' :: Issuer -> Text
name} -> Text
name) (\s :: Issuer
s@Issuer' {} Text
a -> Issuer
s {$sel:name:Issuer' :: Text
name = Text
a} :: Issuer)

instance Prelude.Hashable Issuer

instance Prelude.NFData Issuer

instance Core.ToJSON Issuer where
  toJSON :: Issuer -> Value
toJSON Issuer' {Maybe Text
Text
name :: Text
signKey :: Maybe Text
$sel:name:Issuer' :: Issuer -> Text
$sel:signKey:Issuer' :: Issuer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SignKey" 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
signKey,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )