{-# 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.DMS.Types.ElasticsearchSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DMS.Types.ElasticsearchSettings where

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

-- | Provides information that defines an OpenSearch endpoint.
--
-- /See:/ 'newElasticsearchSettings' smart constructor.
data ElasticsearchSettings = ElasticsearchSettings'
  { -- | The maximum number of seconds for which DMS retries failed API requests
    -- to the OpenSearch cluster.
    ElasticsearchSettings -> Maybe Int
errorRetryDuration :: Prelude.Maybe Prelude.Int,
    -- | The maximum percentage of records that can fail to be written before a
    -- full load operation stops.
    --
    -- To avoid early failure, this counter is only effective after 1000
    -- records are transferred. OpenSearch also has the concept of error
    -- monitoring during the last 10 minutes of an Observation Window. If
    -- transfer of all records fail in the last 10 minutes, the full load
    -- operation stops.
    ElasticsearchSettings -> Maybe Int
fullLoadErrorPercentage :: Prelude.Maybe Prelude.Int,
    -- | Set this option to @true@ for DMS to migrate documentation using the
    -- documentation type @_doc@. OpenSearch and an Elasticsearch cluster only
    -- support the _doc documentation type in versions 7. x and later. The
    -- default value is @false@.
    ElasticsearchSettings -> Maybe Bool
useNewMappingType :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) used by the service to access the IAM
    -- role. The role must allow the @iam:PassRole@ action.
    ElasticsearchSettings -> Text
serviceAccessRoleArn :: Prelude.Text,
    -- | The endpoint for the OpenSearch cluster. DMS uses HTTPS if a transport
    -- protocol (http\/https) is not specified.
    ElasticsearchSettings -> Text
endpointUri :: Prelude.Text
  }
  deriving (ElasticsearchSettings -> ElasticsearchSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElasticsearchSettings -> ElasticsearchSettings -> Bool
$c/= :: ElasticsearchSettings -> ElasticsearchSettings -> Bool
== :: ElasticsearchSettings -> ElasticsearchSettings -> Bool
$c== :: ElasticsearchSettings -> ElasticsearchSettings -> Bool
Prelude.Eq, ReadPrec [ElasticsearchSettings]
ReadPrec ElasticsearchSettings
Int -> ReadS ElasticsearchSettings
ReadS [ElasticsearchSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ElasticsearchSettings]
$creadListPrec :: ReadPrec [ElasticsearchSettings]
readPrec :: ReadPrec ElasticsearchSettings
$creadPrec :: ReadPrec ElasticsearchSettings
readList :: ReadS [ElasticsearchSettings]
$creadList :: ReadS [ElasticsearchSettings]
readsPrec :: Int -> ReadS ElasticsearchSettings
$creadsPrec :: Int -> ReadS ElasticsearchSettings
Prelude.Read, Int -> ElasticsearchSettings -> ShowS
[ElasticsearchSettings] -> ShowS
ElasticsearchSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElasticsearchSettings] -> ShowS
$cshowList :: [ElasticsearchSettings] -> ShowS
show :: ElasticsearchSettings -> String
$cshow :: ElasticsearchSettings -> String
showsPrec :: Int -> ElasticsearchSettings -> ShowS
$cshowsPrec :: Int -> ElasticsearchSettings -> ShowS
Prelude.Show, forall x. Rep ElasticsearchSettings x -> ElasticsearchSettings
forall x. ElasticsearchSettings -> Rep ElasticsearchSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ElasticsearchSettings x -> ElasticsearchSettings
$cfrom :: forall x. ElasticsearchSettings -> Rep ElasticsearchSettings x
Prelude.Generic)

-- |
-- Create a value of 'ElasticsearchSettings' 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:
--
-- 'errorRetryDuration', 'elasticsearchSettings_errorRetryDuration' - The maximum number of seconds for which DMS retries failed API requests
-- to the OpenSearch cluster.
--
-- 'fullLoadErrorPercentage', 'elasticsearchSettings_fullLoadErrorPercentage' - The maximum percentage of records that can fail to be written before a
-- full load operation stops.
--
-- To avoid early failure, this counter is only effective after 1000
-- records are transferred. OpenSearch also has the concept of error
-- monitoring during the last 10 minutes of an Observation Window. If
-- transfer of all records fail in the last 10 minutes, the full load
-- operation stops.
--
-- 'useNewMappingType', 'elasticsearchSettings_useNewMappingType' - Set this option to @true@ for DMS to migrate documentation using the
-- documentation type @_doc@. OpenSearch and an Elasticsearch cluster only
-- support the _doc documentation type in versions 7. x and later. The
-- default value is @false@.
--
-- 'serviceAccessRoleArn', 'elasticsearchSettings_serviceAccessRoleArn' - The Amazon Resource Name (ARN) used by the service to access the IAM
-- role. The role must allow the @iam:PassRole@ action.
--
-- 'endpointUri', 'elasticsearchSettings_endpointUri' - The endpoint for the OpenSearch cluster. DMS uses HTTPS if a transport
-- protocol (http\/https) is not specified.
newElasticsearchSettings ::
  -- | 'serviceAccessRoleArn'
  Prelude.Text ->
  -- | 'endpointUri'
  Prelude.Text ->
  ElasticsearchSettings
