{-# 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.ElasticsearchDataSourceConfig
-- 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.ElasticsearchDataSourceConfig where

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

-- | Describes an OpenSearch data source configuration.
--
-- As of September 2021, Amazon Elasticsearch service is Amazon OpenSearch
-- Service. This configuration is deprecated. For new data sources, use
-- OpenSearchServiceDataSourceConfig to specify an OpenSearch data source.
--
-- /See:/ 'newElasticsearchDataSourceConfig' smart constructor.
data ElasticsearchDataSourceConfig = ElasticsearchDataSourceConfig'
  { -- | The endpoint.
    ElasticsearchDataSourceConfig -> Text
endpoint :: Prelude.Text,
    -- | The Amazon Web Services Region.
    ElasticsearchDataSourceConfig -> Text
awsRegion :: Prelude.Text
  }
  deriving (ElasticsearchDataSourceConfig
-> ElasticsearchDataSourceConfig -> Bool
(ElasticsearchDataSourceConfig
 -> ElasticsearchDataSourceConfig -> Bool)
-> (ElasticsearchDataSourceConfig
    -> ElasticsearchDataSourceConfig -> Bool)
-> Eq ElasticsearchDataSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElasticsearchDataSourceConfig
-> ElasticsearchDataSourceConfig -> Bool
$c/= :: ElasticsearchDataSourceConfig
-> ElasticsearchDataSourceConfig -> Bool
== :: ElasticsearchDataSourceConfig
-> ElasticsearchDataSourceConfig -> Bool
$c== :: ElasticsearchDataSourceConfig
-> ElasticsearchDataSourceConfig -> Bool
Prelude.Eq, ReadPrec [ElasticsearchDataSourceConfig]
ReadPrec ElasticsearchDataSourceConfig
Int -> ReadS ElasticsearchDataSourceConfig
ReadS [ElasticsearchDataSourceConfig]
(Int -> ReadS ElasticsearchDataSourceConfig)
-> ReadS [ElasticsearchDataSourceConfig]
-> ReadPrec ElasticsearchDataSourceConfig
-> ReadPrec [ElasticsearchDataSourceConfig]
-> Read ElasticsearchDataSourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ElasticsearchDataSourceConfig]
$creadListPrec :: ReadPrec [ElasticsearchDataSourceConfig]
readPrec :: ReadPrec ElasticsearchDataSourceConfig
$creadPrec :: ReadPrec ElasticsearchDataSourceConfig
readList :: ReadS [ElasticsearchDataSourceConfig]
$creadList :: ReadS [ElasticsearchDataSourceConfig]
readsPrec :: Int -> ReadS ElasticsearchDataSourceConfig
$creadsPrec :: Int -> ReadS ElasticsearchDataSourceConfig
Prelude.Read, Int -> ElasticsearchDataSourceConfig -> ShowS
[ElasticsearchDataSourceConfig] -> ShowS
ElasticsearchDataSourceConfig -> String
(Int -> ElasticsearchDataSourceConfig -> ShowS)
-> (ElasticsearchDataSourceConfig -> String)
-> ([ElasticsearchDataSourceConfig] -> ShowS)
-> Show ElasticsearchDataSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElasticsearchDataSourceConfig] -> ShowS
$cshowList :: [ElasticsearchDataSourceConfig] -> ShowS
show :: ElasticsearchDataSourceConfig -> String
$cshow :: ElasticsearchDataSourceConfig -> String
showsPrec :: Int -> ElasticsearchDataSourceConfig -> ShowS
$cshowsPrec :: Int -> ElasticsearchDataSourceConfig -> ShowS
Prelude.Show, (forall x.
 ElasticsearchDataSourceConfig
 -> Rep ElasticsearchDataSourceConfig x)
-> (forall x.
    Rep ElasticsearchDataSourceConfig x
    -> ElasticsearchDataSourceConfig)
-> Generic ElasticsearchDataSourceConfig
forall x.
Rep ElasticsearchDataSourceConfig x
-> ElasticsearchDataSourceConfig
forall x.
ElasticsearchDataSourceConfig
-> Rep ElasticsearchDataSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ElasticsearchDataSourceConfig x
-> ElasticsearchDataSourceConfig
$cfrom :: forall x.
ElasticsearchDataSourceConfig
-> Rep ElasticsearchDataSourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'ElasticsearchDataSourceConfig' 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:
--
-- 'endpoint', 'elasticsearchDataSourceConfig_endpoint' - The endpoint.
--
-- 'awsRegion', 'elasticsearchDataSourceConfig_awsRegion' - The Amazon Web Services Region.
newElasticsearchDataSourceConfig ::
  -- | 'endpoint'
  Prelude.Text ->
  -- | 'awsRegion'
  Prelude.Text ->
  ElasticsearchDataSourceConfig
