{-# 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.WorkSpacesWeb.Types.Certificate
-- 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.WorkSpacesWeb.Types.Certificate 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

-- | The certificate.
--
-- /See:/ 'newCertificate' smart constructor.
data Certificate = Certificate'
  { -- | The body of the certificate.
    Certificate -> Maybe Base64
body :: Prelude.Maybe Data.Base64,
    -- | The entity that issued the certificate.
    Certificate -> Maybe Text
issuer :: Prelude.Maybe Prelude.Text,
    -- | The certificate is not valid after this date.
    Certificate -> Maybe POSIX
notValidAfter :: Prelude.Maybe Data.POSIX,
    -- | The certificate is not valid before this date.
    Certificate -> Maybe POSIX
notValidBefore :: Prelude.Maybe Data.POSIX,
    -- | The entity the certificate belongs to.
    Certificate -> Maybe Text
subject :: Prelude.Maybe Prelude.Text,
    -- | A hexadecimal identifier for the certificate.
    Certificate -> Maybe Text
thumbprint :: Prelude.Maybe Prelude.Text
  }
  deriving (Certificate -> Certificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Certificate -> Certificate -> Bool
$c/= :: Certificate -> Certificate -> Bool
== :: Certificate -> Certificate -> Bool
$c== :: Certificate -> Certificate -> Bool
Prelude.Eq, ReadPrec [Certificate]
ReadPrec Certificate
Int -> ReadS Certificate
ReadS [Certificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Certificate]
$creadListPrec :: ReadPrec [Certificate]
readPrec :: ReadPrec Certificate
$creadPrec :: ReadPrec Certificate
readList :: ReadS [Certificate]
$creadList :: ReadS [Certificate]
readsPrec :: Int -> ReadS Certificate
$creadsPrec :: Int -> ReadS Certificate
Prelude.Read, Int -> Certificate -> ShowS
[Certificate] -> ShowS
Certificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Certificate] -> ShowS
$cshowList :: [Certificate] -> ShowS
show :: Certificate -> String
$cshow :: Certificate -> String
showsPrec :: Int -> Certificate -> ShowS
$cshowsPrec :: Int -> Certificate -> ShowS
Prelude.Show, forall x. Rep Certificate x -> Certificate
forall x. Certificate -> Rep Certificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Certificate x -> Certificate
$cfrom :: forall x. Certificate -> Rep Certificate x
Prelude.Generic)

-- |
-- Create a value of 'Certificate' 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:
--
-- 'body', 'certificate_body' - The body of the certificate.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'issuer', 'certificate_issuer' - The entity that issued the certificate.
--
-- 'notValidAfter', 'certificate_notValidAfter' - The certificate is not valid after this date.
--
-- 'notValidBefore', 'certificate_notValidBefore' - The certificate is not valid before this date.
--
-- 'subject', 'certificate_subject' - The entity the certificate belongs to.
--
-- 'thumbprint', 'certificate_thumbprint' - A hexadecimal identifier for the certificate.
newCertificate ::
  Certificate
newCertificate :: Certificate
newCertificate =
  Certificate'
    { $sel:body:Certificate' :: Maybe Base64
body = forall a. Maybe a
Prelude.Nothing,
      $sel:issuer:Certificate' :: Maybe Text
issuer = forall a. Maybe a
Prelude.Nothing,
      $sel:notValidAfter:Certificate' :: Maybe POSIX
notValidAfter = forall a. Maybe a
Prelude.Nothing,
      $sel:notValidBefore:Certificate' :: Maybe POSIX
notValidBefore = forall a. Maybe a
Prelude.Nothing,
      $sel:subject:Certificate' :: Maybe Text
subject = forall a. Maybe a
Prelude.Nothing,
      $sel:thumbprint:Certificate' :: Maybe Text
thumbprint = forall a. Maybe a
Prelude.Nothing
    }

-- | The body of the certificate.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
certificate_body :: Lens.Lens' Certificate (Prelude.Maybe Prelude.ByteString)
certificate_body :: Lens' Certificate (Maybe ByteString)
certificate_body = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Base64
body :: Maybe Base64
$sel:body:Certificate' :: Certificate -> Maybe Base64
body} -> Maybe Base64
body) (\s :: Certificate
s@Certificate' {} Maybe Base64
a -> Certificate
s {$sel:body:Certificate' :: Maybe Base64
body = Maybe Base64
a} :: Certificate) 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 Iso' Base64 ByteString
Data._Base64

