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

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

-- | Describes an app\'s SSL configuration.
--
-- /See:/ 'newSslConfiguration' smart constructor.
data SslConfiguration = SslConfiguration'
  { -- | The private key; the contents of the certificate\'s domain.kex file.
    SslConfiguration -> Maybe Text
privateKey :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (SslConfiguration -> SslConfiguration -> Bool
(SslConfiguration -> SslConfiguration -> Bool)
-> (SslConfiguration -> SslConfiguration -> Bool)
-> Eq SslConfiguration
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]
(Int -> ReadS SslConfiguration)
-> ReadS [SslConfiguration]
-> ReadPrec SslConfiguration
-> ReadPrec [SslConfiguration]
-> Read 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
(Int -> SslConfiguration -> ShowS)
-> (SslConfiguration -> String)
-> ([SslConfiguration] -> ShowS)
-> Show SslConfiguration
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. SslConfiguration -> Rep SslConfiguration x)
-> (forall x. Rep SslConfiguration x -> SslConfiguration)
-> Generic SslConfiguration
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:
--
-- 'privateKey', 'sslConfiguration_privateKey' - The private key; the contents of the certificate\'s domain.kex file.
--
-- '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.
newSslConfiguration ::
  SslConfiguration
newSslConfiguration :: SslConfiguration
newSslConfiguration =
  SslConfiguration' :: Maybe Text -> Maybe Text -> Maybe Text -> SslConfiguration
SslConfiguration'
    { $sel:privateKey:SslConfiguration' :: Maybe Text
privateKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificate:SslConfiguration' :: Maybe Text
certificate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:chain:SslConfiguration' :: Maybe Text
chain = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The private key; the contents of the certificate\'s domain.kex file.
sslConfiguration_privateKey :: Lens.Lens' SslConfiguration (Prelude.Maybe Prelude.Text)
sslConfiguration_privateKey :: (Maybe Text -> f (Maybe Text))
-> SslConfiguration -> f SslConfiguration
sslConfiguration_privateKey = (SslConfiguration -> Maybe Text)
-> (SslConfiguration -> Maybe Text -> SslConfiguration)
-> Lens SslConfiguration SslConfiguration (Maybe Text) (Maybe Text)
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)

-- | The contents of the certificate\'s domain.crt file.
sslConfiguration_certificate :: Lens.Lens' SslConfiguration (Prelude.Maybe Prelude.Text)
sslConfiguration_certificate :: (Maybe Text -> f (Maybe Text))
-> SslConfiguration -> f SslConfiguration
sslConfiguration_certificate = (SslConfiguration -> Maybe Text)
-> (SslConfiguration -> Maybe Text -> SslConfiguration)
-> Lens SslConfiguration SslConfiguration (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> SslConfiguration -> f SslConfiguration
sslConfiguration_chain = (SslConfiguration -> Maybe Text)
-> (SslConfiguration -> Maybe Text -> SslConfiguration)
-> Lens SslConfiguration SslConfiguration (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable SslConfiguration

instance Prelude.NFData SslConfiguration

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