{-# 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.AppSync.Types.RelationalDatabaseDataSourceConfig
-- 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.AppSync.Types.RelationalDatabaseDataSourceConfig where

import Amazonka.AppSync.Types.RdsHttpEndpointConfig
import Amazonka.AppSync.Types.RelationalDatabaseSourceType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a relational database data source configuration.
--
-- /See:/ 'newRelationalDatabaseDataSourceConfig' smart constructor.
data RelationalDatabaseDataSourceConfig = RelationalDatabaseDataSourceConfig'
  { -- | Source type for the relational database.
    --
    -- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
    --     Amazon RDS HTTP endpoint.
    RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Prelude.Maybe RelationalDatabaseSourceType,
    -- | Amazon RDS HTTP endpoint settings.
    RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig :: Prelude.Maybe RdsHttpEndpointConfig
  }
  deriving (RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
(RelationalDatabaseDataSourceConfig
 -> RelationalDatabaseDataSourceConfig -> Bool)
-> (RelationalDatabaseDataSourceConfig
    -> RelationalDatabaseDataSourceConfig -> Bool)
-> Eq RelationalDatabaseDataSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
$c/= :: RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
== :: RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
$c== :: RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
Prelude.Eq, ReadPrec [RelationalDatabaseDataSourceConfig]
ReadPrec RelationalDatabaseDataSourceConfig
Int -> ReadS RelationalDatabaseDataSourceConfig
ReadS [RelationalDatabaseDataSourceConfig]
(Int -> ReadS RelationalDatabaseDataSourceConfig)
-> ReadS [RelationalDatabaseDataSourceConfig]
-> ReadPrec RelationalDatabaseDataSourceConfig
-> ReadPrec [RelationalDatabaseDataSourceConfig]
-> Read RelationalDatabaseDataSourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelationalDatabaseDataSourceConfig]
$creadListPrec :: ReadPrec [RelationalDatabaseDataSourceConfig]
readPrec :: ReadPrec RelationalDatabaseDataSourceConfig
$creadPrec :: ReadPrec RelationalDatabaseDataSourceConfig
readList :: ReadS [RelationalDatabaseDataSourceConfig]
$creadList :: ReadS [RelationalDatabaseDataSourceConfig]
readsPrec :: Int -> ReadS RelationalDatabaseDataSourceConfig
$creadsPrec :: Int -> ReadS RelationalDatabaseDataSourceConfig
Prelude.Read, Int -> RelationalDatabaseDataSourceConfig -> ShowS
[RelationalDatabaseDataSourceConfig] -> ShowS
RelationalDatabaseDataSourceConfig -> String
(Int -> RelationalDatabaseDataSourceConfig -> ShowS)
-> (RelationalDatabaseDataSourceConfig -> String)
-> ([RelationalDatabaseDataSourceConfig] -> ShowS)
-> Show RelationalDatabaseDataSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationalDatabaseDataSourceConfig] -> ShowS
$cshowList :: [RelationalDatabaseDataSourceConfig] -> ShowS
show :: RelationalDatabaseDataSourceConfig -> String
$cshow :: RelationalDatabaseDataSourceConfig -> String
showsPrec :: Int -> RelationalDatabaseDataSourceConfig -> ShowS
$cshowsPrec :: Int -> RelationalDatabaseDataSourceConfig -> ShowS
Prelude.Show, (forall x.
 RelationalDatabaseDataSourceConfig
 -> Rep RelationalDatabaseDataSourceConfig x)
-> (forall x.
    Rep RelationalDatabaseDataSourceConfig x
    -> RelationalDatabaseDataSourceConfig)
-> Generic RelationalDatabaseDataSourceConfig
forall x.
Rep RelationalDatabaseDataSourceConfig x
-> RelationalDatabaseDataSourceConfig
forall x.
RelationalDatabaseDataSourceConfig
-> Rep RelationalDatabaseDataSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RelationalDatabaseDataSourceConfig x
-> RelationalDatabaseDataSourceConfig
$cfrom :: forall x.
RelationalDatabaseDataSourceConfig
-> Rep RelationalDatabaseDataSourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'RelationalDatabaseDataSourceConfig' 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:
--
-- 'relationalDatabaseSourceType', 'relationalDatabaseDataSourceConfig_relationalDatabaseSourceType' - Source type for the relational database.
--
-- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
--     Amazon RDS HTTP endpoint.
--
-- 'rdsHttpEndpointConfig', 'relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig' - Amazon RDS HTTP endpoint settings.
newRelationalDatabaseDataSourceConfig ::
  RelationalDatabaseDataSourceConfig
newRelationalDatabaseDataSourceConfig :: RelationalDatabaseDataSourceConfig
newRelationalDatabaseDataSourceConfig =
  RelationalDatabaseDataSourceConfig' :: Maybe RelationalDatabaseSourceType
-> Maybe RdsHttpEndpointConfig
-> RelationalDatabaseDataSourceConfig
RelationalDatabaseDataSourceConfig'
    { $sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType =
        Maybe RelationalDatabaseSourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig = Maybe RdsHttpEndpointConfig
forall a. Maybe a
Prelude.Nothing
    }