-- | The entity that issued the certificate.
certificate_issuer :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_issuer :: Lens' Certificate (Maybe Text)
certificate_issuer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
issuer :: Maybe Text
$sel:issuer:Certificate' :: Certificate -> Maybe Text
issuer} -> Maybe Text
issuer) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:issuer:Certificate' :: Maybe Text
issuer = Maybe Text
a} :: Certificate)

-- | The certificate is not valid after this date.
certificate_notValidAfter :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_notValidAfter :: Lens' Certificate (Maybe UTCTime)
certificate_notValidAfter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe POSIX
notValidAfter :: Maybe POSIX
$sel:notValidAfter:Certificate' :: Certificate -> Maybe POSIX
notValidAfter} -> Maybe POSIX
notValidAfter) (\s :: Certificate
s@Certificate' {} Maybe POSIX
a -> Certificate
s {$sel:notValidAfter:Certificate' :: Maybe POSIX
notValidAfter = Maybe POSIX
a} :: Certificate) 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 certificate is not valid before this date.
certificate_notValidBefore :: Lens.Lens' Certificate (Prelude.Maybe Prelude.UTCTime)
certificate_notValidBefore :: Lens' Certificate (Maybe UTCTime)
certificate_notValidBefore = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe POSIX
notValidBefore :: Maybe POSIX
$sel:notValidBefore:Certificate' :: Certificate -> Maybe POSIX
notValidBefore} -> Maybe POSIX
notValidBefore) (\s :: Certificate
s@Certificate' {} Maybe POSIX
a -> Certificate
s {$sel:notValidBefore:Certificate' :: Maybe POSIX
notValidBefore = Maybe POSIX
a} :: Certificate) 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 entity the certificate belongs to.
certificate_subject :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_subject :: Lens' Certificate (Maybe Text)
certificate_subject = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
subject :: Maybe Text
$sel:subject:Certificate' :: Certificate -> Maybe Text
subject} -> Maybe Text
subject) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:subject:Certificate' :: Maybe Text
subject = Maybe Text
a} :: Certificate)

-- | A hexadecimal identifier for the certificate.
certificate_thumbprint :: Lens.Lens' Certificate (Prelude.Maybe Prelude.Text)
certificate_thumbprint :: Lens' Certificate (Maybe Text)
certificate_thumbprint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Certificate' {Maybe Text
thumbprint :: Maybe Text
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
thumbprint} -> Maybe Text
thumbprint) (\s :: Certificate
s@Certificate' {} Maybe Text
a -> Certificate
s {$sel:thumbprint:Certificate' :: Maybe Text
thumbprint = Maybe Text
a} :: Certificate)

instance Data.FromJSON Certificate where
  parseJSON :: Value -> Parser Certificate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Certificate"
      ( \Object
x ->
          Maybe Base64
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Certificate
Certificate'
            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
"body")
            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
"notValidAfter")
            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
"notValidBefore")
            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
"subject")
            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
"thumbprint")
      )

instance Prelude.Hashable Certificate where
  hashWithSalt :: Int -> Certificate -> Int
hashWithSalt Int
_salt Certificate' {Maybe Text
Maybe Base64
Maybe POSIX
thumbprint :: Maybe Text
subject :: Maybe Text
notValidBefore :: Maybe POSIX
notValidAfter :: Maybe POSIX
issuer :: Maybe Text
body :: Maybe Base64
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
$sel:subject:Certificate' :: Certificate -> Maybe Text
$sel:notValidBefore:Certificate' :: Certificate -> Maybe POSIX
$sel:notValidAfter:Certificate' :: Certificate -> Maybe POSIX
$sel:issuer:Certificate' :: Certificate -> Maybe Text
$sel:body:Certificate' :: Certificate -> Maybe Base64
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
body
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
issuer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
notValidAfter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
notValidBefore
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subject
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thumbprint

instance Prelude.NFData Certificate where
  rnf :: Certificate -> ()
rnf Certificate' {Maybe Text
Maybe Base64
Maybe POSIX
thumbprint :: Maybe Text
subject :: Maybe Text
notValidBefore :: Maybe POSIX
notValidAfter :: Maybe POSIX
issuer :: Maybe Text
body :: Maybe Base64
$sel:thumbprint:Certificate' :: Certificate -> Maybe Text
$sel:subject:Certificate' :: Certificate -> Maybe Text
$sel:notValidBefore:Certificate' :: Certificate -> Maybe POSIX
$sel:notValidAfter:Certificate' :: Certificate -> Maybe POSIX
$sel:issuer:Certificate' :: Certificate -> Maybe Text
$sel:body:Certificate' :: Certificate -> Maybe Base64
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
body
      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 POSIX
notValidAfter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
notValidBefore
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subject
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thumbprint