{-# 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.ElasticSearch.Types.DomainEndpointOptions
-- 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.ElasticSearch.Types.DomainEndpointOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticSearch.Types.TLSSecurityPolicy
import qualified Amazonka.Prelude as Prelude

-- | Options to configure endpoint for the Elasticsearch domain.
--
-- /See:/ 'newDomainEndpointOptions' smart constructor.
data DomainEndpointOptions = DomainEndpointOptions'
  { -- | Specify the fully qualified domain for your custom endpoint.
    DomainEndpointOptions -> Maybe Text
customEndpoint :: Prelude.Maybe Prelude.Text,
    -- | Specify ACM certificate ARN for your custom endpoint.
    DomainEndpointOptions -> Maybe Text
customEndpointCertificateArn :: Prelude.Maybe Prelude.Text,
    -- | Specify if custom endpoint should be enabled for the Elasticsearch
    -- domain.
    DomainEndpointOptions -> Maybe Bool
customEndpointEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Specify if only HTTPS endpoint should be enabled for the Elasticsearch
    -- domain.
    DomainEndpointOptions -> Maybe Bool
enforceHTTPS :: Prelude.Maybe Prelude.Bool,
    -- | Specify the TLS security policy that needs to be applied to the HTTPS
    -- endpoint of Elasticsearch domain.
    -- It can be one of the following values:
    --
    -- -   __Policy-Min-TLS-1-0-2019-07:__ TLS security policy which supports
    --     TLSv1.0 and higher.
    -- -   __Policy-Min-TLS-1-2-2019-07:__ TLS security policy which supports
    --     only TLSv1.2
    DomainEndpointOptions -> Maybe TLSSecurityPolicy
tLSSecurityPolicy :: Prelude.Maybe TLSSecurityPolicy
  }
  deriving (DomainEndpointOptions -> DomainEndpointOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DomainEndpointOptions -> DomainEndpointOptions -> Bool
$c/= :: DomainEndpointOptions -> DomainEndpointOptions -> Bool
== :: DomainEndpointOptions -> DomainEndpointOptions -> Bool
$c== :: DomainEndpointOptions -> DomainEndpointOptions -> Bool
Prelude.Eq, ReadPrec [DomainEndpointOptions]
ReadPrec DomainEndpointOptions
Int -> ReadS DomainEndpointOptions
ReadS [DomainEndpointOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DomainEndpointOptions]
$creadListPrec :: ReadPrec [DomainEndpointOptions]
readPrec :: ReadPrec DomainEndpointOptions
$creadPrec :: ReadPrec DomainEndpointOptions
readList :: ReadS [DomainEndpointOptions]
$creadList :: ReadS [DomainEndpointOptions]
readsPrec :: Int -> ReadS DomainEndpointOptions
$creadsPrec :: Int -> ReadS DomainEndpointOptions
Prelude.Read, Int -> DomainEndpointOptions -> ShowS
[DomainEndpointOptions] -> ShowS
DomainEndpointOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DomainEndpointOptions] -> ShowS
$cshowList :: [DomainEndpointOptions] -> ShowS
show :: DomainEndpointOptions -> String
$cshow :: DomainEndpointOptions -> String
showsPrec :: Int -> DomainEndpointOptions -> ShowS
$cshowsPrec :: Int -> DomainEndpointOptions -> ShowS
Prelude.Show, forall x. Rep DomainEndpointOptions x -> DomainEndpointOptions
forall x. DomainEndpointOptions -> Rep DomainEndpointOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DomainEndpointOptions x -> DomainEndpointOptions
$cfrom :: forall x. DomainEndpointOptions -> Rep DomainEndpointOptions x
Prelude.Generic)

-- |
-- Create a value of 'DomainEndpointOptions' 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:
--
-- 'customEndpoint', 'domainEndpointOptions_customEndpoint' - Specify the fully qualified domain for your custom endpoint.
--
-- 'customEndpointCertificateArn', 'domainEndpointOptions_customEndpointCertificateArn' - Specify ACM certificate ARN for your custom endpoint.
--
-- 'customEndpointEnabled', 'domainEndpointOptions_customEndpointEnabled' - Specify if custom endpoint should be enabled for the Elasticsearch
-- domain.
--
-- 'enforceHTTPS', 'domainEndpointOptions_enforceHTTPS' - Specify if only HTTPS endpoint should be enabled for the Elasticsearch
-- domain.
--
-- 'tLSSecurityPolicy', 'domainEndpointOptions_tLSSecurityPolicy' - Specify the TLS security policy that needs to be applied to the HTTPS
-- endpoint of Elasticsearch domain.
-- It can be one of the following values:
--
-- -   __Policy-Min-TLS-1-0-2019-07:__ TLS security policy which supports
--     TLSv1.0 and higher.
-- -   __Policy-Min-TLS-1-2-2019-07:__ TLS security policy which supports
--     only TLSv1.2
newDomainEndpointOptions ::
  DomainEndpointOptions
