{-# 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.UpdateDataSource
-- 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)
--
-- Updates a @DataSource@ object.
module Amazonka.AppSync.UpdateDataSource
  ( -- * Creating a Request
    UpdateDataSource (..),
    newUpdateDataSource,

    -- * Request Lenses
    updateDataSource_serviceRoleArn,
    updateDataSource_relationalDatabaseConfig,
    updateDataSource_dynamodbConfig,
    updateDataSource_httpConfig,
    updateDataSource_openSearchServiceConfig,
    updateDataSource_lambdaConfig,
    updateDataSource_description,
    updateDataSource_elasticsearchConfig,
    updateDataSource_apiId,
    updateDataSource_name,
    updateDataSource_type,

    -- * Destructuring the Response
    UpdateDataSourceResponse (..),
    newUpdateDataSourceResponse,

    -- * Response Lenses
    updateDataSourceResponse_dataSource,
    updateDataSourceResponse_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:/ 'newUpdateDataSource' smart constructor.
data UpdateDataSource = UpdateDataSource'
  { -- | The new service role ARN for the data source.
    UpdateDataSource -> Maybe Text
serviceRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The new relational database configuration.
    UpdateDataSource -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig :: Prelude.Maybe RelationalDatabaseDataSourceConfig,
    -- | The new Amazon DynamoDB configuration.
    UpdateDataSource -> Maybe DynamodbDataSourceConfig
dynamodbConfig :: Prelude.Maybe DynamodbDataSourceConfig,
    -- | The new HTTP endpoint configuration.
    UpdateDataSource -> Maybe HttpDataSourceConfig
httpConfig :: Prelude.Maybe HttpDataSourceConfig,
    -- | The new OpenSearch configuration.
    UpdateDataSource -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig :: Prelude.Maybe OpenSearchServiceDataSourceConfig,
    -- | The new Amazon Web Services Lambda configuration.
    UpdateDataSource -> Maybe LambdaDataSourceConfig
lambdaConfig :: Prelude.Maybe LambdaDataSourceConfig,
    -- | The new description for the data source.
    UpdateDataSource -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The new OpenSearch configuration.
    --
    -- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
    -- Service. This configuration is deprecated. Instead, use
    -- UpdateDataSourceRequest$openSearchServiceConfig to update an OpenSearch
    -- data source.
    UpdateDataSource -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig :: Prelude.Maybe ElasticsearchDataSourceConfig,
    -- | The API ID.
    UpdateDataSource -> Text
apiId :: Prelude.Text,
    -- | The new name for the data source.
    UpdateDataSource -> Text
name :: Prelude.Text,
    -- | The new data source type.
    UpdateDataSource -> DataSourceType
type' :: DataSourceType
  }
  deriving (UpdateDataSource -> UpdateDataSource -> Bool
(UpdateDataSource -> UpdateDataSource -> Bool)
-> (UpdateDataSource -> UpdateDataSource -> Bool)
-> Eq UpdateDataSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDataSource -> UpdateDataSource -> Bool
$c/= :: UpdateDataSource -> UpdateDataSource -> Bool
== :: UpdateDataSource -> UpdateDataSource -> Bool
$c== :: UpdateDataSource -> UpdateDataSource -> Bool
Prelude.Eq, ReadPrec [UpdateDataSource]
ReadPrec UpdateDataSource
Int -> ReadS UpdateDataSource
ReadS [UpdateDataSource]
(Int -> ReadS UpdateDataSource)
-> ReadS [UpdateDataSource]
-> ReadPrec UpdateDataSource
-> ReadPrec [UpdateDataSource]
-> Read UpdateDataSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDataSource]
$creadListPrec :: ReadPrec [UpdateDataSource]
readPrec :: ReadPrec UpdateDataSource
$creadPrec :: ReadPrec UpdateDataSource
readList :: ReadS [UpdateDataSource]
$creadList :: ReadS [UpdateDataSource]
readsPrec :: Int -> ReadS UpdateDataSource
$creadsPrec :: Int -> ReadS UpdateDataSource
Prelude.Read, Int -> UpdateDataSource -> ShowS
[UpdateDataSource] -> ShowS
UpdateDataSource -> String
(Int -> UpdateDataSource -> ShowS)
-> (UpdateDataSource -> String)
-> ([UpdateDataSource] -> ShowS)
-> Show UpdateDataSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDataSource] -> ShowS
$cshowList :: [UpdateDataSource] -> ShowS
show :: UpdateDataSource -> String
$cshow :: UpdateDataSource -> String
showsPrec :: Int -> UpdateDataSource -> ShowS
$cshowsPrec :: Int -> UpdateDataSource -> ShowS
Prelude.Show, (forall x. UpdateDataSource -> Rep UpdateDataSource x)
-> (forall x. Rep UpdateDataSource x -> UpdateDataSource)
-> Generic UpdateDataSource
forall x. Rep UpdateDataSource x -> UpdateDataSource
forall x. UpdateDataSource -> Rep UpdateDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDataSource x -> UpdateDataSource
$cfrom :: forall x. UpdateDataSource -> Rep UpdateDataSource x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDataSource' 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', 'updateDataSource_serviceRoleArn' - The new service role ARN for the data source.
--
-- 'relationalDatabaseConfig', 'updateDataSource_relationalDatabaseConfig' - The new relational database configuration.
--
-- 'dynamodbConfig', 'updateDataSource_dynamodbConfig' - The new Amazon DynamoDB configuration.
--
-- 'httpConfig', 'updateDataSource_httpConfig' - The new HTTP endpoint configuration.
--
-- 'openSearchServiceConfig', 'updateDataSource_openSearchServiceConfig' - The new OpenSearch configuration.
--
-- 'lambdaConfig', 'updateDataSource_lambdaConfig' - The new Amazon Web Services Lambda configuration.
--
-- 'description', 'updateDataSource_description' - The new description for the data source.
--
-- 'elasticsearchConfig', 'updateDataSource_elasticsearchConfig' - The new OpenSearch configuration.
--
-- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
-- Service. This configuration is deprecated. Instead, use
-- UpdateDataSourceRequest$openSearchServiceConfig to update an OpenSearch
-- data source.
--
-- 'apiId', 'updateDataSource_apiId' - The API ID.
--
-- 'name', 'updateDataSource_name' - The new name for the data source.
--
-- 'type'', 'updateDataSource_type' - The new data source type.
newUpdateDataSource ::
  -- | 'apiId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  DataSourceType ->
  UpdateDataSource
