{-# 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.APIGateway.Types.ClientCertificate
-- 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.APIGateway.Types.ClientCertificate 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

-- | Represents a client certificate used to configure client-side SSL
-- authentication while sending requests to the integration endpoint.
--
-- /See:/ 'newClientCertificate' smart constructor.
data ClientCertificate = ClientCertificate'
  { -- | The identifier of the client certificate.
    ClientCertificate -> Maybe Text
clientCertificateId :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the client certificate was created.
    ClientCertificate -> Maybe POSIX
createdDate :: Prelude.Maybe Data.POSIX,
    -- | The description of the client certificate.
    ClientCertificate -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the client certificate will expire.
    ClientCertificate -> Maybe POSIX
expirationDate :: Prelude.Maybe Data.POSIX,
    -- | The PEM-encoded public key of the client certificate, which can be used
    -- to configure certificate authentication in the integration endpoint .
    ClientCertificate -> Maybe Text
pemEncodedCertificate :: Prelude.Maybe Prelude.Text,
    -- | The collection of tags. Each tag element is associated with a given
    -- resource.
    ClientCertificate -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ClientCertificate -> ClientCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientCertificate -> ClientCertificate -> Bool
$c/= :: ClientCertificate -> ClientCertificate -> Bool
== :: ClientCertificate -> ClientCertificate -> Bool
$c== :: ClientCertificate -> ClientCertificate -> Bool
Prelude.Eq, ReadPrec [ClientCertificate]
ReadPrec ClientCertificate
Int -> ReadS ClientCertificate
ReadS [ClientCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClientCertificate]
$creadListPrec :: ReadPrec [ClientCertificate]
readPrec :: ReadPrec ClientCertificate
$creadPrec :: ReadPrec ClientCertificate
readList :: ReadS [ClientCertificate]
$creadList :: ReadS [ClientCertificate]
readsPrec :: Int -> ReadS ClientCertificate
$creadsPrec :: Int -> ReadS ClientCertificate
Prelude.Read, Int -> ClientCertificate -> ShowS
[ClientCertificate] -> ShowS
ClientCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientCertificate] -> ShowS
$cshowList :: [ClientCertificate] -> ShowS
show :: ClientCertificate -> String
$cshow :: ClientCertificate -> String
showsPrec :: Int -> ClientCertificate -> ShowS
$cshowsPrec :: Int -> ClientCertificate -> ShowS
Prelude.Show, forall x. Rep ClientCertificate x -> ClientCertificate
forall x. ClientCertificate -> Rep ClientCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClientCertificate x -> ClientCertificate
$cfrom :: forall x. ClientCertificate -> Rep ClientCertificate x
Prelude.Generic)

-- |
-- Create a value of 'ClientCertificate' 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:
--
-- 'clientCertificateId', 'clientCertificate_clientCertificateId' - The identifier of the client certificate.
--
-- 'createdDate', 'clientCertificate_createdDate' - The timestamp when the client certificate was created.
--
-- 'description', 'clientCertificate_description' - The description of the client certificate.
--
-- 'expirationDate', 'clientCertificate_expirationDate' - The timestamp when the client certificate will expire.
--
-- 'pemEncodedCertificate', 'clientCertificate_pemEncodedCertificate' - The PEM-encoded public key of the client certificate, which can be used
-- to configure certificate authentication in the integration endpoint .
--
-- 'tags', 'clientCertificate_tags' - The collection of tags. Each tag element is associated with a given
-- resource.
newClientCertificate ::
  ClientCertificate
newClientCertificate :: ClientCertificate
newClientCertificate =
  ClientCertificate'
    { $sel:clientCertificateId:ClientCertificate' :: Maybe Text
clientCertificateId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:createdDate:ClientCertificate' :: Maybe POSIX
createdDate = forall a. Maybe a
Prelude.Nothing,
      $sel:description:ClientCertificate' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:ClientCertificate' :: Maybe POSIX
expirationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:pemEncodedCertificate:ClientCertificate' :: Maybe Text
pemEncodedCertificate = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ClientCertificate' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the client certificate.
clientCertificate_clientCertificateId :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.Text)
clientCertificate_clientCertificateId :: Lens' ClientCertificate (Maybe Text)
clientCertificate_clientCertificateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe Text
clientCertificateId :: Maybe Text
$sel:clientCertificateId:ClientCertificate' :: ClientCertificate -> Maybe Text
clientCertificateId} -> Maybe Text
clientCertificateId) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe Text
a -> ClientCertificate
s {$sel:clientCertificateId:ClientCertificate' :: Maybe Text
clientCertificateId = Maybe Text
a} :: ClientCertificate)

