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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.TLSSecurityPolicy
import qualified Amazonka.Prelude as Prelude

-- | Options to configure the endpoint for the domain.
--
-- /See:/ 'newDomainEndpointOptions' smart constructor.
data DomainEndpointOptions = DomainEndpointOptions'
  { -- | Whether only HTTPS endpoint should be enabled for the domain.
    DomainEndpointOptions -> Maybe Bool
enforceHTTPS :: Prelude.Maybe Prelude.Bool,
    -- | Specify the TLS security policy to apply to the HTTPS endpoint of the
    -- domain.
    -- 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,
    -- | Whether to enable a custom endpoint for the domain.
    DomainEndpointOptions -> Maybe Bool
customEndpointEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The fully qualified domain for your custom endpoint.
    DomainEndpointOptions -> Maybe Text
customEndpoint :: Prelude.Maybe Prelude.Text,
    -- | The ACM certificate ARN for your custom endpoint.
    DomainEndpointOptions -> Maybe Text
customEndpointCertificateArn :: Prelude.Maybe Prelude.Text
  }
  deriving (DomainEndpointOptions -> DomainEndpointOptions -> Bool
(DomainEndpointOptions -> DomainEndpointOptions -> Bool)
-> (DomainEndpointOptions -> DomainEndpointOptions -> Bool)
-> Eq DomainEndpointOptions
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]
(Int -> ReadS DomainEndpointOptions)
-> ReadS [DomainEndpointOptions]
-> ReadPrec DomainEndpointOptions
-> ReadPrec [DomainEndpointOptions]
-> Read 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
(Int -> DomainEndpointOptions -> ShowS)
-> (DomainEndpointOptions -> String)
-> ([DomainEndpointOptions] -> ShowS)
-> Show DomainEndpointOptions
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. DomainEndpointOptions -> Rep DomainEndpointOptions x)
-> (forall x. Rep DomainEndpointOptions x -> DomainEndpointOptions)
-> Generic DomainEndpointOptions
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:
--
-- 'enforceHTTPS', 'domainEndpointOptions_enforceHTTPS' - Whether only HTTPS endpoint should be enabled for the domain.
--
-- 'tLSSecurityPolicy', 'domainEndpointOptions_tLSSecurityPolicy' - Specify the TLS security policy to apply to the HTTPS endpoint of the
-- domain.
-- 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
--
-- 'customEndpointEnabled', 'domainEndpointOptions_customEndpointEnabled' - Whether to enable a custom endpoint for the domain.
--
-- 'customEndpoint', 'domainEndpointOptions_customEndpoint' - The fully qualified domain for your custom endpoint.
--
-- 'customEndpointCertificateArn', 'domainEndpointOptions_customEndpointCertificateArn' - The ACM certificate ARN for your custom endpoint.
newDomainEndpointOptions ::
  DomainEndpointOptions
newDomainEndpointOptions :: DomainEndpointOptions
newDomainEndpointOptions =
  DomainEndpointOptions' :: Maybe Bool
-> Maybe TLSSecurityPolicy
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> DomainEndpointOptions
DomainEndpointOptions'
    { $sel:enforceHTTPS:DomainEndpointOptions' :: Maybe Bool
enforceHTTPS =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:tLSSecurityPolicy:DomainEndpointOptions' :: Maybe TLSSecurityPolicy
tLSSecurityPolicy = Maybe TLSSecurityPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:customEndpointEnabled:DomainEndpointOptions' :: Maybe Bool
customEndpointEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:customEndpoint:DomainEndpointOptions' :: Maybe Text
customEndpoint = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:customEndpointCertificateArn:DomainEndpointOptions' :: Maybe Text
customEndpointCertificateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether only HTTPS endpoint should be enabled for the domain.
domainEndpointOptions_enforceHTTPS :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Bool)
domainEndpointOptions_enforceHTTPS :: (Maybe Bool -> f (Maybe Bool))
-> DomainEndpointOptions -> f DomainEndpointOptions
domainEndpointOptions_enforceHTTPS = (DomainEndpointOptions -> Maybe Bool)
-> (DomainEndpointOptions -> Maybe Bool -> DomainEndpointOptions)
-> Lens
     DomainEndpointOptions
     DomainEndpointOptions
     (Maybe Bool)
     (Maybe Bool)
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 to apply to the HTTPS endpoint of the
-- domain.
-- 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 :: (Maybe TLSSecurityPolicy -> f (Maybe TLSSecurityPolicy))
-> DomainEndpointOptions -> f DomainEndpointOptions
domainEndpointOptions_tLSSecurityPolicy = (DomainEndpointOptions -> Maybe TLSSecurityPolicy)
-> (DomainEndpointOptions
    -> Maybe TLSSecurityPolicy -> DomainEndpointOptions)
-> Lens
     DomainEndpointOptions
     DomainEndpointOptions
     (Maybe TLSSecurityPolicy)
     (Maybe 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)

