{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateDataSource
-- 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)
--
-- Creates a @DataSource@ object.
module Amazonka.AppSync.CreateDataSource
  ( -- * Creating a Request
    CreateDataSource (..),
    newCreateDataSource,

    -- * Request Lenses
    createDataSource_serviceRoleArn,
    createDataSource_relationalDatabaseConfig,
    createDataSource_dynamodbConfig,
    createDataSource_httpConfig,
    createDataSource_openSearchServiceConfig,
    createDataSource_lambdaConfig,
    createDataSource_description,
    createDataSource_elasticsearchConfig,
    createDataSource_apiId,
    createDataSource_name,
    createDataSource_type,

    -- * Destructuring the Response
    CreateDataSourceResponse (..),
    newCreateDataSourceResponse,

    -- * Response Lenses
    createDataSourceResponse_dataSource,
    createDataSourceResponse_httpStatus,
  )
where

import Amazonka.AppSync.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateDataSource' smart constructor.
data CreateDataSource = CreateDataSource'
  { -- | The Identity and Access Management service role ARN for the data source.
    -- The system assumes this role when accessing the data source.
    CreateDataSource -> Maybe Text
serviceRoleArn :: Prelude.Maybe Prelude.Text,
    -- | Relational database settings.
    CreateDataSource -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig :: Prelude.Maybe RelationalDatabaseDataSourceConfig,
    -- | Amazon DynamoDB settings.
    CreateDataSource -> Maybe DynamodbDataSourceConfig
dynamodbConfig :: Prelude.Maybe DynamodbDataSourceConfig,
    -- | HTTP endpoint settings.
    CreateDataSource -> Maybe HttpDataSourceConfig
httpConfig :: Prelude.Maybe HttpDataSourceConfig,
    -- | Amazon OpenSearch Service settings.
    CreateDataSource -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig :: Prelude.Maybe OpenSearchServiceDataSourceConfig,
    -- | Amazon Web Services Lambda settings.
    CreateDataSource -> Maybe LambdaDataSourceConfig
lambdaConfig :: Prelude.Maybe LambdaDataSourceConfig,
    -- | A description of the @DataSource@.
    CreateDataSource -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Amazon OpenSearch Service settings.
    --
    -- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
    -- Service. This configuration is deprecated. For new data sources, use
    -- CreateDataSourceRequest$openSearchServiceConfig to create an OpenSearch
    -- data source.
    CreateDataSource -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig :: Prelude.Maybe ElasticsearchDataSourceConfig,
    -- | The API ID for the GraphQL API for the @DataSource@.
    CreateDataSource -> Text
apiId :: Prelude.Text,
    -- | A user-supplied name for the @DataSource@.
    CreateDataSource -> Text
name :: Prelude.Text,
    -- | The type of the @DataSource@.
    CreateDataSource -> DataSourceType
type' :: DataSourceType
  }
  deriving (CreateDataSource -> CreateDataSource -> Bool
(CreateDataSource -> CreateDataSource -> Bool)
-> (CreateDataSource -> CreateDataSource -> Bool)
-> Eq CreateDataSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataSource -> CreateDataSource -> Bool
$c/= :: CreateDataSource -> CreateDataSource -> Bool
== :: CreateDataSource -> CreateDataSource -> Bool
$c== :: CreateDataSource -> CreateDataSource -> Bool
Prelude.Eq, ReadPrec [CreateDataSource]
ReadPrec CreateDataSource
Int -> ReadS CreateDataSource
ReadS [CreateDataSource]
(Int -> ReadS CreateDataSource)
-> ReadS [CreateDataSource]
-> ReadPrec CreateDataSource
-> ReadPrec [CreateDataSource]
-> Read CreateDataSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataSource]
$creadListPrec :: ReadPrec [CreateDataSource]
readPrec :: ReadPrec CreateDataSource
$creadPrec :: ReadPrec CreateDataSource
readList :: ReadS [CreateDataSource]
$creadList :: ReadS [CreateDataSource]
readsPrec :: Int -> ReadS CreateDataSource
$creadsPrec :: Int -> ReadS CreateDataSource
Prelude.Read, Int -> CreateDataSource -> ShowS
[CreateDataSource] -> ShowS
CreateDataSource -> String
(Int -> CreateDataSource -> ShowS)
-> (CreateDataSource -> String)
-> ([CreateDataSource] -> ShowS)
-> Show CreateDataSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataSource] -> ShowS
$cshowList :: [CreateDataSource] -> ShowS
show :: CreateDataSource -> String
$cshow :: CreateDataSource -> String
showsPrec :: Int -> CreateDataSource -> ShowS
$cshowsPrec :: Int -> CreateDataSource -> ShowS
Prelude.Show, (forall x. CreateDataSource -> Rep CreateDataSource x)
-> (forall x. Rep CreateDataSource x -> CreateDataSource)
-> Generic CreateDataSource
forall x. Rep CreateDataSource x -> CreateDataSource
forall x. CreateDataSource -> Rep CreateDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDataSource x -> CreateDataSource
$cfrom :: forall x. CreateDataSource -> Rep CreateDataSource x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataSource' 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:
--
-- 'serviceRoleArn', 'createDataSource_serviceRoleArn' - The Identity and Access Management service role ARN for the data source.
-- The system assumes this role when accessing the data source.
--
-- 'relationalDatabaseConfig', 'createDataSource_relationalDatabaseConfig' - Relational database settings.
--
-- 'dynamodbConfig', 'createDataSource_dynamodbConfig' - Amazon DynamoDB settings.
--
-- 'httpConfig', 'createDataSource_httpConfig' - HTTP endpoint settings.
--
-- 'openSearchServiceConfig', 'createDataSource_openSearchServiceConfig' - Amazon OpenSearch Service settings.
--
-- 'lambdaConfig', 'createDataSource_lambdaConfig' - Amazon Web Services Lambda settings.
--
-- 'description', 'createDataSource_description' - A description of the @DataSource@.
--
-- 'elasticsearchConfig', 'createDataSource_elasticsearchConfig' - Amazon OpenSearch Service settings.
--
-- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
-- Service. This configuration is deprecated. For new data sources, use
-- CreateDataSourceRequest$openSearchServiceConfig to create an OpenSearch
-- data source.
--
-- 'apiId', 'createDataSource_apiId' - The API ID for the GraphQL API for the @DataSource@.
--
-- 'name', 'createDataSource_name' - A user-supplied name for the @DataSource@.
--
-- 'type'', 'createDataSource_type' - The type of the @DataSource@.
newCreateDataSource ::
  -- | 'apiId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  DataSourceType ->
  CreateDataSource
