{-# 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-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.DMS.Types.ElasticsearchSettings where

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

-- | Provides information that defines an Elasticsearch endpoint.
--
-- /See:/ 'newElasticsearchSettings' smart constructor.
data ElasticsearchSettings = 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. Elasticsearch 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,
    -- | The maximum number of seconds for which DMS retries failed API requests
    -- to the Elasticsearch cluster.
    ElasticsearchSettings -> Maybe Int
errorRetryDuration :: Prelude.Maybe Prelude.Int,
    -- | 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 Elasticsearch cluster. DMS uses HTTPS if a
    -- transport protocol (http\/https) is not specified.
    ElasticsearchSettings -> Text
endpointUri :: Prelude.Text
  }
  deriving (ElasticsearchSettings -> ElasticsearchSettings -> Bool
(ElasticsearchSettings -> ElasticsearchSettings -> Bool)
-> (ElasticsearchSettings -> ElasticsearchSettings -> Bool)
-> Eq ElasticsearchSettings
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]
(Int -> ReadS ElasticsearchSettings)
-> ReadS [ElasticsearchSettings]
-> ReadPrec ElasticsearchSettings
-> ReadPrec [ElasticsearchSettings]
-> Read 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
(Int -> ElasticsearchSettings -> ShowS)
-> (ElasticsearchSettings -> String)
-> ([ElasticsearchSettings] -> ShowS)
-> Show ElasticsearchSettings
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. ElasticsearchSettings -> Rep ElasticsearchSettings x)
-> (forall x. Rep ElasticsearchSettings x -> ElasticsearchSettings)
-> Generic ElasticsearchSettings
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:
--
-- '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. Elasticsearch 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.
--
-- 'errorRetryDuration', 'elasticsearchSettings_errorRetryDuration' - The maximum number of seconds for which DMS retries failed API requests
-- to the Elasticsearch cluster.
--
-- '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 Elasticsearch 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' :: Maybe Int -> Maybe Int -> Text -> Text -> ElasticsearchSettings
ElasticsearchSettings'
      { $sel:fullLoadErrorPercentage:ElasticsearchSettings' :: Maybe Int
fullLoadErrorPercentage =
          Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:errorRetryDuration:ElasticsearchSettings' :: Maybe Int
errorRetryDuration = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:serviceAccessRoleArn:ElasticsearchSettings' :: Text
serviceAccessRoleArn = Text
pServiceAccessRoleArn_,
        $sel:endpointUri:ElasticsearchSettings' :: Text
endpointUri = Text
pEndpointUri_
      }

-- | 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. Elasticsearch 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 :: (Maybe Int -> f (Maybe Int))
-> ElasticsearchSettings -> f ElasticsearchSettings
elasticsearchSettings_fullLoadErrorPercentage = (ElasticsearchSettings -> Maybe Int)
-> (ElasticsearchSettings -> Maybe Int -> ElasticsearchSettings)
-> Lens
     ElasticsearchSettings ElasticsearchSettings (Maybe Int) (Maybe Int)
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)

-- | The maximum number of seconds for which DMS retries failed API requests
-- to the Elasticsearch cluster.
elasticsearchSettings_errorRetryDuration :: Lens.Lens' ElasticsearchSettings (Prelude.Maybe Prelude.Int)
elasticsearchSettings_errorRetryDuration :: (Maybe Int -> f (Maybe Int))
-> ElasticsearchSettings -> f ElasticsearchSettings
elasticsearchSettings_errorRetryDuration = (ElasticsearchSettings -> Maybe Int)
-> (ElasticsearchSettings -> Maybe Int -> ElasticsearchSettings)
-> Lens
     ElasticsearchSettings ElasticsearchSettings (Maybe Int) (Maybe Int)
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 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 :: (Text -> f Text)
-> ElasticsearchSettings -> f ElasticsearchSettings
elasticsearchSettings_serviceAccessRoleArn = (ElasticsearchSettings -> Text)
-> (ElasticsearchSettings -> Text -> ElasticsearchSettings)
-> Lens ElasticsearchSettings ElasticsearchSettings Text Text
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 Elasticsearch cluster. DMS uses HTTPS if a
-- transport protocol (http\/https) is not specified.
elasticsearchSettings_endpointUri :: Lens.Lens' ElasticsearchSettings Prelude.Text
elasticsearchSettings_endpointUri :: (Text -> f Text)
-> ElasticsearchSettings -> f ElasticsearchSettings
elasticsearchSettings_endpointUri = (ElasticsearchSettings -> Text)
-> (ElasticsearchSettings -> Text -> ElasticsearchSettings)
-> Lens ElasticsearchSettings ElasticsearchSettings Text Text
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 Core.FromJSON ElasticsearchSettings where
  parseJSON :: Value -> Parser ElasticsearchSettings
parseJSON =
    String
-> (Object -> Parser ElasticsearchSettings)
-> Value
-> Parser ElasticsearchSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ElasticsearchSettings"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Text -> Text -> ElasticsearchSettings
ElasticsearchSettings'
            (Maybe Int -> Maybe Int -> Text -> Text -> ElasticsearchSettings)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Text -> Text -> ElasticsearchSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FullLoadErrorPercentage")
            Parser (Maybe Int -> Text -> Text -> ElasticsearchSettings)
-> Parser (Maybe Int)
-> Parser (Text -> Text -> ElasticsearchSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorRetryDuration")
            Parser (Text -> Text -> ElasticsearchSettings)
-> Parser Text -> Parser (Text -> ElasticsearchSettings)
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
"ServiceAccessRoleArn")
            Parser (Text -> ElasticsearchSettings)
-> Parser Text -> Parser ElasticsearchSettings
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
"EndpointUri")
      )

instance Prelude.Hashable ElasticsearchSettings

instance Prelude.NFData ElasticsearchSettings

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