newElasticsearchDataSourceConfig :: Text -> Text -> ElasticsearchDataSourceConfig
newElasticsearchDataSourceConfig
  Text
pEndpoint_
  Text
pAwsRegion_ =
    ElasticsearchDataSourceConfig' :: Text -> Text -> ElasticsearchDataSourceConfig
ElasticsearchDataSourceConfig'
      { $sel:endpoint:ElasticsearchDataSourceConfig' :: Text
endpoint =
          Text
pEndpoint_,
        $sel:awsRegion:ElasticsearchDataSourceConfig' :: Text
awsRegion = Text
pAwsRegion_
      }

-- | The endpoint.
elasticsearchDataSourceConfig_endpoint :: Lens.Lens' ElasticsearchDataSourceConfig Prelude.Text
elasticsearchDataSourceConfig_endpoint :: (Text -> f Text)
-> ElasticsearchDataSourceConfig -> f ElasticsearchDataSourceConfig
elasticsearchDataSourceConfig_endpoint = (ElasticsearchDataSourceConfig -> Text)
-> (ElasticsearchDataSourceConfig
    -> Text -> ElasticsearchDataSourceConfig)
-> Lens
     ElasticsearchDataSourceConfig
     ElasticsearchDataSourceConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchDataSourceConfig' {Text
endpoint :: Text
$sel:endpoint:ElasticsearchDataSourceConfig' :: ElasticsearchDataSourceConfig -> Text
endpoint} -> Text
endpoint) (\s :: ElasticsearchDataSourceConfig
s@ElasticsearchDataSourceConfig' {} Text
a -> ElasticsearchDataSourceConfig
s {$sel:endpoint:ElasticsearchDataSourceConfig' :: Text
endpoint = Text
a} :: ElasticsearchDataSourceConfig)

-- | The Amazon Web Services Region.
elasticsearchDataSourceConfig_awsRegion :: Lens.Lens' ElasticsearchDataSourceConfig Prelude.Text
elasticsearchDataSourceConfig_awsRegion :: (Text -> f Text)
-> ElasticsearchDataSourceConfig -> f ElasticsearchDataSourceConfig
elasticsearchDataSourceConfig_awsRegion = (ElasticsearchDataSourceConfig -> Text)
-> (ElasticsearchDataSourceConfig
    -> Text -> ElasticsearchDataSourceConfig)
-> Lens
     ElasticsearchDataSourceConfig
     ElasticsearchDataSourceConfig
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchDataSourceConfig' {Text
awsRegion :: Text
$sel:awsRegion:ElasticsearchDataSourceConfig' :: ElasticsearchDataSourceConfig -> Text
awsRegion} -> Text
awsRegion) (\s :: ElasticsearchDataSourceConfig
s@ElasticsearchDataSourceConfig' {} Text
a -> ElasticsearchDataSourceConfig
s {$sel:awsRegion:ElasticsearchDataSourceConfig' :: Text
awsRegion = Text
a} :: ElasticsearchDataSourceConfig)

instance Core.FromJSON ElasticsearchDataSourceConfig where
  parseJSON :: Value -> Parser ElasticsearchDataSourceConfig
parseJSON =
    String
-> (Object -> Parser ElasticsearchDataSourceConfig)
-> Value
-> Parser ElasticsearchDataSourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ElasticsearchDataSourceConfig"
      ( \Object
x ->
          Text -> Text -> ElasticsearchDataSourceConfig
ElasticsearchDataSourceConfig'
            (Text -> Text -> ElasticsearchDataSourceConfig)
-> Parser Text -> Parser (Text -> ElasticsearchDataSourceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"endpoint")
            Parser (Text -> ElasticsearchDataSourceConfig)
-> Parser Text -> Parser ElasticsearchDataSourceConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"awsRegion")
      )

instance
  Prelude.Hashable
    ElasticsearchDataSourceConfig

instance Prelude.NFData ElasticsearchDataSourceConfig

instance Core.ToJSON ElasticsearchDataSourceConfig where
  toJSON :: ElasticsearchDataSourceConfig -> Value
toJSON ElasticsearchDataSourceConfig' {Text
awsRegion :: Text
endpoint :: Text
$sel:awsRegion:ElasticsearchDataSourceConfig' :: ElasticsearchDataSourceConfig -> Text
$sel:endpoint:ElasticsearchDataSourceConfig' :: ElasticsearchDataSourceConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"awsRegion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
awsRegion)
          ]
      )