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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a client certificate used to configure client-side SSL
-- authentication while sending requests to the integration endpoint.
--
-- Client certificates are used to authenticate an API by the backend
-- server. To authenticate an API client (or user), use IAM roles and
-- policies, a custom Authorizer or an Amazon Cognito user pool.
--
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html Use Client-Side Certificate>
--
-- /See:/ 'newClientCertificate' smart constructor.
data ClientCertificate = ClientCertificate'
  { -- | 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 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 Core.POSIX,
    -- | The timestamp when the client certificate will expire.
    ClientCertificate -> Maybe POSIX
expirationDate :: Prelude.Maybe Core.POSIX,
    -- | The description of the client certificate.
    ClientCertificate -> Maybe Text
description :: 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
(ClientCertificate -> ClientCertificate -> Bool)
-> (ClientCertificate -> ClientCertificate -> Bool)
-> Eq ClientCertificate
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]
(Int -> ReadS ClientCertificate)
-> ReadS [ClientCertificate]
-> ReadPrec ClientCertificate
-> ReadPrec [ClientCertificate]
-> Read 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
(Int -> ClientCertificate -> ShowS)
-> (ClientCertificate -> String)
-> ([ClientCertificate] -> ShowS)
-> Show ClientCertificate
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. ClientCertificate -> Rep ClientCertificate x)
-> (forall x. Rep ClientCertificate x -> ClientCertificate)
-> Generic ClientCertificate
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:
--
-- 'pemEncodedCertificate', 'clientCertificate_pemEncodedCertificate' - The PEM-encoded public key of the client certificate, which can be used
-- to configure certificate authentication in the integration endpoint .
--
-- 'clientCertificateId', 'clientCertificate_clientCertificateId' - The identifier of the client certificate.
--
-- 'createdDate', 'clientCertificate_createdDate' - The timestamp when the client certificate was created.
--
-- 'expirationDate', 'clientCertificate_expirationDate' - The timestamp when the client certificate will expire.
--
-- 'description', 'clientCertificate_description' - The description of the client certificate.
--
-- 'tags', 'clientCertificate_tags' - The collection of tags. Each tag element is associated with a given
-- resource.
newClientCertificate ::
  ClientCertificate
newClientCertificate :: ClientCertificate
newClientCertificate =
  ClientCertificate' :: Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe (HashMap Text Text)
-> ClientCertificate
ClientCertificate'
    { $sel:pemEncodedCertificate:ClientCertificate' :: Maybe Text
pemEncodedCertificate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clientCertificateId:ClientCertificate' :: Maybe Text
clientCertificateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdDate:ClientCertificate' :: Maybe POSIX
createdDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationDate:ClientCertificate' :: Maybe POSIX
expirationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ClientCertificate' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:ClientCertificate' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ClientCertificate -> f ClientCertificate
clientCertificate_pemEncodedCertificate = (ClientCertificate -> Maybe Text)
-> (ClientCertificate -> Maybe Text -> ClientCertificate)
-> Lens
     ClientCertificate ClientCertificate (Maybe Text) (Maybe Text)
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 identifier of the client certificate.
clientCertificate_clientCertificateId :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.Text)
clientCertificate_clientCertificateId :: (Maybe Text -> f (Maybe Text))
-> ClientCertificate -> f ClientCertificate
clientCertificate_clientCertificateId = (ClientCertificate -> Maybe Text)
-> (ClientCertificate -> Maybe Text -> ClientCertificate)
-> Lens
     ClientCertificate ClientCertificate (Maybe Text) (Maybe Text)
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ClientCertificate -> f ClientCertificate
clientCertificate_createdDate = (ClientCertificate -> Maybe POSIX)
-> (ClientCertificate -> Maybe POSIX -> ClientCertificate)
-> Lens
     ClientCertificate ClientCertificate (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> ClientCertificate -> f ClientCertificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ClientCertificate
-> f ClientCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The timestamp when the client certificate will expire.
clientCertificate_expirationDate :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.UTCTime)
clientCertificate_expirationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ClientCertificate -> f ClientCertificate
clientCertificate_expirationDate = (ClientCertificate -> Maybe POSIX)
-> (ClientCertificate -> Maybe POSIX -> ClientCertificate)
-> Lens
     ClientCertificate ClientCertificate (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX))
 -> ClientCertificate -> f ClientCertificate)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ClientCertificate
-> f ClientCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The description of the client certificate.
clientCertificate_description :: Lens.Lens' ClientCertificate (Prelude.Maybe Prelude.Text)
clientCertificate_description :: (Maybe Text -> f (Maybe Text))
-> ClientCertificate -> f ClientCertificate
clientCertificate_description = (ClientCertificate -> Maybe Text)
-> (ClientCertificate -> Maybe Text -> ClientCertificate)
-> Lens
     ClientCertificate ClientCertificate (Maybe Text) (Maybe Text)
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 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ClientCertificate -> f ClientCertificate
clientCertificate_tags = (ClientCertificate -> Maybe (HashMap Text Text))
-> (ClientCertificate
    -> Maybe (HashMap Text Text) -> ClientCertificate)
-> Lens
     ClientCertificate
     ClientCertificate
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ClientCertificate -> f ClientCertificate)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ClientCertificate
-> f ClientCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ClientCertificate where
  parseJSON :: Value -> Parser ClientCertificate
parseJSON =
    String
-> (Object -> Parser ClientCertificate)
-> Value
-> Parser ClientCertificate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ClientCertificate"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe (HashMap Text Text)
-> ClientCertificate
ClientCertificate'
            (Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> ClientCertificate)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> ClientCertificate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pemEncodedCertificate")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> ClientCertificate)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> ClientCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"clientCertificateId")
            Parser
  (Maybe POSIX
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> ClientCertificate)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe (HashMap Text Text) -> ClientCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdDate")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe (HashMap Text Text) -> ClientCertificate)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> ClientCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"expirationDate")
            Parser
  (Maybe Text -> Maybe (HashMap Text Text) -> ClientCertificate)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> ClientCertificate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"description")
            Parser (Maybe (HashMap Text Text) -> ClientCertificate)
-> Parser (Maybe (HashMap Text Text)) -> Parser ClientCertificate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ClientCertificate

instance Prelude.NFData ClientCertificate