newCreateDataSource :: Text -> Text -> DataSourceType -> CreateDataSource
newCreateDataSource Text
pApiId_ Text
pName_ DataSourceType
pType_ =
  CreateDataSource' :: Maybe Text
-> Maybe RelationalDatabaseDataSourceConfig
-> Maybe DynamodbDataSourceConfig
-> Maybe HttpDataSourceConfig
-> Maybe OpenSearchServiceDataSourceConfig
-> Maybe LambdaDataSourceConfig
-> Maybe Text
-> Maybe ElasticsearchDataSourceConfig
-> Text
-> Text
-> DataSourceType
-> CreateDataSource
CreateDataSource'
    { $sel:serviceRoleArn:CreateDataSource' :: Maybe Text
serviceRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relationalDatabaseConfig:CreateDataSource' :: Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig = Maybe RelationalDatabaseDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:dynamodbConfig:CreateDataSource' :: Maybe DynamodbDataSourceConfig
dynamodbConfig = Maybe DynamodbDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:httpConfig:CreateDataSource' :: Maybe HttpDataSourceConfig
httpConfig = Maybe HttpDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:openSearchServiceConfig:CreateDataSource' :: Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig = Maybe OpenSearchServiceDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaConfig:CreateDataSource' :: Maybe LambdaDataSourceConfig
lambdaConfig = Maybe LambdaDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateDataSource' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:elasticsearchConfig:CreateDataSource' :: Maybe ElasticsearchDataSourceConfig
elasticsearchConfig = Maybe ElasticsearchDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:apiId:CreateDataSource' :: Text
apiId = Text
pApiId_,
      $sel:name:CreateDataSource' :: Text
name = Text
pName_,
      $sel:type':CreateDataSource' :: DataSourceType
type' = DataSourceType
pType_
    }