-- | Whether to enable a custom endpoint for the domain.
domainEndpointOptions_customEndpointEnabled :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Bool)
domainEndpointOptions_customEndpointEnabled :: (Maybe Bool -> f (Maybe Bool))
-> DomainEndpointOptions -> f DomainEndpointOptions
domainEndpointOptions_customEndpointEnabled = (DomainEndpointOptions -> Maybe Bool)
-> (DomainEndpointOptions -> Maybe Bool -> DomainEndpointOptions)
-> Lens
     DomainEndpointOptions
     DomainEndpointOptions
     (Maybe Bool)
     (Maybe Bool)
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)

-- | The fully qualified domain for your custom endpoint.
domainEndpointOptions_customEndpoint :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Text)
domainEndpointOptions_customEndpoint :: (Maybe Text -> f (Maybe Text))
-> DomainEndpointOptions -> f DomainEndpointOptions
domainEndpointOptions_customEndpoint = (DomainEndpointOptions -> Maybe Text)
-> (DomainEndpointOptions -> Maybe Text -> DomainEndpointOptions)
-> Lens
     DomainEndpointOptions
     DomainEndpointOptions
     (Maybe Text)
     (Maybe Text)
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)

-- | The ACM certificate ARN for your custom endpoint.
domainEndpointOptions_customEndpointCertificateArn :: Lens.Lens' DomainEndpointOptions (Prelude.Maybe Prelude.Text)
domainEndpointOptions_customEndpointCertificateArn :: (Maybe Text -> f (Maybe Text))
-> DomainEndpointOptions -> f DomainEndpointOptions
domainEndpointOptions_customEndpointCertificateArn = (DomainEndpointOptions -> Maybe Text)
-> (DomainEndpointOptions -> Maybe Text -> DomainEndpointOptions)
-> Lens
     DomainEndpointOptions
     DomainEndpointOptions
     (Maybe Text)
     (Maybe Text)
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)

instance Core.FromJSON DomainEndpointOptions where
  parseJSON :: Value -> Parser DomainEndpointOptions
parseJSON =
    String
-> (Object -> Parser DomainEndpointOptions)
-> Value
-> Parser DomainEndpointOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DomainEndpointOptions"
      ( \Object
x ->
          Maybe Bool
-> Maybe TLSSecurityPolicy
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> DomainEndpointOptions
DomainEndpointOptions'
            (Maybe Bool
 -> Maybe TLSSecurityPolicy
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> DomainEndpointOptions)
-> Parser (Maybe Bool)
-> Parser
     (Maybe TLSSecurityPolicy
      -> Maybe Bool -> Maybe Text -> Maybe Text -> DomainEndpointOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EnforceHTTPS")
            Parser
  (Maybe TLSSecurityPolicy
   -> Maybe Bool -> Maybe Text -> Maybe Text -> DomainEndpointOptions)
-> Parser (Maybe TLSSecurityPolicy)
-> Parser
     (Maybe Bool -> Maybe Text -> Maybe Text -> DomainEndpointOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TLSSecurityPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TLSSecurityPolicy")
            Parser
  (Maybe Bool -> Maybe Text -> Maybe Text -> DomainEndpointOptions)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Maybe Text -> DomainEndpointOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CustomEndpointEnabled")
            Parser (Maybe Text -> Maybe Text -> DomainEndpointOptions)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> DomainEndpointOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CustomEndpoint")
            Parser (Maybe Text -> DomainEndpointOptions)
-> Parser (Maybe Text) -> Parser DomainEndpointOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CustomEndpointCertificateArn")
      )

instance Prelude.Hashable DomainEndpointOptions

instance Prelude.NFData DomainEndpointOptions

instance Core.ToJSON DomainEndpointOptions where
  toJSON :: DomainEndpointOptions -> Value
toJSON DomainEndpointOptions' {Maybe Bool
Maybe Text
Maybe TLSSecurityPolicy
customEndpointCertificateArn :: Maybe Text
customEndpoint :: Maybe Text
customEndpointEnabled :: Maybe Bool
tLSSecurityPolicy :: Maybe TLSSecurityPolicy
enforceHTTPS :: Maybe Bool
$sel:customEndpointCertificateArn:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
$sel:customEndpoint:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Text
$sel:customEndpointEnabled:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
$sel:tLSSecurityPolicy:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe TLSSecurityPolicy
$sel:enforceHTTPS:DomainEndpointOptions' :: DomainEndpointOptions -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EnforceHTTPS" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enforceHTTPS,
            (Text
"TLSSecurityPolicy" Text -> TLSSecurityPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TLSSecurityPolicy -> Pair)
-> Maybe TLSSecurityPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TLSSecurityPolicy
tLSSecurityPolicy,
            (Text
"CustomEndpointEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
customEndpointEnabled,
            (Text
"CustomEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
customEndpoint,
            (Text
"CustomEndpointCertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
customEndpointCertificateArn
          ]
      )