newElasticsearchSettings :: Text -> Text -> ElasticsearchSettings
newElasticsearchSettings
  Text
pServiceAccessRoleArn_
  Text
pEndpointUri_ =
    ElasticsearchSettings'
      { $sel:errorRetryDuration:ElasticsearchSettings' :: Maybe Int
errorRetryDuration =
          forall a. Maybe a
Prelude.Nothing,
        $sel:fullLoadErrorPercentage:ElasticsearchSettings' :: Maybe Int
fullLoadErrorPercentage = forall a. Maybe a
Prelude.Nothing,
        $sel:useNewMappingType:ElasticsearchSettings' :: Maybe Bool
useNewMappingType = forall a. Maybe a
Prelude.Nothing,
        $sel:serviceAccessRoleArn:ElasticsearchSettings' :: Text
serviceAccessRoleArn = Text
pServiceAccessRoleArn_,
        $sel:endpointUri:ElasticsearchSettings' :: Text
endpointUri = Text
pEndpointUri_
      }

-- | The maximum number of seconds for which DMS retries failed API requests
-- to the OpenSearch cluster.
elasticsearchSettings_errorRetryDuration :: Lens.Lens' ElasticsearchSettings (Prelude.Maybe Prelude.Int)
elasticsearchSettings_errorRetryDuration :: Lens' ElasticsearchSettings (Maybe Int)
elasticsearchSettings_errorRetryDuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchSettings' {Maybe Int
errorRetryDuration :: Maybe Int
$sel:errorRetryDuration:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
errorRetryDuration} -> Maybe Int
errorRetryDuration) (\s :: ElasticsearchSettings
s@ElasticsearchSettings' {} Maybe Int
a -> ElasticsearchSettings
s {$sel:errorRetryDuration:ElasticsearchSettings' :: Maybe Int
errorRetryDuration = Maybe Int
a} :: ElasticsearchSettings)

-- | The maximum percentage of records that can fail to be written before a
-- full load operation stops.
--
-- To avoid early failure, this counter is only effective after 1000
-- records are transferred. OpenSearch also has the concept of error
-- monitoring during the last 10 minutes of an Observation Window. If
-- transfer of all records fail in the last 10 minutes, the full load
-- operation stops.
elasticsearchSettings_fullLoadErrorPercentage :: Lens.Lens' ElasticsearchSettings (Prelude.Maybe Prelude.Int)
elasticsearchSettings_fullLoadErrorPercentage :: Lens' ElasticsearchSettings (Maybe Int)
elasticsearchSettings_fullLoadErrorPercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchSettings' {Maybe Int
fullLoadErrorPercentage :: Maybe Int
$sel:fullLoadErrorPercentage:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
fullLoadErrorPercentage} -> Maybe Int
fullLoadErrorPercentage) (\s :: ElasticsearchSettings
s@ElasticsearchSettings' {} Maybe Int
a -> ElasticsearchSettings
s {$sel:fullLoadErrorPercentage:ElasticsearchSettings' :: Maybe Int
fullLoadErrorPercentage = Maybe Int
a} :: ElasticsearchSettings)

-- | Set this option to @true@ for DMS to migrate documentation using the
-- documentation type @_doc@. OpenSearch and an Elasticsearch cluster only
-- support the _doc documentation type in versions 7. x and later. The
-- default value is @false@.
elasticsearchSettings_useNewMappingType :: Lens.Lens' ElasticsearchSettings (Prelude.Maybe Prelude.Bool)
elasticsearchSettings_useNewMappingType :: Lens' ElasticsearchSettings (Maybe Bool)
elasticsearchSettings_useNewMappingType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchSettings' {Maybe Bool
useNewMappingType :: Maybe Bool
$sel:useNewMappingType:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Bool
useNewMappingType} -> Maybe Bool
useNewMappingType) (\s :: ElasticsearchSettings
s@ElasticsearchSettings' {} Maybe Bool
a -> ElasticsearchSettings
s {$sel:useNewMappingType:ElasticsearchSettings' :: Maybe Bool
useNewMappingType = Maybe Bool
a} :: ElasticsearchSettings)