-- | The Identity and Access Management service role ARN for the data source.
-- The system assumes this role when accessing the data source.
createDataSource_serviceRoleArn :: Lens.Lens' CreateDataSource (Prelude.Maybe Prelude.Text)
createDataSource_serviceRoleArn :: (Maybe Text -> f (Maybe Text))
-> CreateDataSource -> f CreateDataSource
createDataSource_serviceRoleArn = (CreateDataSource -> Maybe Text)
-> (CreateDataSource -> Maybe Text -> CreateDataSource)
-> Lens CreateDataSource CreateDataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe Text
serviceRoleArn :: Maybe Text
$sel:serviceRoleArn:CreateDataSource' :: CreateDataSource -> Maybe Text
serviceRoleArn} -> Maybe Text
serviceRoleArn) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe Text
a -> CreateDataSource
s {$sel:serviceRoleArn:CreateDataSource' :: Maybe Text
serviceRoleArn = Maybe Text
a} :: CreateDataSource)

-- | Relational database settings.
createDataSource_relationalDatabaseConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe RelationalDatabaseDataSourceConfig)
createDataSource_relationalDatabaseConfig :: (Maybe RelationalDatabaseDataSourceConfig
 -> f (Maybe RelationalDatabaseDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_relationalDatabaseConfig = (CreateDataSource -> Maybe RelationalDatabaseDataSourceConfig)
-> (CreateDataSource
    -> Maybe RelationalDatabaseDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe RelationalDatabaseDataSourceConfig)
     (Maybe RelationalDatabaseDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig :: Maybe RelationalDatabaseDataSourceConfig
$sel:relationalDatabaseConfig:CreateDataSource' :: CreateDataSource -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig} -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe RelationalDatabaseDataSourceConfig
a -> CreateDataSource
s {$sel:relationalDatabaseConfig:CreateDataSource' :: Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig = Maybe RelationalDatabaseDataSourceConfig
a} :: CreateDataSource)

-- | Amazon DynamoDB settings.
createDataSource_dynamodbConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe DynamodbDataSourceConfig)
createDataSource_dynamodbConfig :: (Maybe DynamodbDataSourceConfig
 -> f (Maybe DynamodbDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_dynamodbConfig = (CreateDataSource -> Maybe DynamodbDataSourceConfig)
-> (CreateDataSource
    -> Maybe DynamodbDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe DynamodbDataSourceConfig)
     (Maybe DynamodbDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe DynamodbDataSourceConfig
dynamodbConfig :: Maybe DynamodbDataSourceConfig
$sel:dynamodbConfig:CreateDataSource' :: CreateDataSource -> Maybe DynamodbDataSourceConfig
dynamodbConfig} -> Maybe DynamodbDataSourceConfig
dynamodbConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe DynamodbDataSourceConfig
a -> CreateDataSource
s {$sel:dynamodbConfig:CreateDataSource' :: Maybe DynamodbDataSourceConfig
dynamodbConfig = Maybe DynamodbDataSourceConfig
a} :: CreateDataSource)

-- | HTTP endpoint settings.
createDataSource_httpConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe HttpDataSourceConfig)
createDataSource_httpConfig :: (Maybe HttpDataSourceConfig -> f (Maybe HttpDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_httpConfig = (CreateDataSource -> Maybe HttpDataSourceConfig)
-> (CreateDataSource
    -> Maybe HttpDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe HttpDataSourceConfig)
     (Maybe HttpDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe HttpDataSourceConfig
httpConfig :: Maybe HttpDataSourceConfig
$sel:httpConfig:CreateDataSource' :: CreateDataSource -> Maybe HttpDataSourceConfig
httpConfig} -> Maybe HttpDataSourceConfig
httpConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe HttpDataSourceConfig
a -> CreateDataSource
s {$sel:httpConfig:CreateDataSource' :: Maybe HttpDataSourceConfig
httpConfig = Maybe HttpDataSourceConfig
a} :: CreateDataSource)

-- | Amazon OpenSearch Service settings.
createDataSource_openSearchServiceConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe OpenSearchServiceDataSourceConfig)
createDataSource_openSearchServiceConfig :: (Maybe OpenSearchServiceDataSourceConfig
 -> f (Maybe OpenSearchServiceDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_openSearchServiceConfig = (CreateDataSource -> Maybe OpenSearchServiceDataSourceConfig)
-> (CreateDataSource
    -> Maybe OpenSearchServiceDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe OpenSearchServiceDataSourceConfig)
     (Maybe OpenSearchServiceDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig :: Maybe OpenSearchServiceDataSourceConfig
$sel:openSearchServiceConfig:CreateDataSource' :: CreateDataSource -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig} -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe OpenSearchServiceDataSourceConfig
a -> CreateDataSource
s {$sel:openSearchServiceConfig:CreateDataSource' :: Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig = Maybe OpenSearchServiceDataSourceConfig
a} :: CreateDataSource)

-- | Amazon Web Services Lambda settings.
createDataSource_lambdaConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe LambdaDataSourceConfig)
createDataSource_lambdaConfig :: (Maybe LambdaDataSourceConfig -> f (Maybe LambdaDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_lambdaConfig = (CreateDataSource -> Maybe LambdaDataSourceConfig)
-> (CreateDataSource
    -> Maybe LambdaDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe LambdaDataSourceConfig)
     (Maybe LambdaDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe LambdaDataSourceConfig
lambdaConfig :: Maybe LambdaDataSourceConfig
$sel:lambdaConfig:CreateDataSource' :: CreateDataSource -> Maybe LambdaDataSourceConfig
lambdaConfig} -> Maybe LambdaDataSourceConfig
lambdaConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe LambdaDataSourceConfig
a -> CreateDataSource
s {$sel:lambdaConfig:CreateDataSource' :: Maybe LambdaDataSourceConfig
lambdaConfig = Maybe LambdaDataSourceConfig
a} :: CreateDataSource)

-- | A description of the @DataSource@.
createDataSource_description :: Lens.Lens' CreateDataSource (Prelude.Maybe Prelude.Text)
createDataSource_description :: (Maybe Text -> f (Maybe Text))
-> CreateDataSource -> f CreateDataSource
createDataSource_description = (CreateDataSource -> Maybe Text)
-> (CreateDataSource -> Maybe Text -> CreateDataSource)
-> Lens CreateDataSource CreateDataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe Text
description :: Maybe Text
$sel:description:CreateDataSource' :: CreateDataSource -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe Text
a -> CreateDataSource
s {$sel:description:CreateDataSource' :: Maybe Text
description = Maybe Text
a} :: CreateDataSource)

-- | Amazon OpenSearch Service settings.
--
-- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
-- Service. This configuration is deprecated. For new data sources, use
-- CreateDataSourceRequest$openSearchServiceConfig to create an OpenSearch
-- data source.
createDataSource_elasticsearchConfig :: Lens.Lens' CreateDataSource (Prelude.Maybe ElasticsearchDataSourceConfig)
createDataSource_elasticsearchConfig :: (Maybe ElasticsearchDataSourceConfig
 -> f (Maybe ElasticsearchDataSourceConfig))
-> CreateDataSource -> f CreateDataSource
createDataSource_elasticsearchConfig = (CreateDataSource -> Maybe ElasticsearchDataSourceConfig)
-> (CreateDataSource
    -> Maybe ElasticsearchDataSourceConfig -> CreateDataSource)
-> Lens
     CreateDataSource
     CreateDataSource
     (Maybe ElasticsearchDataSourceConfig)
     (Maybe ElasticsearchDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Maybe ElasticsearchDataSourceConfig
elasticsearchConfig :: Maybe ElasticsearchDataSourceConfig
$sel:elasticsearchConfig:CreateDataSource' :: CreateDataSource -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig} -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig) (\s :: CreateDataSource
s@CreateDataSource' {} Maybe ElasticsearchDataSourceConfig
a -> CreateDataSource
s {$sel:elasticsearchConfig:CreateDataSource' :: Maybe ElasticsearchDataSourceConfig
elasticsearchConfig = Maybe ElasticsearchDataSourceConfig
a} :: CreateDataSource)

-- | The API ID for the GraphQL API for the @DataSource@.
createDataSource_apiId :: Lens.Lens' CreateDataSource Prelude.Text
createDataSource_apiId :: (Text -> f Text) -> CreateDataSource -> f CreateDataSource
createDataSource_apiId = (CreateDataSource -> Text)
-> (CreateDataSource -> Text -> CreateDataSource)
-> Lens CreateDataSource CreateDataSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Text
apiId :: Text
$sel:apiId:CreateDataSource' :: CreateDataSource -> Text
apiId} -> Text
apiId) (\s :: CreateDataSource
s@CreateDataSource' {} Text
a -> CreateDataSource
s {$sel:apiId:CreateDataSource' :: Text
apiId = Text
a} :: CreateDataSource)