newUpdateDataSource :: Text -> Text -> DataSourceType -> UpdateDataSource
newUpdateDataSource Text
pApiId_ Text
pName_ DataSourceType
pType_ =
  UpdateDataSource' :: Maybe Text
-> Maybe RelationalDatabaseDataSourceConfig
-> Maybe DynamodbDataSourceConfig
-> Maybe HttpDataSourceConfig
-> Maybe OpenSearchServiceDataSourceConfig
-> Maybe LambdaDataSourceConfig
-> Maybe Text
-> Maybe ElasticsearchDataSourceConfig
-> Text
-> Text
-> DataSourceType
-> UpdateDataSource
UpdateDataSource'
    { $sel:serviceRoleArn:UpdateDataSource' :: Maybe Text
serviceRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relationalDatabaseConfig:UpdateDataSource' :: Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig = Maybe RelationalDatabaseDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:dynamodbConfig:UpdateDataSource' :: Maybe DynamodbDataSourceConfig
dynamodbConfig = Maybe DynamodbDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:httpConfig:UpdateDataSource' :: Maybe HttpDataSourceConfig
httpConfig = Maybe HttpDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:openSearchServiceConfig:UpdateDataSource' :: Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig = Maybe OpenSearchServiceDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaConfig:UpdateDataSource' :: Maybe LambdaDataSourceConfig
lambdaConfig = Maybe LambdaDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateDataSource' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:elasticsearchConfig:UpdateDataSource' :: Maybe ElasticsearchDataSourceConfig
elasticsearchConfig = Maybe ElasticsearchDataSourceConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:apiId:UpdateDataSource' :: Text
apiId = Text
pApiId_,
      $sel:name:UpdateDataSource' :: Text
name = Text
pName_,
      $sel:type':UpdateDataSource' :: DataSourceType
type' = DataSourceType
pType_
    }

-- | The new service role ARN for the data source.
updateDataSource_serviceRoleArn :: Lens.Lens' UpdateDataSource (Prelude.Maybe Prelude.Text)
updateDataSource_serviceRoleArn :: (Maybe Text -> f (Maybe Text))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_serviceRoleArn = (UpdateDataSource -> Maybe Text)
-> (UpdateDataSource -> Maybe Text -> UpdateDataSource)
-> Lens UpdateDataSource UpdateDataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe Text
serviceRoleArn :: Maybe Text
$sel:serviceRoleArn:UpdateDataSource' :: UpdateDataSource -> Maybe Text
serviceRoleArn} -> Maybe Text
serviceRoleArn) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe Text
a -> UpdateDataSource
s {$sel:serviceRoleArn:UpdateDataSource' :: Maybe Text
serviceRoleArn = Maybe Text
a} :: UpdateDataSource)

