{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a relational database data source configuration.
--
-- /See:/ 'newRelationalDatabaseDataSourceConfig' smart constructor.
data RelationalDatabaseDataSourceConfig = RelationalDatabaseDataSourceConfig'
  { -- | Amazon RDS HTTP endpoint settings.
    RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig :: Prelude.Maybe RdsHttpEndpointConfig,
    -- | Source type for the relational database.
    --
    -- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
    --     Amazon Relational Database Service (Amazon RDS) HTTP endpoint.
    RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Prelude.Maybe RelationalDatabaseSourceType
  }
  deriving (RelationalDatabaseDataSourceConfig
-> RelationalDatabaseDataSourceConfig -> Bool
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]
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
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.
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:
--
-- 'rdsHttpEndpointConfig', 'relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig' - Amazon RDS HTTP endpoint settings.
--
-- 'relationalDatabaseSourceType', 'relationalDatabaseDataSourceConfig_relationalDatabaseSourceType' - Source type for the relational database.
--
-- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
--     Amazon Relational Database Service (Amazon RDS) HTTP endpoint.
newRelationalDatabaseDataSourceConfig ::
  RelationalDatabaseDataSourceConfig
newRelationalDatabaseDataSourceConfig :: RelationalDatabaseDataSourceConfig
newRelationalDatabaseDataSourceConfig =
  RelationalDatabaseDataSourceConfig'
    { $sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Amazon RDS HTTP endpoint settings.
relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig :: Lens.Lens' RelationalDatabaseDataSourceConfig (Prelude.Maybe RdsHttpEndpointConfig)
relationalDatabaseDataSourceConfig_rdsHttpEndpointConfig :: Lens'
  RelationalDatabaseDataSourceConfig (Maybe RdsHttpEndpointConfig)
relationalDatabaseDataSourceConfig_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)

-- | Source type for the relational database.
--
-- -   __RDS_HTTP_ENDPOINT__: The relational database source type is an
--     Amazon Relational Database Service (Amazon RDS) HTTP endpoint.
relationalDatabaseDataSourceConfig_relationalDatabaseSourceType :: Lens.Lens' RelationalDatabaseDataSourceConfig (Prelude.Maybe RelationalDatabaseSourceType)
relationalDatabaseDataSourceConfig_relationalDatabaseSourceType :: Lens'
  RelationalDatabaseDataSourceConfig
  (Maybe RelationalDatabaseSourceType)
relationalDatabaseDataSourceConfig_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)

instance
  Data.FromJSON
    RelationalDatabaseDataSourceConfig
  where
  parseJSON :: Value -> Parser RelationalDatabaseDataSourceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RelationalDatabaseDataSourceConfig"
      ( \Object
x ->
          Maybe RdsHttpEndpointConfig
-> Maybe RelationalDatabaseSourceType
-> RelationalDatabaseDataSourceConfig
RelationalDatabaseDataSourceConfig'
            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
"rdsHttpEndpointConfig")
            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
"relationalDatabaseSourceType")
      )

instance
  Prelude.Hashable
    RelationalDatabaseDataSourceConfig
  where
  hashWithSalt :: Int -> RelationalDatabaseDataSourceConfig -> Int
hashWithSalt
    Int
_salt
    RelationalDatabaseDataSourceConfig' {Maybe RdsHttpEndpointConfig
Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Maybe RelationalDatabaseSourceType
rdsHttpEndpointConfig :: Maybe RdsHttpEndpointConfig
$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType

instance
  Prelude.NFData
    RelationalDatabaseDataSourceConfig
  where
  rnf :: RelationalDatabaseDataSourceConfig -> ()
rnf RelationalDatabaseDataSourceConfig' {Maybe RdsHttpEndpointConfig
Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Maybe RelationalDatabaseSourceType
rdsHttpEndpointConfig :: Maybe RdsHttpEndpointConfig
$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RdsHttpEndpointConfig
rdsHttpEndpointConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType

instance
  Data.ToJSON
    RelationalDatabaseDataSourceConfig
  where
  toJSON :: RelationalDatabaseDataSourceConfig -> Value
toJSON RelationalDatabaseDataSourceConfig' {Maybe RdsHttpEndpointConfig
Maybe RelationalDatabaseSourceType
relationalDatabaseSourceType :: Maybe RelationalDatabaseSourceType
rdsHttpEndpointConfig :: Maybe RdsHttpEndpointConfig
$sel:relationalDatabaseSourceType:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig
-> Maybe RelationalDatabaseSourceType
$sel:rdsHttpEndpointConfig:RelationalDatabaseDataSourceConfig' :: RelationalDatabaseDataSourceConfig -> Maybe RdsHttpEndpointConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"rdsHttpEndpointConfig" 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 RdsHttpEndpointConfig
rdsHttpEndpointConfig,
            (Key
"relationalDatabaseSourceType" 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 RelationalDatabaseSourceType
relationalDatabaseSourceType
          ]
      )