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

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.StatusType
import qualified Amazonka.Lens as Lens
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 Core.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
(SigningCertificate -> SigningCertificate -> Bool)
-> (SigningCertificate -> SigningCertificate -> Bool)
-> Eq SigningCertificate
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]
(Int -> ReadS SigningCertificate)
-> ReadS [SigningCertificate]
-> ReadPrec SigningCertificate
-> ReadPrec [SigningCertificate]
-> Read 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
(Int -> SigningCertificate -> ShowS)
-> (SigningCertificate -> String)
-> ([SigningCertificate] -> ShowS)
-> Show SigningCertificate
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. SigningCertificate -> Rep SigningCertificate x)
-> (forall x. Rep SigningCertificate x -> SigningCertificate)
-> Generic SigningCertificate
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' :: Maybe ISO8601
-> Text -> Text -> Text -> StatusType -> SigningCertificate
SigningCertificate'
      { $sel:uploadDate:SigningCertificate' :: Maybe ISO8601
uploadDate = Maybe ISO8601
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SigningCertificate -> f SigningCertificate
signingCertificate_uploadDate = (SigningCertificate -> Maybe ISO8601)
-> (SigningCertificate -> Maybe ISO8601 -> SigningCertificate)
-> Lens
     SigningCertificate
     SigningCertificate
     (Maybe ISO8601)
     (Maybe ISO8601)
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) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> SigningCertificate -> f SigningCertificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SigningCertificate
-> f SigningCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the user the signing certificate is associated with.
signingCertificate_userName :: Lens.Lens' SigningCertificate Prelude.Text
signingCertificate_userName :: (Text -> f Text) -> SigningCertificate -> f SigningCertificate
signingCertificate_userName = (SigningCertificate -> Text)
-> (SigningCertificate -> Text -> SigningCertificate)
-> Lens SigningCertificate SigningCertificate Text Text
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 :: (Text -> f Text) -> SigningCertificate -> f SigningCertificate
signingCertificate_certificateId = (SigningCertificate -> Text)
-> (SigningCertificate -> Text -> SigningCertificate)
-> Lens SigningCertificate SigningCertificate Text Text
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 :: (Text -> f Text) -> SigningCertificate -> f SigningCertificate
signingCertificate_certificateBody = (SigningCertificate -> Text)
-> (SigningCertificate -> Text -> SigningCertificate)
-> Lens SigningCertificate SigningCertificate Text Text
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 :: (StatusType -> f StatusType)
-> SigningCertificate -> f SigningCertificate
signingCertificate_status = (SigningCertificate -> StatusType)
-> (SigningCertificate -> StatusType -> SigningCertificate)
-> Lens SigningCertificate SigningCertificate StatusType StatusType
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 Core.FromXML SigningCertificate where
  parseXML :: [Node] -> Either String SigningCertificate
parseXML [Node]
x =
    Maybe ISO8601
-> Text -> Text -> Text -> StatusType -> SigningCertificate
SigningCertificate'
      (Maybe ISO8601
 -> Text -> Text -> Text -> StatusType -> SigningCertificate)
-> Either String (Maybe ISO8601)
-> Either
     String (Text -> Text -> Text -> StatusType -> SigningCertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UploadDate")
      Either
  String (Text -> Text -> Text -> StatusType -> SigningCertificate)
-> Either String Text
-> Either String (Text -> Text -> StatusType -> SigningCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"UserName")
      Either String (Text -> Text -> StatusType -> SigningCertificate)
-> Either String Text
-> Either String (Text -> StatusType -> SigningCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CertificateId")
      Either String (Text -> StatusType -> SigningCertificate)
-> Either String Text
-> Either String (StatusType -> SigningCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CertificateBody")
      Either String (StatusType -> SigningCertificate)
-> Either String StatusType -> Either String SigningCertificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String StatusType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Status")

instance Prelude.Hashable SigningCertificate

instance Prelude.NFData SigningCertificate