-- | A user-supplied name for the @DataSource@.
createDataSource_name :: Lens.Lens' CreateDataSource Prelude.Text
createDataSource_name :: (Text -> f Text) -> CreateDataSource -> f CreateDataSource
createDataSource_name = (CreateDataSource -> Text)
-> (CreateDataSource -> Text -> CreateDataSource)
-> Lens CreateDataSource CreateDataSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {Text
name :: Text
$sel:name:CreateDataSource' :: CreateDataSource -> Text
name} -> Text
name) (\s :: CreateDataSource
s@CreateDataSource' {} Text
a -> CreateDataSource
s {$sel:name:CreateDataSource' :: Text
name = Text
a} :: CreateDataSource)

-- | The type of the @DataSource@.
createDataSource_type :: Lens.Lens' CreateDataSource DataSourceType
createDataSource_type :: (DataSourceType -> f DataSourceType)
-> CreateDataSource -> f CreateDataSource
createDataSource_type = (CreateDataSource -> DataSourceType)
-> (CreateDataSource -> DataSourceType -> CreateDataSource)
-> Lens
     CreateDataSource CreateDataSource DataSourceType DataSourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSource' {DataSourceType
type' :: DataSourceType
$sel:type':CreateDataSource' :: CreateDataSource -> DataSourceType
type'} -> DataSourceType
type') (\s :: CreateDataSource
s@CreateDataSource' {} DataSourceType
a -> CreateDataSource
s {$sel:type':CreateDataSource' :: DataSourceType
type' = DataSourceType
a} :: CreateDataSource)