-- | The new relational database configuration.
updateDataSource_relationalDatabaseConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe RelationalDatabaseDataSourceConfig)
updateDataSource_relationalDatabaseConfig :: (Maybe RelationalDatabaseDataSourceConfig
 -> f (Maybe RelationalDatabaseDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_relationalDatabaseConfig = (UpdateDataSource -> Maybe RelationalDatabaseDataSourceConfig)
-> (UpdateDataSource
    -> Maybe RelationalDatabaseDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe RelationalDatabaseDataSourceConfig)
     (Maybe RelationalDatabaseDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig :: Maybe RelationalDatabaseDataSourceConfig
$sel:relationalDatabaseConfig:UpdateDataSource' :: UpdateDataSource -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig} -> Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe RelationalDatabaseDataSourceConfig
a -> UpdateDataSource
s {$sel:relationalDatabaseConfig:UpdateDataSource' :: Maybe RelationalDatabaseDataSourceConfig
relationalDatabaseConfig = Maybe RelationalDatabaseDataSourceConfig
a} :: UpdateDataSource)

-- | The new Amazon DynamoDB configuration.
updateDataSource_dynamodbConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe DynamodbDataSourceConfig)
updateDataSource_dynamodbConfig :: (Maybe DynamodbDataSourceConfig
 -> f (Maybe DynamodbDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_dynamodbConfig = (UpdateDataSource -> Maybe DynamodbDataSourceConfig)
-> (UpdateDataSource
    -> Maybe DynamodbDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe DynamodbDataSourceConfig)
     (Maybe DynamodbDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe DynamodbDataSourceConfig
dynamodbConfig :: Maybe DynamodbDataSourceConfig
$sel:dynamodbConfig:UpdateDataSource' :: UpdateDataSource -> Maybe DynamodbDataSourceConfig
dynamodbConfig} -> Maybe DynamodbDataSourceConfig
dynamodbConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe DynamodbDataSourceConfig
a -> UpdateDataSource
s {$sel:dynamodbConfig:UpdateDataSource' :: Maybe DynamodbDataSourceConfig
dynamodbConfig = Maybe DynamodbDataSourceConfig
a} :: UpdateDataSource)

-- | The new HTTP endpoint configuration.
updateDataSource_httpConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe HttpDataSourceConfig)
updateDataSource_httpConfig :: (Maybe HttpDataSourceConfig -> f (Maybe HttpDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_httpConfig = (UpdateDataSource -> Maybe HttpDataSourceConfig)
-> (UpdateDataSource
    -> Maybe HttpDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe HttpDataSourceConfig)
     (Maybe HttpDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe HttpDataSourceConfig
httpConfig :: Maybe HttpDataSourceConfig
$sel:httpConfig:UpdateDataSource' :: UpdateDataSource -> Maybe HttpDataSourceConfig
httpConfig} -> Maybe HttpDataSourceConfig
httpConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe HttpDataSourceConfig
a -> UpdateDataSource
s {$sel:httpConfig:UpdateDataSource' :: Maybe HttpDataSourceConfig
httpConfig = Maybe HttpDataSourceConfig
a} :: UpdateDataSource)

-- | The new OpenSearch configuration.
updateDataSource_openSearchServiceConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe OpenSearchServiceDataSourceConfig)
updateDataSource_openSearchServiceConfig :: (Maybe OpenSearchServiceDataSourceConfig
 -> f (Maybe OpenSearchServiceDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_openSearchServiceConfig = (UpdateDataSource -> Maybe OpenSearchServiceDataSourceConfig)
-> (UpdateDataSource
    -> Maybe OpenSearchServiceDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe OpenSearchServiceDataSourceConfig)
     (Maybe OpenSearchServiceDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig :: Maybe OpenSearchServiceDataSourceConfig
$sel:openSearchServiceConfig:UpdateDataSource' :: UpdateDataSource -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig} -> Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe OpenSearchServiceDataSourceConfig
a -> UpdateDataSource
s {$sel:openSearchServiceConfig:UpdateDataSource' :: Maybe OpenSearchServiceDataSourceConfig
openSearchServiceConfig = Maybe OpenSearchServiceDataSourceConfig
a} :: UpdateDataSource)

-- | The new Amazon Web Services Lambda configuration.
updateDataSource_lambdaConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe LambdaDataSourceConfig)
updateDataSource_lambdaConfig :: (Maybe LambdaDataSourceConfig -> f (Maybe LambdaDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_lambdaConfig = (UpdateDataSource -> Maybe LambdaDataSourceConfig)
-> (UpdateDataSource
    -> Maybe LambdaDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe LambdaDataSourceConfig)
     (Maybe LambdaDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe LambdaDataSourceConfig
lambdaConfig :: Maybe LambdaDataSourceConfig
$sel:lambdaConfig:UpdateDataSource' :: UpdateDataSource -> Maybe LambdaDataSourceConfig
lambdaConfig} -> Maybe LambdaDataSourceConfig
lambdaConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe LambdaDataSourceConfig
a -> UpdateDataSource
s {$sel:lambdaConfig:UpdateDataSource' :: Maybe LambdaDataSourceConfig
lambdaConfig = Maybe LambdaDataSourceConfig
a} :: UpdateDataSource)

-- | The new description for the data source.
updateDataSource_description :: Lens.Lens' UpdateDataSource (Prelude.Maybe Prelude.Text)
updateDataSource_description :: (Maybe Text -> f (Maybe Text))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_description = (UpdateDataSource -> Maybe Text)
-> (UpdateDataSource -> Maybe Text -> UpdateDataSource)
-> Lens UpdateDataSource UpdateDataSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe Text
description :: Maybe Text
$sel:description:UpdateDataSource' :: UpdateDataSource -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe Text
a -> UpdateDataSource
s {$sel:description:UpdateDataSource' :: Maybe Text
description = Maybe Text
a} :: UpdateDataSource)

-- | The new OpenSearch configuration.
--
-- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
-- Service. This configuration is deprecated. Instead, use
-- UpdateDataSourceRequest$openSearchServiceConfig to update an OpenSearch
-- data source.
updateDataSource_elasticsearchConfig :: Lens.Lens' UpdateDataSource (Prelude.Maybe ElasticsearchDataSourceConfig)
updateDataSource_elasticsearchConfig :: (Maybe ElasticsearchDataSourceConfig
 -> f (Maybe ElasticsearchDataSourceConfig))
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_elasticsearchConfig = (UpdateDataSource -> Maybe ElasticsearchDataSourceConfig)
-> (UpdateDataSource
    -> Maybe ElasticsearchDataSourceConfig -> UpdateDataSource)
-> Lens
     UpdateDataSource
     UpdateDataSource
     (Maybe ElasticsearchDataSourceConfig)
     (Maybe ElasticsearchDataSourceConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Maybe ElasticsearchDataSourceConfig
elasticsearchConfig :: Maybe ElasticsearchDataSourceConfig
$sel:elasticsearchConfig:UpdateDataSource' :: UpdateDataSource -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig} -> Maybe ElasticsearchDataSourceConfig
elasticsearchConfig) (\s :: UpdateDataSource
s@UpdateDataSource' {} Maybe ElasticsearchDataSourceConfig
a -> UpdateDataSource
s {$sel:elasticsearchConfig:UpdateDataSource' :: Maybe ElasticsearchDataSourceConfig
elasticsearchConfig = Maybe ElasticsearchDataSourceConfig
a} :: UpdateDataSource)

-- | The API ID.
updateDataSource_apiId :: Lens.Lens' UpdateDataSource Prelude.Text
updateDataSource_apiId :: (Text -> f Text) -> UpdateDataSource -> f UpdateDataSource
updateDataSource_apiId = (UpdateDataSource -> Text)
-> (UpdateDataSource -> Text -> UpdateDataSource)
-> Lens UpdateDataSource UpdateDataSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Text
apiId :: Text
$sel:apiId:UpdateDataSource' :: UpdateDataSource -> Text
apiId} -> Text
apiId) (\s :: UpdateDataSource
s@UpdateDataSource' {} Text
a -> UpdateDataSource
s {$sel:apiId:UpdateDataSource' :: Text
apiId = Text
a} :: UpdateDataSource)

