{-# 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.IAM.Types.SigningCertificate
-- 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.IAM.Types.SigningCertificate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types.StatusType
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an X.509 signing certificate.
--
-- This data type is used as a response element in the
-- UploadSigningCertificate and ListSigningCertificates operations.
--
-- /See:/ 'newSigningCertificate' smart constructor.
data SigningCertificate = SigningCertificate'
  { -- | The date when the signing certificate was uploaded.
    SigningCertificate -> Maybe ISO8601
uploadDate :: Prelude.Maybe Data.ISO8601,
    -- | The name of the user the signing certificate is associated with.
    SigningCertificate -> Text
userName :: Prelude.Text,
    -- | The ID for the signing certificate.
    SigningCertificate -> Text
certificateId :: Prelude.Text,
    -- | The contents of the signing certificate.
    SigningCertificate -> Text
certificateBody :: Prelude.Text,
    -- | The status of the signing certificate. @Active@ means that the key is
    -- valid for API calls, while @Inactive@ means it is not.
    SigningCertificate -> StatusType
status :: StatusType
  }
  deriving (SigningCertificate -> SigningCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SigningCertificate -> SigningCertificate -> Bool
$c/= :: SigningCertificate -> SigningCertificate -> Bool
== :: SigningCertificate -> SigningCertificate -> Bool
$c== :: SigningCertificate -> SigningCertificate -> Bool
Prelude.Eq, ReadPrec [SigningCertificate]
ReadPrec SigningCertificate
Int -> ReadS SigningCertificate
ReadS [SigningCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SigningCertificate]
$creadListPrec :: ReadPrec [SigningCertificate]
readPrec :: ReadPrec SigningCertificate
$creadPrec :: ReadPrec SigningCertificate
readList :: ReadS [SigningCertificate]
$creadList :: ReadS [SigningCertificate]
readsPrec :: Int -> ReadS SigningCertificate
$creadsPrec :: Int -> ReadS SigningCertificate
Prelude.Read, Int -> SigningCertificate -> ShowS
[SigningCertificate] -> ShowS
SigningCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SigningCertificate] -> ShowS
$cshowList :: [SigningCertificate] -> ShowS
show :: SigningCertificate -> String
$cshow :: SigningCertificate -> String
showsPrec :: Int -> SigningCertificate -> ShowS
$cshowsPrec :: Int -> SigningCertificate -> ShowS
Prelude.Show, forall x. Rep SigningCertificate x -> SigningCertificate
forall x. SigningCertificate -> Rep SigningCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SigningCertificate x -> SigningCertificate
$cfrom :: forall x. SigningCertificate -> Rep SigningCertificate x
Prelude.Generic)

-- |
-- Create a value of 'SigningCertificate' 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:
--
-- 'uploadDate', 'signingCertificate_uploadDate' - The date when the signing certificate was uploaded.
--
-- 'userName', 'signingCertificate_userName' - The name of the user the signing certificate is associated with.
--
-- 'certificateId', 'signingCertificate_certificateId' - The ID for the signing certificate.
--
-- 'certificateBody', 'signingCertificate_certificateBody' - The contents of the signing certificate.
--
-- 'status', 'signingCertificate_status' - The status of the signing certificate. @Active@ means that the key is
-- valid for API calls, while @Inactive@ means it is not.
newSigningCertificate ::
  -- | 'userName'
  Prelude.Text ->
  -- | 'certificateId'
  Prelude.Text ->
  -- | 'certificateBody'
  Prelude.Text ->
  -- | 'status'
  StatusType ->
  SigningCertificate
newSigningCertificate :: Text -> Text -> Text -> StatusType -> SigningCertificate
newSigningCertificate
  Text
pUserName_
  Text
pCertificateId_
  Text
pCertificateBody_
  StatusType
pStatus_ =
    SigningCertificate'
      { $sel:uploadDate:SigningCertificate' :: Maybe ISO8601
uploadDate = forall a. Maybe a
Prelude.Nothing,
        $sel:userName:SigningCertificate' :: Text
userName = Text
pUserName_,
        $sel:certificateId:SigningCertificate' :: Text
certificateId = Text
pCertificateId_,
        $sel:certificateBody:SigningCertificate' :: Text
certificateBody = Text
pCertificateBody_,
        $sel:status:SigningCertificate' :: StatusType
status = StatusType
pStatus_
      }

