{-# 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.RolesAnywhere.Types.CredentialSummary
-- 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.RolesAnywhere.Types.CredentialSummary 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

-- | A record of a presented X509 credential to
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>.
--
-- /See:/ 'newCredentialSummary' smart constructor.
data CredentialSummary = CredentialSummary'
  { -- | Indicates whether the credential is enabled.
    CredentialSummary -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether the
    -- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
    -- operation was successful.
    CredentialSummary -> Maybe Bool
failed :: Prelude.Maybe Prelude.Bool,
    -- | The fully qualified domain name of the issuing certificate for the
    -- presented end-entity certificate.
    CredentialSummary -> Maybe Text
issuer :: Prelude.Maybe Prelude.Text,
    -- | The ISO-8601 time stamp of when the certificate was last used in a
    -- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
    -- operation.
    CredentialSummary -> Maybe ISO8601
seenAt :: Prelude.Maybe Data.ISO8601,
    -- | The serial number of the certificate.
    CredentialSummary -> Maybe Text
serialNumber :: Prelude.Maybe Prelude.Text,
    -- | The PEM-encoded data of the certificate.
    CredentialSummary -> Maybe Text
x509CertificateData :: Prelude.Maybe Prelude.Text
  }
  deriving (CredentialSummary -> CredentialSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CredentialSummary -> CredentialSummary -> Bool
$c/= :: CredentialSummary -> CredentialSummary -> Bool
== :: CredentialSummary -> CredentialSummary -> Bool
$c== :: CredentialSummary -> CredentialSummary -> Bool
Prelude.Eq, ReadPrec [CredentialSummary]
ReadPrec CredentialSummary
Int -> ReadS CredentialSummary
ReadS [CredentialSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CredentialSummary]
$creadListPrec :: ReadPrec [CredentialSummary]
readPrec :: ReadPrec CredentialSummary
$creadPrec :: ReadPrec CredentialSummary
readList :: ReadS [CredentialSummary]
$creadList :: ReadS [CredentialSummary]
readsPrec :: Int -> ReadS CredentialSummary
$creadsPrec :: Int -> ReadS CredentialSummary
Prelude.Read, Int -> CredentialSummary -> ShowS
[CredentialSummary] -> ShowS
CredentialSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CredentialSummary] -> ShowS
$cshowList :: [CredentialSummary] -> ShowS
show :: CredentialSummary -> String
$cshow :: CredentialSummary -> String
showsPrec :: Int -> CredentialSummary -> ShowS
$cshowsPrec :: Int -> CredentialSummary -> ShowS
Prelude.Show, forall x. Rep CredentialSummary x -> CredentialSummary
forall x. CredentialSummary -> Rep CredentialSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CredentialSummary x -> CredentialSummary
$cfrom :: forall x. CredentialSummary -> Rep CredentialSummary x
Prelude.Generic)

-- |
-- Create a value of 'CredentialSummary' 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:
--
-- 'enabled', 'credentialSummary_enabled' - Indicates whether the credential is enabled.
--
-- 'failed', 'credentialSummary_failed' - Indicates whether the
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
-- operation was successful.
--
-- 'issuer', 'credentialSummary_issuer' - The fully qualified domain name of the issuing certificate for the
-- presented end-entity certificate.
--
-- 'seenAt', 'credentialSummary_seenAt' - The ISO-8601 time stamp of when the certificate was last used in a
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
-- operation.
--
-- 'serialNumber', 'credentialSummary_serialNumber' - The serial number of the certificate.
--
-- 'x509CertificateData', 'credentialSummary_x509CertificateData' - The PEM-encoded data of the certificate.
newCredentialSummary ::
  CredentialSummary
newCredentialSummary :: CredentialSummary
newCredentialSummary =
  CredentialSummary'
    { $sel:enabled:CredentialSummary' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:failed:CredentialSummary' :: Maybe Bool
failed = forall a. Maybe a
Prelude.Nothing,
      $sel:issuer:CredentialSummary' :: Maybe Text
issuer = forall a. Maybe a
Prelude.Nothing,
      $sel:seenAt:CredentialSummary' :: Maybe ISO8601
seenAt = forall a. Maybe a
Prelude.Nothing,
      $sel:serialNumber:CredentialSummary' :: Maybe Text
serialNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:x509CertificateData:CredentialSummary' :: Maybe Text
x509CertificateData = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the credential is enabled.
credentialSummary_enabled :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.Bool)
credentialSummary_enabled :: Lens' CredentialSummary (Maybe Bool)
credentialSummary_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:CredentialSummary' :: CredentialSummary -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe Bool
a -> CredentialSummary
s {$sel:enabled:CredentialSummary' :: Maybe Bool
enabled = Maybe Bool
a} :: CredentialSummary)

-- | Indicates whether the
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
-- operation was successful.
credentialSummary_failed :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.Bool)
credentialSummary_failed :: Lens' CredentialSummary (Maybe Bool)
credentialSummary_failed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe Bool
failed :: Maybe Bool
$sel:failed:CredentialSummary' :: CredentialSummary -> Maybe Bool
failed} -> Maybe Bool
failed) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe Bool
a -> CredentialSummary
s {$sel:failed:CredentialSummary' :: Maybe Bool
failed = Maybe Bool
a} :: CredentialSummary)