-- | The new name for the data source.
updateDataSource_name :: Lens.Lens' UpdateDataSource Prelude.Text
updateDataSource_name :: (Text -> f Text) -> UpdateDataSource -> f UpdateDataSource
updateDataSource_name = (UpdateDataSource -> Text)
-> (UpdateDataSource -> Text -> UpdateDataSource)
-> Lens UpdateDataSource UpdateDataSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {Text
name :: Text
$sel:name:UpdateDataSource' :: UpdateDataSource -> Text
name} -> Text
name) (\s :: UpdateDataSource
s@UpdateDataSource' {} Text
a -> UpdateDataSource
s {$sel:name:UpdateDataSource' :: Text
name = Text
a} :: UpdateDataSource)

-- | The new data source type.
updateDataSource_type :: Lens.Lens' UpdateDataSource DataSourceType
updateDataSource_type :: (DataSourceType -> f DataSourceType)
-> UpdateDataSource -> f UpdateDataSource
updateDataSource_type = (UpdateDataSource -> DataSourceType)
-> (UpdateDataSource -> DataSourceType -> UpdateDataSource)
-> Lens
     UpdateDataSource UpdateDataSource DataSourceType DataSourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDataSource' {DataSourceType
type' :: DataSourceType
$sel:type':UpdateDataSource' :: UpdateDataSource -> DataSourceType
type'} -> DataSourceType
type') (\s :: UpdateDataSource
s@UpdateDataSource' {} DataSourceType
a -> UpdateDataSource
s {$sel:type':UpdateDataSource' :: DataSourceType
type' = DataSourceType
a} :: UpdateDataSource)