instance Core.AWSRequest CreateDataSource where
  type
    AWSResponse CreateDataSource =
      CreateDataSourceResponse
  request :: CreateDataSource -> Request CreateDataSource
request = Service -> CreateDataSource -> Request CreateDataSource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDataSource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDataSource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDataSource))
-> Logger
-> Service
-> Proxy CreateDataSource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDataSource)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DataSource -> Int -> CreateDataSourceResponse
CreateDataSourceResponse'
            (Maybe DataSource -> Int -> CreateDataSourceResponse)
-> Either String (Maybe DataSource)
-> Either String (Int -> CreateDataSourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DataSource)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"dataSource")
            Either String (Int -> CreateDataSourceResponse)
-> Either String Int -> Either String CreateDataSourceResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateDataSource

instance Prelude.NFData CreateDataSource

instance Core.ToHeaders CreateDataSource where
  toHeaders :: CreateDataSource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDataSource -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateDataSource where
  toJSON :: CreateDataSource -> Value
toJSON CreateDataSource' {Maybe Text
Maybe DynamodbDataSourceConfig
Maybe ElasticsearchDataSourceConfig
Maybe HttpDataSourceConfig
Maybe LambdaDataSourceConfig
Maybe OpenSearchServiceDataSourceConfig
Maybe RelationalDatabaseDataSourceConfig
Text
DataSourceType
type' :: DataSourceType
name :: Text
apiId :: Text
elasticsearchConfig :: Maybe ElasticsearchDataSourceConfig
description :: Maybe Text
lambdaConfig :: Maybe LambdaDataSourceConfig
openSearchServiceConfig :: Maybe OpenSearchServiceDataSourceConfig
httpConfig :: Maybe HttpDataSourceConfig
dynamodbConfig :: Maybe DynamodbDataSourceConfig
relationalDatabaseConfig :: Maybe RelationalDatabaseDataSourceConfig
serviceRoleArn :: Maybe Text
$sel:type':CreateDataSource' :: CreateDataSource -> DataSourceType
$sel:name:CreateDataSource' :: CreateDataSource -> Text
$sel:apiId:CreateDataSource' :: CreateDataSource -> Text
$sel:elasticsearchConfig:CreateDataSource' :: CreateDataSource -> Maybe ElasticsearchDataSourceConfig
$sel:description:CreateDataSource' :: CreateDataSource -> Maybe Text
$sel:lambdaConfig:CreateDataSource' :: CreateDataSource -> Maybe LambdaDataSourceConfig
$sel:openSearchServiceConfig:CreateDataSource' :: CreateDataSource -> Maybe OpenSearchServiceDataSourceConfig
$sel:httpConfig:CreateDataSource' :: CreateDataSource -> Maybe HttpDataSourceConfig
$sel:dynamodbConfig:CreateDataSource' :: CreateDataSource -> Maybe DynamodbDataSourceConfig
$sel:relationalDatabaseConfig:CreateDataSource' :: CreateDataSource -> Maybe RelationalDatabaseDataSourceConfig
$sel:serviceRoleArn:CreateDataSource' :: CreateDataSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serviceRoleArn" 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
serviceRoleArn,
            (Text
"relationalDatabaseConfig" Text -> RelationalDatabaseDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RelationalDatabaseDataSourceConfig -> Pair)
-> Maybe RelationalDatabaseDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig,
            (Text
"dynamodbConfig" Text -> DynamodbDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DynamodbDataSourceConfig -> Pair)
-> Maybe DynamodbDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DynamodbDataSourceConfig
dynamodbConfig,
            (Text
"httpConfig" Text -> HttpDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HttpDataSourceConfig -> Pair)
-> Maybe HttpDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HttpDataSourceConfig
httpConfig,
            (Text
"openSearchServiceConfig" Text -> OpenSearchServiceDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OpenSearchServiceDataSourceConfig -> Pair)
-> Maybe OpenSearchServiceDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig,
            (Text
"lambdaConfig" Text -> LambdaDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LambdaDataSourceConfig -> Pair)
-> Maybe LambdaDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaDataSourceConfig
lambdaConfig,
            (Text
"description" 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
description,
            (Text
"elasticsearchConfig" Text -> ElasticsearchDataSourceConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ElasticsearchDataSourceConfig -> Pair)
-> Maybe ElasticsearchDataSourceConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> DataSourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DataSourceType
type')
          ]
      )