-- | The Amazon Resource Name (ARN) used by the service to access the IAM
-- role. The role must allow the @iam:PassRole@ action.
elasticsearchSettings_serviceAccessRoleArn :: Lens.Lens' ElasticsearchSettings Prelude.Text
elasticsearchSettings_serviceAccessRoleArn :: Lens' ElasticsearchSettings Text
elasticsearchSettings_serviceAccessRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchSettings' {Text
serviceAccessRoleArn :: Text
$sel:serviceAccessRoleArn:ElasticsearchSettings' :: ElasticsearchSettings -> Text
serviceAccessRoleArn} -> Text
serviceAccessRoleArn) (\s :: ElasticsearchSettings
s@ElasticsearchSettings' {} Text
a -> ElasticsearchSettings
s {$sel:serviceAccessRoleArn:ElasticsearchSettings' :: Text
serviceAccessRoleArn = Text
a} :: ElasticsearchSettings)

-- | The endpoint for the OpenSearch cluster. DMS uses HTTPS if a transport
-- protocol (http\/https) is not specified.
elasticsearchSettings_endpointUri :: Lens.Lens' ElasticsearchSettings Prelude.Text
elasticsearchSettings_endpointUri :: Lens' ElasticsearchSettings Text
elasticsearchSettings_endpointUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticsearchSettings' {Text
endpointUri :: Text
$sel:endpointUri:ElasticsearchSettings' :: ElasticsearchSettings -> Text
endpointUri} -> Text
endpointUri) (\s :: ElasticsearchSettings
s@ElasticsearchSettings' {} Text
a -> ElasticsearchSettings
s {$sel:endpointUri:ElasticsearchSettings' :: Text
endpointUri = Text
a} :: ElasticsearchSettings)

instance Data.FromJSON ElasticsearchSettings where
  parseJSON :: Value -> Parser ElasticsearchSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ElasticsearchSettings"
      ( \Object
x ->
          Maybe Int
-> Maybe Int -> Maybe Bool -> Text -> Text -> ElasticsearchSettings
ElasticsearchSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ErrorRetryDuration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FullLoadErrorPercentage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"UseNewMappingType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ServiceAccessRoleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EndpointUri")
      )

instance Prelude.Hashable ElasticsearchSettings where
  hashWithSalt :: Int -> ElasticsearchSettings -> Int
hashWithSalt Int
_salt ElasticsearchSettings' {Maybe Bool
Maybe Int
Text
endpointUri :: Text
serviceAccessRoleArn :: Text
useNewMappingType :: Maybe Bool
fullLoadErrorPercentage :: Maybe Int
errorRetryDuration :: Maybe Int
$sel:endpointUri:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:serviceAccessRoleArn:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:useNewMappingType:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Bool
$sel:fullLoadErrorPercentage:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
$sel:errorRetryDuration:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
errorRetryDuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
fullLoadErrorPercentage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useNewMappingType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceAccessRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
endpointUri

instance Prelude.NFData ElasticsearchSettings where
  rnf :: ElasticsearchSettings -> ()
rnf ElasticsearchSettings' {Maybe Bool
Maybe Int
Text
endpointUri :: Text
serviceAccessRoleArn :: Text
useNewMappingType :: Maybe Bool
fullLoadErrorPercentage :: Maybe Int
errorRetryDuration :: Maybe Int
$sel:endpointUri:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:serviceAccessRoleArn:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:useNewMappingType:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Bool
$sel:fullLoadErrorPercentage:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
$sel:errorRetryDuration:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
errorRetryDuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
fullLoadErrorPercentage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
useNewMappingType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serviceAccessRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
endpointUri

instance Data.ToJSON ElasticsearchSettings where
  toJSON :: ElasticsearchSettings -> Value
toJSON ElasticsearchSettings' {Maybe Bool
Maybe Int
Text
endpointUri :: Text
serviceAccessRoleArn :: Text
useNewMappingType :: Maybe Bool
fullLoadErrorPercentage :: Maybe Int
errorRetryDuration :: Maybe Int
$sel:endpointUri:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:serviceAccessRoleArn:ElasticsearchSettings' :: ElasticsearchSettings -> Text
$sel:useNewMappingType:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Bool
$sel:fullLoadErrorPercentage:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
$sel:errorRetryDuration:ElasticsearchSettings' :: ElasticsearchSettings -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ErrorRetryDuration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
errorRetryDuration,
            (Key
"FullLoadErrorPercentage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
fullLoadErrorPercentage,
            (Key
"UseNewMappingType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useNewMappingType,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ServiceAccessRoleArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serviceAccessRoleArn
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"EndpointUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
endpointUri)
          ]
      )