newDomainEndpointOptions :: DomainEndpointOptions
newDomainEndpointOptions =
  DomainEndpointOptions'
    { $sel:customEndpoint:DomainEndpointOptions' :: Maybe Text
customEndpoint =
        forall a. Maybe a
Prelude.Nothing,
      $sel:customEndpointCertificateArn:DomainEndpointOptions' :: Maybe Text
customEndpointCertificateArn = forall a. Maybe a
Prelude.Nothing,
      $sel:customEndpointEnabled:DomainEndpointOptions' :: Maybe Bool
customEndpointEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:enforceHTTPS:DomainEndpointOptions' :: Maybe Bool
enforceHTTPS = forall a. Maybe a
Prelude.Nothing,
      $sel:tLSSecurityPolicy:DomainEndpointOptions' :: Maybe TLSSecurityPolicy
tLSSecurityPolicy = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the fully qualified domain for your custom endpoint.
domainEndpointOptions_customEndpoint :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Text)
domainEndpointOptions_customEndpoint :: Lens' DomainEndpointOptions (Maybe Text)
domainEndpointOptions_customEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainEndpointOptions' {Maybe Text
customEndpoint :: Maybe Text
$sel:customEndpoint:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
customEndpoint} -> Maybe Text
customEndpoint) (\s :: DomainEndpointOptions
s@DomainEndpointOptions' {} Maybe Text
a -> DomainEndpointOptions
s {$sel:customEndpoint:DomainEndpointOptions' :: Maybe Text
customEndpoint = Maybe Text
a} :: DomainEndpointOptions)

-- | Specify ACM certificate ARN for your custom endpoint.
domainEndpointOptions_customEndpointCertificateArn :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Text)
domainEndpointOptions_customEndpointCertificateArn :: Lens' DomainEndpointOptions (Maybe Text)
domainEndpointOptions_customEndpointCertificateArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainEndpointOptions' {Maybe Text
customEndpointCertificateArn :: Maybe Text
$sel:customEndpointCertificateArn:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
customEndpointCertificateArn} -> Maybe Text
customEndpointCertificateArn) (\s :: DomainEndpointOptions
s@DomainEndpointOptions' {} Maybe Text
a -> DomainEndpointOptions
s {$sel:customEndpointCertificateArn:DomainEndpointOptions' :: Maybe Text
customEndpointCertificateArn = Maybe Text
a} :: DomainEndpointOptions)

-- | Specify if custom endpoint should be enabled for the Elasticsearch
-- domain.
domainEndpointOptions_customEndpointEnabled :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Bool)
domainEndpointOptions_customEndpointEnabled :: Lens' DomainEndpointOptions (Maybe Bool)
domainEndpointOptions_customEndpointEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainEndpointOptions' {Maybe Bool
customEndpointEnabled :: Maybe Bool
$sel:customEndpointEnabled:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
customEndpointEnabled} -> Maybe Bool
customEndpointEnabled) (\s :: DomainEndpointOptions
s@DomainEndpointOptions' {} Maybe Bool
a -> DomainEndpointOptions
s {$sel:customEndpointEnabled:DomainEndpointOptions' :: Maybe Bool
customEndpointEnabled = Maybe Bool
a} :: DomainEndpointOptions)

-- | Specify if only HTTPS endpoint should be enabled for the Elasticsearch
-- domain.
domainEndpointOptions_enforceHTTPS :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Bool)
domainEndpointOptions_enforceHTTPS :: Lens' DomainEndpointOptions (Maybe Bool)
domainEndpointOptions_enforceHTTPS = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainEndpointOptions' {Maybe Bool
enforceHTTPS :: Maybe Bool
$sel:enforceHTTPS:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
enforceHTTPS} -> Maybe Bool
enforceHTTPS) (\s :: DomainEndpointOptions
s@DomainEndpointOptions' {} Maybe Bool
a -> DomainEndpointOptions
s {$sel:enforceHTTPS:DomainEndpointOptions' :: Maybe Bool
enforceHTTPS = Maybe Bool
a} :: DomainEndpointOptions)