instance Core.ToPath CreateDataSource where
  toPath :: CreateDataSource -> ByteString
toPath CreateDataSource' {Maybe Text
Maybe DynamodbDataSourceConfig
Maybe ElasticsearchDataSourceConfig
Maybe HttpDataSourceConfig
Maybe LambdaDataSourceConfig
Maybe OpenSearchServiceDataSourceConfig
Maybe RelationalDatabaseDataSourceConfig
Text
DataSourceType
type' :: DataSourceType
name :: Text
apiId :: Text
elasticsearchConfig :: Maybe ElasticsearchDataSourceConfig
description :: Maybe Text
lambdaConfig :: Maybe LambdaDataSourceConfig
openSearchServiceConfig :: Maybe OpenSearchServiceDataSourceConfig
httpConfig :: Maybe HttpDataSourceConfig
dynamodbConfig :: Maybe DynamodbDataSourceConfig
relationalDatabaseConfig :: Maybe RelationalDatabaseDataSourceConfig
serviceRoleArn :: Maybe Text
$sel:type':CreateDataSource' :: CreateDataSource -> DataSourceType
$sel:name:CreateDataSource' :: CreateDataSource -> Text
$sel:apiId:CreateDataSource' :: CreateDataSource -> Text
$sel:elasticsearchConfig:CreateDataSource' :: CreateDataSource -> Maybe ElasticsearchDataSourceConfig
$sel:description:CreateDataSource' :: CreateDataSource -> Maybe Text
$sel:lambdaConfig:CreateDataSource' :: CreateDataSource -> Maybe LambdaDataSourceConfig
$sel:openSearchServiceConfig:CreateDataSource' :: CreateDataSource -> Maybe OpenSearchServiceDataSourceConfig
$sel:httpConfig:CreateDataSource' :: CreateDataSource -> Maybe HttpDataSourceConfig
$sel:dynamodbConfig:CreateDataSource' :: CreateDataSource -> Maybe DynamodbDataSourceConfig
$sel:relationalDatabaseConfig:CreateDataSource' :: CreateDataSource -> Maybe RelationalDatabaseDataSourceConfig
$sel:serviceRoleArn:CreateDataSource' :: CreateDataSource -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/apis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId, ByteString
"/datasources"]