-- | The timestamp when the client certificate was created.
clientCertificate_createdDate :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.UTCTime)
clientCertificate_createdDate :: Lens' ClientCertificate (Maybe UTCTime)
clientCertificate_createdDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe POSIX
createdDate :: Maybe POSIX
$sel:createdDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
createdDate} -> Maybe POSIX
createdDate) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe POSIX
a -> ClientCertificate
s {$sel:createdDate:ClientCertificate' :: Maybe POSIX
createdDate = Maybe POSIX
a} :: ClientCertificate) 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 description of the client certificate.
clientCertificate_description :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.Text)
clientCertificate_description :: Lens' ClientCertificate (Maybe Text)
clientCertificate_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe Text
description :: Maybe Text
$sel:description:ClientCertificate' :: ClientCertificate -> Maybe Text
description} -> Maybe Text
description) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe Text
a -> ClientCertificate
s {$sel:description:ClientCertificate' :: Maybe Text
description = Maybe Text
a} :: ClientCertificate)

-- | The timestamp when the client certificate will expire.
clientCertificate_expirationDate :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.UTCTime)
clientCertificate_expirationDate :: Lens' ClientCertificate (Maybe UTCTime)
clientCertificate_expirationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe POSIX
expirationDate :: Maybe POSIX
$sel:expirationDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
expirationDate} -> Maybe POSIX
expirationDate) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe POSIX
a -> ClientCertificate
s {$sel:expirationDate:ClientCertificate' :: Maybe POSIX
expirationDate = Maybe POSIX
a} :: ClientCertificate) 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 PEM-encoded public key of the client certificate, which can be used
-- to configure certificate authentication in the integration endpoint .
clientCertificate_pemEncodedCertificate :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.Text)
clientCertificate_pemEncodedCertificate :: Lens' ClientCertificate (Maybe Text)
clientCertificate_pemEncodedCertificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe Text
pemEncodedCertificate :: Maybe Text
$sel:pemEncodedCertificate:ClientCertificate' :: ClientCertificate -> Maybe Text
pemEncodedCertificate} -> Maybe Text
pemEncodedCertificate) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe Text
a -> ClientCertificate
s {$sel:pemEncodedCertificate:ClientCertificate' :: Maybe Text
pemEncodedCertificate = Maybe Text
a} :: ClientCertificate)

-- | The collection of tags. Each tag element is associated with a given
-- resource.
clientCertificate_tags :: Lens.Lens' ClientCertificate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
clientCertificate_tags :: Lens' ClientCertificate (Maybe (HashMap Text Text))
clientCertificate_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClientCertificate' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:ClientCertificate' :: ClientCertificate -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: ClientCertificate
s@ClientCertificate' {} Maybe (HashMap Text Text)
a -> ClientCertificate
s {$sel:tags:ClientCertificate' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: ClientCertificate) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ClientCertificate where
  parseJSON :: Value -> Parser ClientCertificate
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClientCertificate"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe (HashMap Text Text)
-> ClientCertificate
ClientCertificate'
            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
"clientCertificateId")
            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
"createdDate")
            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
"description")
            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
"expirationDate")
            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
"pemEncodedCertificate")
            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
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ClientCertificate where
  hashWithSalt :: Int -> ClientCertificate -> Int
hashWithSalt Int
_salt ClientCertificate' {Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
tags :: Maybe (HashMap Text Text)
pemEncodedCertificate :: Maybe Text
expirationDate :: Maybe POSIX
description :: Maybe Text
createdDate :: Maybe POSIX
clientCertificateId :: Maybe Text
$sel:tags:ClientCertificate' :: ClientCertificate -> Maybe (HashMap Text Text)
$sel:pemEncodedCertificate:ClientCertificate' :: ClientCertificate -> Maybe Text
$sel:expirationDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
$sel:description:ClientCertificate' :: ClientCertificate -> Maybe Text
$sel:createdDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
$sel:clientCertificateId:ClientCertificate' :: ClientCertificate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientCertificateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expirationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pemEncodedCertificate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags

instance Prelude.NFData ClientCertificate where
  rnf :: ClientCertificate -> ()
rnf ClientCertificate' {Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
tags :: Maybe (HashMap Text Text)
pemEncodedCertificate :: Maybe Text
expirationDate :: Maybe POSIX
description :: Maybe Text
createdDate :: Maybe POSIX
clientCertificateId :: Maybe Text
$sel:tags:ClientCertificate' :: ClientCertificate -> Maybe (HashMap Text Text)
$sel:pemEncodedCertificate:ClientCertificate' :: ClientCertificate -> Maybe Text
$sel:expirationDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
$sel:description:ClientCertificate' :: ClientCertificate -> Maybe Text
$sel:createdDate:ClientCertificate' :: ClientCertificate -> Maybe POSIX
$sel:clientCertificateId:ClientCertificate' :: ClientCertificate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientCertificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expirationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pemEncodedCertificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags