{-# 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.OpenSearchServiceDataSourceConfig
-- 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.OpenSearchServiceDataSourceConfig 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.
--
-- /See:/ 'newOpenSearchServiceDataSourceConfig' smart constructor.
data OpenSearchServiceDataSourceConfig = OpenSearchServiceDataSourceConfig'
  { -- | The endpoint.
    OpenSearchServiceDataSourceConfig -> Text
endpoint :: Prelude.Text,
    -- | The Amazon Web Services Region.
    OpenSearchServiceDataSourceConfig -> Text
awsRegion :: Prelude.Text
  }
  deriving (OpenSearchServiceDataSourceConfig
-> OpenSearchServiceDataSourceConfig -> Bool
(OpenSearchServiceDataSourceConfig
 -> OpenSearchServiceDataSourceConfig -> Bool)
-> (OpenSearchServiceDataSourceConfig
    -> OpenSearchServiceDataSourceConfig -> Bool)
-> Eq OpenSearchServiceDataSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpenSearchServiceDataSourceConfig
-> OpenSearchServiceDataSourceConfig -> Bool
$c/= :: OpenSearchServiceDataSourceConfig
-> OpenSearchServiceDataSourceConfig -> Bool
== :: OpenSearchServiceDataSourceConfig
-> OpenSearchServiceDataSourceConfig -> Bool
$c== :: OpenSearchServiceDataSourceConfig
-> OpenSearchServiceDataSourceConfig -> Bool
Prelude.Eq, ReadPrec [OpenSearchServiceDataSourceConfig]
ReadPrec OpenSearchServiceDataSourceConfig
Int -> ReadS OpenSearchServiceDataSourceConfig
ReadS [OpenSearchServiceDataSourceConfig]
(Int -> ReadS OpenSearchServiceDataSourceConfig)
-> ReadS [OpenSearchServiceDataSourceConfig]
-> ReadPrec OpenSearchServiceDataSourceConfig
-> ReadPrec [OpenSearchServiceDataSourceConfig]
-> Read OpenSearchServiceDataSourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpenSearchServiceDataSourceConfig]
$creadListPrec :: ReadPrec [OpenSearchServiceDataSourceConfig]
readPrec :: ReadPrec OpenSearchServiceDataSourceConfig
$creadPrec :: ReadPrec OpenSearchServiceDataSourceConfig
readList :: ReadS [OpenSearchServiceDataSourceConfig]
$creadList :: ReadS [OpenSearchServiceDataSourceConfig]
readsPrec :: Int -> ReadS OpenSearchServiceDataSourceConfig
$creadsPrec :: Int -> ReadS OpenSearchServiceDataSourceConfig
Prelude.Read, Int -> OpenSearchServiceDataSourceConfig -> ShowS
[OpenSearchServiceDataSourceConfig] -> ShowS
OpenSearchServiceDataSourceConfig -> String
(Int -> OpenSearchServiceDataSourceConfig -> ShowS)
-> (OpenSearchServiceDataSourceConfig -> String)
-> ([OpenSearchServiceDataSourceConfig] -> ShowS)
-> Show OpenSearchServiceDataSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpenSearchServiceDataSourceConfig] -> ShowS
$cshowList :: [OpenSearchServiceDataSourceConfig] -> ShowS
show :: OpenSearchServiceDataSourceConfig -> String
$cshow :: OpenSearchServiceDataSourceConfig -> String
showsPrec :: Int -> OpenSearchServiceDataSourceConfig -> ShowS
$cshowsPrec :: Int -> OpenSearchServiceDataSourceConfig -> ShowS
Prelude.Show, (forall x.
 OpenSearchServiceDataSourceConfig
 -> Rep OpenSearchServiceDataSourceConfig x)
-> (forall x.
    Rep OpenSearchServiceDataSourceConfig x
    -> OpenSearchServiceDataSourceConfig)
-> Generic OpenSearchServiceDataSourceConfig
forall x.
Rep OpenSearchServiceDataSourceConfig x
-> OpenSearchServiceDataSourceConfig
forall x.
OpenSearchServiceDataSourceConfig
-> Rep OpenSearchServiceDataSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OpenSearchServiceDataSourceConfig x
-> OpenSearchServiceDataSourceConfig
$cfrom :: forall x.
OpenSearchServiceDataSourceConfig
-> Rep OpenSearchServiceDataSourceConfig x
Prelude.Generic)

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

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

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

instance
  Core.FromJSON
    OpenSearchServiceDataSourceConfig
  where
  parseJSON :: Value -> Parser OpenSearchServiceDataSourceConfig
parseJSON =
    String
-> (Object -> Parser OpenSearchServiceDataSourceConfig)
-> Value
-> Parser OpenSearchServiceDataSourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OpenSearchServiceDataSourceConfig"
      ( \Object
x ->
          Text -> Text -> OpenSearchServiceDataSourceConfig
OpenSearchServiceDataSourceConfig'
            (Text -> Text -> OpenSearchServiceDataSourceConfig)
-> Parser Text
-> Parser (Text -> OpenSearchServiceDataSourceConfig)
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 -> OpenSearchServiceDataSourceConfig)
-> Parser Text -> Parser OpenSearchServiceDataSourceConfig
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
    OpenSearchServiceDataSourceConfig

instance
  Prelude.NFData
    OpenSearchServiceDataSourceConfig

instance
  Core.ToJSON
    OpenSearchServiceDataSourceConfig
  where
  toJSON :: OpenSearchServiceDataSourceConfig -> Value
toJSON OpenSearchServiceDataSourceConfig' {Text
awsRegion :: Text
endpoint :: Text
$sel:awsRegion:OpenSearchServiceDataSourceConfig' :: OpenSearchServiceDataSourceConfig -> Text
$sel:endpoint:OpenSearchServiceDataSourceConfig' :: OpenSearchServiceDataSourceConfig -> 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)
          ]
      )