-- | The fully qualified domain name of the issuing certificate for the
-- presented end-entity certificate.
credentialSummary_issuer :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.Text)
credentialSummary_issuer :: Lens' CredentialSummary (Maybe Text)
credentialSummary_issuer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe Text
issuer :: Maybe Text
$sel:issuer:CredentialSummary' :: CredentialSummary -> Maybe Text
issuer} -> Maybe Text
issuer) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe Text
a -> CredentialSummary
s {$sel:issuer:CredentialSummary' :: Maybe Text
issuer = Maybe Text
a} :: CredentialSummary)

-- | The ISO-8601 time stamp of when the certificate was last used in a
-- <https://docs.aws.amazon.com/rolesanywhere/latest/APIReference/API_CreateSession.html CreateSession>
-- operation.
credentialSummary_seenAt :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.UTCTime)
credentialSummary_seenAt :: Lens' CredentialSummary (Maybe UTCTime)
credentialSummary_seenAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe ISO8601
seenAt :: Maybe ISO8601
$sel:seenAt:CredentialSummary' :: CredentialSummary -> Maybe ISO8601
seenAt} -> Maybe ISO8601
seenAt) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe ISO8601
a -> CredentialSummary
s {$sel:seenAt:CredentialSummary' :: Maybe ISO8601
seenAt = Maybe ISO8601
a} :: CredentialSummary) 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 serial number of the certificate.
credentialSummary_serialNumber :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.Text)
credentialSummary_serialNumber :: Lens' CredentialSummary (Maybe Text)
credentialSummary_serialNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe Text
serialNumber :: Maybe Text
$sel:serialNumber:CredentialSummary' :: CredentialSummary -> Maybe Text
serialNumber} -> Maybe Text
serialNumber) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe Text
a -> CredentialSummary
s {$sel:serialNumber:CredentialSummary' :: Maybe Text
serialNumber = Maybe Text
a} :: CredentialSummary)

-- | The PEM-encoded data of the certificate.
credentialSummary_x509CertificateData :: Lens.Lens' CredentialSummary (Prelude.Maybe Prelude.Text)
credentialSummary_x509CertificateData :: Lens' CredentialSummary (Maybe Text)
credentialSummary_x509CertificateData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CredentialSummary' {Maybe Text
x509CertificateData :: Maybe Text
$sel:x509CertificateData:CredentialSummary' :: CredentialSummary -> Maybe Text
x509CertificateData} -> Maybe Text
x509CertificateData) (\s :: CredentialSummary
s@CredentialSummary' {} Maybe Text
a -> CredentialSummary
s {$sel:x509CertificateData:CredentialSummary' :: Maybe Text
x509CertificateData = Maybe Text
a} :: CredentialSummary)

instance Data.FromJSON CredentialSummary where
  parseJSON :: Value -> Parser CredentialSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CredentialSummary"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe Text
-> Maybe ISO8601
-> Maybe Text
-> Maybe Text
-> CredentialSummary
CredentialSummary'
            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
"enabled")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"failed")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"issuer")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"seenAt")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serialNumber")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"x509CertificateData")
      )

instance Prelude.Hashable CredentialSummary where
  hashWithSalt :: Int -> CredentialSummary -> Int
hashWithSalt Int
_salt CredentialSummary' {Maybe Bool
Maybe Text
Maybe ISO8601
x509CertificateData :: Maybe Text
serialNumber :: Maybe Text
seenAt :: Maybe ISO8601
issuer :: Maybe Text
failed :: Maybe Bool
enabled :: Maybe Bool
$sel:x509CertificateData:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:serialNumber:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:seenAt:CredentialSummary' :: CredentialSummary -> Maybe ISO8601
$sel:issuer:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:failed:CredentialSummary' :: CredentialSummary -> Maybe Bool
$sel:enabled:CredentialSummary' :: CredentialSummary -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
failed
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
issuer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
seenAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serialNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
x509CertificateData

instance Prelude.NFData CredentialSummary where
  rnf :: CredentialSummary -> ()
rnf CredentialSummary' {Maybe Bool
Maybe Text
Maybe ISO8601
x509CertificateData :: Maybe Text
serialNumber :: Maybe Text
seenAt :: Maybe ISO8601
issuer :: Maybe Text
failed :: Maybe Bool
enabled :: Maybe Bool
$sel:x509CertificateData:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:serialNumber:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:seenAt:CredentialSummary' :: CredentialSummary -> Maybe ISO8601
$sel:issuer:CredentialSummary' :: CredentialSummary -> Maybe Text
$sel:failed:CredentialSummary' :: CredentialSummary -> Maybe Bool
$sel:enabled:CredentialSummary' :: CredentialSummary -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
failed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
issuer
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
seenAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serialNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
x509CertificateData