-- | Specify the TLS security policy that needs to be applied to the HTTPS
-- endpoint of Elasticsearch domain.
-- It can be one of the following values:
--
-- -   __Policy-Min-TLS-1-0-2019-07:__ TLS security policy which supports
--     TLSv1.0 and higher.
-- -   __Policy-Min-TLS-1-2-2019-07:__ TLS security policy which supports
--     only TLSv1.2
domainEndpointOptions_tLSSecurityPolicy :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe TLSSecurityPolicy)
domainEndpointOptions_tLSSecurityPolicy :: Lens' DomainEndpointOptions (Maybe TLSSecurityPolicy)
domainEndpointOptions_tLSSecurityPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainEndpointOptions' {Maybe TLSSecurityPolicy
tLSSecurityPolicy :: Maybe TLSSecurityPolicy
$sel:tLSSecurityPolicy:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe TLSSecurityPolicy
tLSSecurityPolicy} -> Maybe TLSSecurityPolicy
tLSSecurityPolicy) (\s :: DomainEndpointOptions
s@DomainEndpointOptions' {} Maybe TLSSecurityPolicy
a -> DomainEndpointOptions
s {$sel:tLSSecurityPolicy:DomainEndpointOptions' :: Maybe TLSSecurityPolicy
tLSSecurityPolicy = Maybe TLSSecurityPolicy
a} :: DomainEndpointOptions)

instance Data.FromJSON DomainEndpointOptions where
  parseJSON :: Value -> Parser DomainEndpointOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DomainEndpointOptions"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe TLSSecurityPolicy
-> DomainEndpointOptions
DomainEndpointOptions'
            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
"CustomEndpoint")
            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
"CustomEndpointCertificateArn")
            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
"CustomEndpointEnabled")
            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
"EnforceHTTPS")
            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
"TLSSecurityPolicy")
      )

instance Prelude.Hashable DomainEndpointOptions where
  hashWithSalt :: Int -> DomainEndpointOptions -> Int
hashWithSalt Int
_salt DomainEndpointOptions' {Maybe Bool
Maybe Text
Maybe TLSSecurityPolicy
tLSSecurityPolicy :: Maybe TLSSecurityPolicy
enforceHTTPS :: Maybe Bool
customEndpointEnabled :: Maybe Bool
customEndpointCertificateArn :: Maybe Text
customEndpoint :: Maybe Text
$sel:tLSSecurityPolicy:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe TLSSecurityPolicy
$sel:enforceHTTPS:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointEnabled:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointCertificateArn:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
$sel:customEndpoint:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
customEndpointCertificateArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
customEndpointEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enforceHTTPS
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TLSSecurityPolicy
tLSSecurityPolicy

instance Prelude.NFData DomainEndpointOptions where
  rnf :: DomainEndpointOptions -> ()
rnf DomainEndpointOptions' {Maybe Bool
Maybe Text
Maybe TLSSecurityPolicy
tLSSecurityPolicy :: Maybe TLSSecurityPolicy
enforceHTTPS :: Maybe Bool
customEndpointEnabled :: Maybe Bool
customEndpointCertificateArn :: Maybe Text
customEndpoint :: Maybe Text
$sel:tLSSecurityPolicy:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe TLSSecurityPolicy
$sel:enforceHTTPS:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointEnabled:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointCertificateArn:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
$sel:customEndpoint:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
customEndpointCertificateArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
customEndpointEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enforceHTTPS
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TLSSecurityPolicy
tLSSecurityPolicy

instance Data.ToJSON DomainEndpointOptions where
  toJSON :: DomainEndpointOptions -> Value
toJSON DomainEndpointOptions' {Maybe Bool
Maybe Text
Maybe TLSSecurityPolicy
tLSSecurityPolicy :: Maybe TLSSecurityPolicy
enforceHTTPS :: Maybe Bool
customEndpointEnabled :: Maybe Bool
customEndpointCertificateArn :: Maybe Text
customEndpoint :: Maybe Text
$sel:tLSSecurityPolicy:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe TLSSecurityPolicy
$sel:enforceHTTPS:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointEnabled:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:customEndpointCertificateArn:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
$sel:customEndpoint:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CustomEndpoint" 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 Text
customEndpoint,
            (Key
"CustomEndpointCertificateArn" 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 Text
customEndpointCertificateArn,
            (Key
"CustomEndpointEnabled" 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
customEndpointEnabled,
            (Key
"EnforceHTTPS" 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
enforceHTTPS,
            (Key
"TLSSecurityPolicy" 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 TLSSecurityPolicy
tLSSecurityPolicy
          ]
      )