-- | Source type for the relational database.
--
-- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
--     Amazon RDS HTTP endpoint.
relationalDatabaseDataSourceConfig_relationalDatabaseSourceType :: Lens.Lens' RelationalDatabaseDataSourceConfig (Prelude.Maybe RelationalDatabaseSourceType)
relationalDatabaseDataSourceConfig_relationalDatabaseSourceType :: (Maybe RelationalDatabaseSourceType
 -> f (Maybe RelationalDatabaseSourceType))
-> RelationalDatabaseDataSourceConfig
-> f RelationalDatabaseDataSourceConfig
relationalDatabaseDataSourceConfig_relationalDatabaseSourceType = (RelationalDatabaseDataSourceConfig
 -> Maybe RelationalDatabaseSourceType)
-> (RelationalDatabaseDataSourceConfig
    -> Maybe RelationalDatabaseSourceType
    -> RelationalDatabaseDataSourceConfig)
-> Lens
     RelationalDatabaseDataSourceConfig
     RelationalDatabaseDataSourceConfig
     (Maybe RelationalDatabaseSourceType)
     (Maybe RelationalDatabaseSourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalDatabaseDataSourceConfig' {Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Maybe RelationalDatabaseSourceType
$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType} -> Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType) (\s :: RelationalDatabaseDataSourceConfig
s@RelationalDatabaseDataSourceConfig' {} Maybe RelationalDatabaseSourceType
a -> RelationalDatabaseDataSourceConfig
s {$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType = Maybe RelationalDatabaseSourceType
a} :: RelationalDatabaseDataSourceConfig)

-- | Amazon RDS HTTP endpoint settings.
relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig :: Lens.Lens' RelationalDatabaseDataSourceConfig (Prelude.Maybe RdsHttpEndpointConfig)
relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig :: (Maybe RdsHttpEndpointConfig -> f (Maybe RdsHttpEndpointConfig))
-> RelationalDatabaseDataSourceConfig
-> f RelationalDatabaseDataSourceConfig
relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig = (RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig)
-> (RelationalDatabaseDataSourceConfig
    -> Maybe RdsHttpEndpointConfig
    -> RelationalDatabaseDataSourceConfig)
-> Lens
     RelationalDatabaseDataSourceConfig
     RelationalDatabaseDataSourceConfig
     (Maybe RdsHttpEndpointConfig)
     (Maybe RdsHttpEndpointConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalDatabaseDataSourceConfig' {Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig :: Maybe RdsHttpEndpointConfig
$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig} -> Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig) (\s :: RelationalDatabaseDataSourceConfig
s@RelationalDatabaseDataSourceConfig' {} Maybe RdsHttpEndpointConfig
a -> RelationalDatabaseDataSourceConfig
s {$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig = Maybe RdsHttpEndpointConfig
a} :: RelationalDatabaseDataSourceConfig)

instance
  Core.FromJSON
    RelationalDatabaseDataSourceConfig
  where
  parseJSON :: Value -> Parser RelationalDatabaseDataSourceConfig
parseJSON =
    String
-> (Object -> Parser RelationalDatabaseDataSourceConfig)
-> Value
-> Parser RelationalDatabaseDataSourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RelationalDatabaseDataSourceConfig"
      ( \Object
x ->
          Maybe RelationalDatabaseSourceType
-> Maybe RdsHttpEndpointConfig
-> RelationalDatabaseDataSourceConfig
RelationalDatabaseDataSourceConfig'
            (Maybe RelationalDatabaseSourceType
 -> Maybe RdsHttpEndpointConfig
 -> RelationalDatabaseDataSourceConfig)
-> Parser (Maybe RelationalDatabaseSourceType)
-> Parser
     (Maybe RdsHttpEndpointConfig -> RelationalDatabaseDataSourceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RelationalDatabaseSourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"relationalDatabaseSourceType")
            Parser
  (Maybe RdsHttpEndpointConfig -> RelationalDatabaseDataSourceConfig)
-> Parser (Maybe RdsHttpEndpointConfig)
-> Parser RelationalDatabaseDataSourceConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RdsHttpEndpointConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rdsHttpEndpointConfig")
      )

instance
  Prelude.Hashable
    RelationalDatabaseDataSourceConfig

instance
  Prelude.NFData
    RelationalDatabaseDataSourceConfig

instance
  Core.ToJSON
    RelationalDatabaseDataSourceConfig
  where
  toJSON :: RelationalDatabaseDataSourceConfig -> Value
toJSON RelationalDatabaseDataSourceConfig' {Maybe RdsHttpEndpointConfig
Maybe RelationalDatabaseSourceType
rdsHttpEndpointConfig :: Maybe RdsHttpEndpointConfig
relationalDatabaseSourceType :: Maybe RelationalDatabaseSourceType
$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"relationalDatabaseSourceType" Text -> RelationalDatabaseSourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RelationalDatabaseSourceType -> Pair)
-> Maybe RelationalDatabaseSourceType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType,
            (Text
"rdsHttpEndpointConfig" Text -> RdsHttpEndpointConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RdsHttpEndpointConfig -> Pair)
-> Maybe RdsHttpEndpointConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig
          ]
      )