instance Core.AWSRequest UpdateDataSource where
  type
    AWSResponse UpdateDataSource =
      UpdateDataSourceResponse
  request :: UpdateDataSource -> Request UpdateDataSource
request = Service -> UpdateDataSource -> Request UpdateDataSource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDataSource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDataSource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateDataSource))
-> Logger
-> Service
-> Proxy UpdateDataSource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDataSource)))
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 -> UpdateDataSourceResponse
UpdateDataSourceResponse'
            (Maybe DataSource -> Int -> UpdateDataSourceResponse)
-> Either String (Maybe DataSource)
-> Either String (Int -> UpdateDataSourceResponse)
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 -> UpdateDataSourceResponse)
-> Either String Int -> Either String UpdateDataSourceResponse
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 UpdateDataSource

instance Prelude.NFData UpdateDataSource

instance Core.ToHeaders UpdateDataSource where
  toHeaders :: UpdateDataSource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDataSource -> 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 UpdateDataSource where
  toJSON :: UpdateDataSource -> Value
toJSON UpdateDataSource' {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':UpdateDataSource' :: UpdateDataSource -> DataSourceType
$sel:name:UpdateDataSource' :: UpdateDataSource -> Text
$sel:apiId:UpdateDataSource' :: UpdateDataSource -> Text
$sel:elasticsearchConfig:UpdateDataSource' :: UpdateDataSource -> Maybe ElasticsearchDataSourceConfig
$sel:description:UpdateDataSource' :: UpdateDataSource -> Maybe Text
$sel:lambdaConfig:UpdateDataSource' :: UpdateDataSource -> Maybe LambdaDataSourceConfig
$sel:openSearchServiceConfig:UpdateDataSource' :: UpdateDataSource -> Maybe OpenSearchServiceDataSourceConfig
$sel:httpConfig:UpdateDataSource' :: UpdateDataSource -> Maybe HttpDataSourceConfig
$sel:dynamodbConfig:UpdateDataSource' :: UpdateDataSource -> Maybe DynamodbDataSourceConfig
$sel:relationalDatabaseConfig:UpdateDataSource' :: UpdateDataSource -> Maybe RelationalDatabaseDataSourceConfig
$sel:serviceRoleArn:UpdateDataSource' :: UpdateDataSource -> 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
"type" Text -> DataSourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DataSourceType
type')
          ]
      )

instance Core.ToPath UpdateDataSource where
  toPath :: UpdateDataSource -> ByteString
toPath UpdateDataSource' {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':UpdateDataSource' :: UpdateDataSource -> DataSourceType
$sel:name:UpdateDataSource' :: UpdateDataSource -> Text
$sel:apiId:UpdateDataSource' :: UpdateDataSource -> Text
$sel:elasticsearchConfig:UpdateDataSource' :: UpdateDataSource -> Maybe ElasticsearchDataSourceConfig
$sel:description:UpdateDataSource' :: UpdateDataSource -> Maybe Text
$sel:lambdaConfig:UpdateDataSource' :: UpdateDataSource -> Maybe LambdaDataSourceConfig
$sel:openSearchServiceConfig:UpdateDataSource' :: UpdateDataSource -> Maybe OpenSearchServiceDataSourceConfig
$sel:httpConfig:UpdateDataSource' :: UpdateDataSource -> Maybe HttpDataSourceConfig
$sel:dynamodbConfig:UpdateDataSource' :: UpdateDataSource -> Maybe DynamodbDataSourceConfig
$sel:relationalDatabaseConfig:UpdateDataSource' :: UpdateDataSource -> Maybe RelationalDatabaseDataSourceConfig
$sel:serviceRoleArn:UpdateDataSource' :: UpdateDataSource -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name
      ]

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

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

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

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

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

instance Prelude.NFData UpdateDataSourceResponse