{-# 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.OpsWorks.Types.SslConfiguration
-- 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.OpsWorks.Types.SslConfiguration 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

-- | Describes an app\'s SSL configuration.
--
-- /See:/ 'newSslConfiguration' smart constructor.
data SslConfiguration = SslConfiguration'
  { -- | The contents of the certificate\'s domain.crt file.
    SslConfiguration -> Maybe Text
certificate :: Prelude.Maybe Prelude.Text,
    -- | Optional. Can be used to specify an intermediate certificate authority
    -- key or client authentication.
    SslConfiguration -> Maybe Text
chain :: Prelude.Maybe Prelude.Text,
    -- | The private key; the contents of the certificate\'s domain.kex file.
    SslConfiguration -> Maybe Text
privateKey :: Prelude.Maybe Prelude.Text
  }
  deriving (SslConfiguration -> SslConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SslConfiguration -> SslConfiguration -> Bool
$c/= :: SslConfiguration -> SslConfiguration -> Bool
== :: SslConfiguration -> SslConfiguration -> Bool
$c== :: SslConfiguration -> SslConfiguration -> Bool
Prelude.Eq, ReadPrec [SslConfiguration]
ReadPrec SslConfiguration
Int -> ReadS SslConfiguration
ReadS [SslConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SslConfiguration]
$creadListPrec :: ReadPrec [SslConfiguration]
readPrec :: ReadPrec SslConfiguration
$creadPrec :: ReadPrec SslConfiguration
readList :: ReadS [SslConfiguration]
$creadList :: ReadS [SslConfiguration]
readsPrec :: Int -> ReadS SslConfiguration
$creadsPrec :: Int -> ReadS SslConfiguration
Prelude.Read, Int -> SslConfiguration -> ShowS
[SslConfiguration] -> ShowS
SslConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SslConfiguration] -> ShowS
$cshowList :: [SslConfiguration] -> ShowS
show :: SslConfiguration -> String
$cshow :: SslConfiguration -> String
showsPrec :: Int -> SslConfiguration -> ShowS
$cshowsPrec :: Int -> SslConfiguration -> ShowS
Prelude.Show, forall x. Rep SslConfiguration x -> SslConfiguration
forall x. SslConfiguration -> Rep SslConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SslConfiguration x -> SslConfiguration
$cfrom :: forall x. SslConfiguration -> Rep SslConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SslConfiguration' 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:
--
-- 'certificate', 'sslConfiguration_certificate' - The contents of the certificate\'s domain.crt file.
--
-- 'chain', 'sslConfiguration_chain' - Optional. Can be used to specify an intermediate certificate authority
-- key or client authentication.
--
-- 'privateKey', 'sslConfiguration_privateKey' - The private key; the contents of the certificate\'s domain.kex file.
newSslConfiguration ::
  SslConfiguration
newSslConfiguration :: SslConfiguration
newSslConfiguration =
  SslConfiguration'
    { $sel:certificate:SslConfiguration' :: Maybe Text
certificate = forall a. Maybe a
Prelude.Nothing,
      $sel:chain:SslConfiguration' :: Maybe Text
chain = forall a. Maybe a
Prelude.Nothing,
      $sel:privateKey:SslConfiguration' :: Maybe Text
privateKey = forall a. Maybe a
Prelude.Nothing
    }

-- | The contents of the certificate\'s domain.crt file.
sslConfiguration_certificate :: Lens.Lens' SslConfiguration (Prelude.Maybe Prelude.Text)
sslConfiguration_certificate :: Lens' SslConfiguration (Maybe Text)
sslConfiguration_certificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SslConfiguration' {Maybe Text
certificate :: Maybe Text
$sel:certificate:SslConfiguration' :: SslConfiguration -> Maybe Text
certificate} -> Maybe Text
certificate) (\s :: SslConfiguration
s@SslConfiguration' {} Maybe Text
a -> SslConfiguration
s {$sel:certificate:SslConfiguration' :: Maybe Text
certificate = Maybe Text
a} :: SslConfiguration)

-- | Optional. Can be used to specify an intermediate certificate authority
-- key or client authentication.
sslConfiguration_chain :: Lens.Lens' SslConfiguration (Prelude.Maybe Prelude.Text)
sslConfiguration_chain :: Lens' SslConfiguration (Maybe Text)
sslConfiguration_chain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SslConfiguration' {Maybe Text
chain :: Maybe Text
$sel:chain:SslConfiguration' :: SslConfiguration -> Maybe Text
chain} -> Maybe Text
chain) (\s :: SslConfiguration
s@SslConfiguration' {} Maybe Text
a -> SslConfiguration
s {$sel:chain:SslConfiguration' :: Maybe Text
chain = Maybe Text
a} :: SslConfiguration)

-- | The private key; the contents of the certificate\'s domain.kex file.
sslConfiguration_privateKey :: Lens.Lens' SslConfiguration (Prelude.Maybe Prelude.Text)
sslConfiguration_privateKey :: Lens' SslConfiguration (Maybe Text)
sslConfiguration_privateKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SslConfiguration' {Maybe Text
privateKey :: Maybe Text
$sel:privateKey:SslConfiguration' :: SslConfiguration -> Maybe Text
privateKey} -> Maybe Text
privateKey) (\s :: SslConfiguration
s@SslConfiguration' {} Maybe Text
a -> SslConfiguration
s {$sel:privateKey:SslConfiguration' :: Maybe Text
privateKey = Maybe Text
a} :: SslConfiguration)

instance Data.FromJSON SslConfiguration where
  parseJSON :: Value -> Parser SslConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SslConfiguration"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> SslConfiguration
SslConfiguration'
            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
"Certificate")
            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
"Chain")
            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
"PrivateKey")
      )

instance Prelude.Hashable SslConfiguration where
  hashWithSalt :: Int -> SslConfiguration -> Int
hashWithSalt Int
_salt SslConfiguration' {Maybe Text
privateKey :: Maybe Text
chain :: Maybe Text
certificate :: Maybe Text
$sel:privateKey:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:chain:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:certificate:SslConfiguration' :: SslConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
certificate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
chain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
privateKey

instance Prelude.NFData SslConfiguration where
  rnf :: SslConfiguration -> ()
rnf SslConfiguration' {Maybe Text
privateKey :: Maybe Text
chain :: Maybe Text
certificate :: Maybe Text
$sel:privateKey:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:chain:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:certificate:SslConfiguration' :: SslConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
certificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
chain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
privateKey

instance Data.ToJSON SslConfiguration where
  toJSON :: SslConfiguration -> Value
toJSON SslConfiguration' {Maybe Text
privateKey :: Maybe Text
chain :: Maybe Text
certificate :: Maybe Text
$sel:privateKey:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:chain:SslConfiguration' :: SslConfiguration -> Maybe Text
$sel:certificate:SslConfiguration' :: SslConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Certificate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
certificate,
            (Key
"Chain" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
chain,
            (Key
"PrivateKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
privateKey
          ]
      )