instance Core.ToQuery CreateDataSource where
  toQuery :: CreateDataSource -> QueryString
toQuery = QueryString -> CreateDataSource -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateDataSourceResponse' smart constructor.
data CreateDataSourceResponse = CreateDataSourceResponse'
  { -- | The @DataSource@ object.
    CreateDataSourceResponse -> Maybe DataSource
dataSource :: Prelude.Maybe DataSource,
    -- | The response's http status code.
    CreateDataSourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDataSourceResponse -> CreateDataSourceResponse -> Bool
(CreateDataSourceResponse -> CreateDataSourceResponse -> Bool)
-> (CreateDataSourceResponse -> CreateDataSourceResponse -> Bool)
-> Eq CreateDataSourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataSourceResponse -> CreateDataSourceResponse -> Bool
$c/= :: CreateDataSourceResponse -> CreateDataSourceResponse -> Bool
== :: CreateDataSourceResponse -> CreateDataSourceResponse -> Bool
$c== :: CreateDataSourceResponse -> CreateDataSourceResponse -> Bool
Prelude.Eq, ReadPrec [CreateDataSourceResponse]
ReadPrec CreateDataSourceResponse
Int -> ReadS CreateDataSourceResponse
ReadS [CreateDataSourceResponse]
(Int -> ReadS CreateDataSourceResponse)
-> ReadS [CreateDataSourceResponse]
-> ReadPrec CreateDataSourceResponse
-> ReadPrec [CreateDataSourceResponse]
-> Read CreateDataSourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDataSourceResponse]
$creadListPrec :: ReadPrec [CreateDataSourceResponse]
readPrec :: ReadPrec CreateDataSourceResponse
$creadPrec :: ReadPrec CreateDataSourceResponse
readList :: ReadS [CreateDataSourceResponse]
$creadList :: ReadS [CreateDataSourceResponse]
readsPrec :: Int -> ReadS CreateDataSourceResponse
$creadsPrec :: Int -> ReadS CreateDataSourceResponse
Prelude.Read, Int -> CreateDataSourceResponse -> ShowS
[CreateDataSourceResponse] -> ShowS
CreateDataSourceResponse -> String
(Int -> CreateDataSourceResponse -> ShowS)
-> (CreateDataSourceResponse -> String)
-> ([CreateDataSourceResponse] -> ShowS)
-> Show CreateDataSourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataSourceResponse] -> ShowS
$cshowList :: [CreateDataSourceResponse] -> ShowS
show :: CreateDataSourceResponse -> String
$cshow :: CreateDataSourceResponse -> String
showsPrec :: Int -> CreateDataSourceResponse -> ShowS
$cshowsPrec :: Int -> CreateDataSourceResponse -> ShowS
Prelude.Show, (forall x.
 CreateDataSourceResponse -> Rep CreateDataSourceResponse x)