-- | The date when the signing certificate was uploaded.
signingCertificate_uploadDate :: Lens.Lens' SigningCertificate (Prelude.Maybe Prelude.UTCTime)
signingCertificate_uploadDate :: Lens' SigningCertificate (Maybe UTCTime)
signingCertificate_uploadDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningCertificate' {Maybe ISO8601
uploadDate :: Maybe ISO8601
$sel:uploadDate:SigningCertificate' :: SigningCertificate -> Maybe ISO8601
uploadDate} -> Maybe ISO8601
uploadDate) (\s :: SigningCertificate
s@SigningCertificate' {} Maybe ISO8601
a -> SigningCertificate
s {$sel:uploadDate:SigningCertificate' :: Maybe ISO8601
uploadDate = Maybe ISO8601
a} :: SigningCertificate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the user the signing certificate is associated with.
signingCertificate_userName :: Lens.Lens' SigningCertificate Prelude.Text
signingCertificate_userName :: Lens' SigningCertificate Text
signingCertificate_userName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningCertificate' {Text
userName :: Text
$sel:userName:SigningCertificate' :: SigningCertificate -> Text
userName} -> Text
userName) (\s :: SigningCertificate
s@SigningCertificate' {} Text
a -> SigningCertificate
s {$sel:userName:SigningCertificate' :: Text
userName = Text
a} :: SigningCertificate)

-- | The ID for the signing certificate.
signingCertificate_certificateId :: Lens.Lens' SigningCertificate Prelude.Text
signingCertificate_certificateId :: Lens' SigningCertificate Text
signingCertificate_certificateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningCertificate' {Text
certificateId :: Text
$sel:certificateId:SigningCertificate' :: SigningCertificate -> Text
certificateId} -> Text
certificateId) (\s :: SigningCertificate
s@SigningCertificate' {} Text
a -> SigningCertificate
s {$sel:certificateId:SigningCertificate' :: Text
certificateId = Text
a} :: SigningCertificate)

-- | The contents of the signing certificate.
signingCertificate_certificateBody :: Lens.Lens' SigningCertificate Prelude.Text
signingCertificate_certificateBody :: Lens' SigningCertificate Text
signingCertificate_certificateBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningCertificate' {Text
certificateBody :: Text
$sel:certificateBody:SigningCertificate' :: SigningCertificate -> Text
certificateBody} -> Text
certificateBody) (\s :: SigningCertificate
s@SigningCertificate' {} Text
a -> SigningCertificate
s {$sel:certificateBody:SigningCertificate' :: Text
certificateBody = Text
a} :: SigningCertificate)

-- | The status of the signing certificate. @Active@ means that the key is
-- valid for API calls, while @Inactive@ means it is not.
signingCertificate_status :: Lens.Lens' SigningCertificate StatusType
signingCertificate_status :: Lens' SigningCertificate StatusType
signingCertificate_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SigningCertificate' {StatusType
status :: StatusType
$sel:status:SigningCertificate' :: SigningCertificate -> StatusType
status} -> StatusType
status) (\s :: SigningCertificate
s@SigningCertificate' {} StatusType
a -> SigningCertificate
s {$sel:status:SigningCertificate' :: StatusType
status = StatusType
a} :: SigningCertificate)

instance Data.FromXML SigningCertificate where
  parseXML :: [Node] -> Either String SigningCertificate
parseXML [Node]
x =
    Maybe ISO8601
-> Text -> Text -> Text -> StatusType -> SigningCertificate
SigningCertificate'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"UploadDate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"UserName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CertificateId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"CertificateBody")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Status")

instance Prelude.Hashable SigningCertificate where
  hashWithSalt :: Int -> SigningCertificate -> Int
hashWithSalt Int
_salt SigningCertificate' {Maybe ISO8601
Text
StatusType
status :: StatusType
certificateBody :: Text
certificateId :: Text
userName :: Text
uploadDate :: Maybe ISO8601
$sel:status:SigningCertificate' :: SigningCertificate -> StatusType
$sel:certificateBody:SigningCertificate' :: SigningCertificate -> Text
$sel:certificateId:SigningCertificate' :: SigningCertificate -> Text
$sel:userName:SigningCertificate' :: SigningCertificate -> Text
$sel:uploadDate:SigningCertificate' :: SigningCertificate -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
uploadDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StatusType
status

instance Prelude.NFData SigningCertificate where
  rnf :: SigningCertificate -> ()
rnf SigningCertificate' {Maybe ISO8601
Text
StatusType
status :: StatusType
certificateBody :: Text
certificateId :: Text
userName :: Text
uploadDate :: Maybe ISO8601
$sel:status:SigningCertificate' :: SigningCertificate -> StatusType
$sel:certificateBody:SigningCertificate' :: SigningCertificate -> Text
$sel:certificateId:SigningCertificate' :: SigningCertificate -> Text
$sel:userName:SigningCertificate' :: SigningCertificate -> Text
$sel:uploadDate:SigningCertificate' :: SigningCertificate -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
uploadDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
certificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
certificateBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StatusType
status