-> (forall x.
    Rep CreateDataSourceResponse x -> CreateDataSourceResponse)
-> Generic CreateDataSourceResponse
forall x.
Rep CreateDataSourceResponse x -> CreateDataSourceResponse
forall x.
CreateDataSourceResponse -> Rep CreateDataSourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDataSourceResponse x -> CreateDataSourceResponse
$cfrom :: forall x.
CreateDataSourceResponse -> Rep CreateDataSourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataSourceResponse' 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:
--
-- 'dataSource', 'createDataSourceResponse_dataSource' - The @DataSource@ object.
--
-- 'httpStatus', 'createDataSourceResponse_httpStatus' - The response's http status code.
newCreateDataSourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDataSourceResponse
newCreateDataSourceResponse :: Int -> CreateDataSourceResponse
newCreateDataSourceResponse Int
pHttpStatus_ =
  CreateDataSourceResponse' :: Maybe DataSource -> Int -> CreateDataSourceResponse
CreateDataSourceResponse'
    { $sel:dataSource:CreateDataSourceResponse' :: Maybe DataSource
dataSource =
        Maybe DataSource
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDataSourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @DataSource@ object.
createDataSourceResponse_dataSource :: Lens.Lens' CreateDataSourceResponse (Prelude.Maybe DataSource)
createDataSourceResponse_dataSource :: (Maybe DataSource -> f (Maybe DataSource))
-> CreateDataSourceResponse -> f CreateDataSourceResponse
createDataSourceResponse_dataSource = (CreateDataSourceResponse -> Maybe DataSource)
-> (CreateDataSourceResponse
    -> Maybe DataSource -> CreateDataSourceResponse)
-> Lens
     CreateDataSourceResponse
     CreateDataSourceResponse
     (Maybe DataSource)
     (Maybe DataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceResponse' {Maybe DataSource
dataSource :: Maybe DataSource
$sel:dataSource:CreateDataSourceResponse' :: CreateDataSourceResponse -> Maybe DataSource
dataSource} -> Maybe DataSource
dataSource) (\s :: CreateDataSourceResponse
s@CreateDataSourceResponse' {} Maybe DataSource
a -> CreateDataSourceResponse
s {$sel:dataSource:CreateDataSourceResponse' :: Maybe DataSource
dataSource = Maybe DataSource
a} :: CreateDataSourceResponse)

-- | The response's http status code.
createDataSourceResponse_httpStatus :: Lens.Lens' CreateDataSourceResponse Prelude.Int
createDataSourceResponse_httpStatus :: (Int -> f Int)
-> CreateDataSourceResponse -> f CreateDataSourceResponse
createDataSourceResponse_httpStatus = (CreateDataSourceResponse -> Int)
-> (CreateDataSourceResponse -> Int -> CreateDataSourceResponse)
-> Lens CreateDataSourceResponse CreateDataSourceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataSourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDataSourceResponse' :: CreateDataSourceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateDataSourceResponse
s@CreateDataSourceResponse' {} Int
a -> CreateDataSourceResponse
s {$sel:httpStatus:CreateDataSourceResponse' :: Int
httpStatus = Int
a} :: CreateDataSourceResponse)

instance Prelude.NFData CreateDataSourceResponse