{-# 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.MigrationHubReFactorSpaces.Types.UrlEndpointInput
-- 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.MigrationHubReFactorSpaces.Types.UrlEndpointInput 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

-- | The configuration for the URL endpoint type.
--
-- /See:/ 'newUrlEndpointInput' smart constructor.
data UrlEndpointInput = UrlEndpointInput'
  { -- | The health check URL of the URL endpoint type. If the URL is a public
    -- endpoint, the @HealthUrl@ must also be a public endpoint. If the URL is
    -- a private endpoint inside a virtual private cloud (VPC), the health URL
    -- must also be a private endpoint, and the host must be the same as the
    -- URL.
    UrlEndpointInput -> Maybe Text
healthUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL to route traffic to. The URL must be an
    -- <https://datatracker.ietf.org/doc/html/rfc3986 rfc3986-formatted URL>.
    -- If the host is a domain name, the name must be resolvable over the
    -- public internet. If the scheme is @https@, the top level domain of the
    -- host must be listed in the
    -- <https://www.iana.org/domains/root/db IANA root zone database>.
    UrlEndpointInput -> Text
url :: Prelude.Text
  }
  deriving (UrlEndpointInput -> UrlEndpointInput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UrlEndpointInput -> UrlEndpointInput -> Bool
$c/= :: UrlEndpointInput -> UrlEndpointInput -> Bool
== :: UrlEndpointInput -> UrlEndpointInput -> Bool
$c== :: UrlEndpointInput -> UrlEndpointInput -> Bool
Prelude.Eq, ReadPrec [UrlEndpointInput]
ReadPrec UrlEndpointInput
Int -> ReadS UrlEndpointInput
ReadS [UrlEndpointInput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UrlEndpointInput]
$creadListPrec :: ReadPrec [UrlEndpointInput]
readPrec :: ReadPrec UrlEndpointInput
$creadPrec :: ReadPrec UrlEndpointInput
readList :: ReadS [UrlEndpointInput]
$creadList :: ReadS [UrlEndpointInput]
readsPrec :: Int -> ReadS UrlEndpointInput
$creadsPrec :: Int -> ReadS UrlEndpointInput
Prelude.Read, Int -> UrlEndpointInput -> ShowS
[UrlEndpointInput] -> ShowS
UrlEndpointInput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UrlEndpointInput] -> ShowS
$cshowList :: [UrlEndpointInput] -> ShowS
show :: UrlEndpointInput -> String
$cshow :: UrlEndpointInput -> String
showsPrec :: Int -> UrlEndpointInput -> ShowS
$cshowsPrec :: Int -> UrlEndpointInput -> ShowS
Prelude.Show, forall x. Rep UrlEndpointInput x -> UrlEndpointInput
forall x. UrlEndpointInput -> Rep UrlEndpointInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UrlEndpointInput x -> UrlEndpointInput
$cfrom :: forall x. UrlEndpointInput -> Rep UrlEndpointInput x
Prelude.Generic)

-- |
-- Create a value of 'UrlEndpointInput' 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:
--
-- 'healthUrl', 'urlEndpointInput_healthUrl' - The health check URL of the URL endpoint type. If the URL is a public
-- endpoint, the @HealthUrl@ must also be a public endpoint. If the URL is
-- a private endpoint inside a virtual private cloud (VPC), the health URL
-- must also be a private endpoint, and the host must be the same as the
-- URL.
--
-- 'url', 'urlEndpointInput_url' - The URL to route traffic to. The URL must be an
-- <https://datatracker.ietf.org/doc/html/rfc3986 rfc3986-formatted URL>.
-- If the host is a domain name, the name must be resolvable over the
-- public internet. If the scheme is @https@, the top level domain of the
-- host must be listed in the
-- <https://www.iana.org/domains/root/db IANA root zone database>.
newUrlEndpointInput ::
  -- | 'url'
  Prelude.Text ->
  UrlEndpointInput
newUrlEndpointInput :: Text -> UrlEndpointInput
newUrlEndpointInput Text
pUrl_ =
  UrlEndpointInput'
    { $sel:healthUrl:UrlEndpointInput' :: Maybe Text
healthUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:url:UrlEndpointInput' :: Text
url = Text
pUrl_
    }

-- | The health check URL of the URL endpoint type. If the URL is a public
-- endpoint, the @HealthUrl@ must also be a public endpoint. If the URL is
-- a private endpoint inside a virtual private cloud (VPC), the health URL
-- must also be a private endpoint, and the host must be the same as the
-- URL.
urlEndpointInput_healthUrl :: Lens.Lens' UrlEndpointInput (Prelude.Maybe Prelude.Text)
urlEndpointInput_healthUrl :: Lens' UrlEndpointInput (Maybe Text)
urlEndpointInput_healthUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UrlEndpointInput' {Maybe Text
healthUrl :: Maybe Text
$sel:healthUrl:UrlEndpointInput' :: UrlEndpointInput -> Maybe Text
healthUrl} -> Maybe Text
healthUrl) (\s :: UrlEndpointInput
s@UrlEndpointInput' {} Maybe Text
a -> UrlEndpointInput
s {$sel:healthUrl:UrlEndpointInput' :: Maybe Text
healthUrl = Maybe Text
a} :: UrlEndpointInput)

-- | The URL to route traffic to. The URL must be an
-- <https://datatracker.ietf.org/doc/html/rfc3986 rfc3986-formatted URL>.
-- If the host is a domain name, the name must be resolvable over the
-- public internet. If the scheme is @https@, the top level domain of the
-- host must be listed in the
-- <https://www.iana.org/domains/root/db IANA root zone database>.
urlEndpointInput_url :: Lens.Lens' UrlEndpointInput Prelude.Text
urlEndpointInput_url :: Lens' UrlEndpointInput Text
urlEndpointInput_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UrlEndpointInput' {Text
url :: Text
$sel:url:UrlEndpointInput' :: UrlEndpointInput -> Text
url} -> Text
url) (\s :: UrlEndpointInput
s@UrlEndpointInput' {} Text
a -> UrlEndpointInput
s {$sel:url:UrlEndpointInput' :: Text
url = Text
a} :: UrlEndpointInput)

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

instance Prelude.Hashable UrlEndpointInput where
  hashWithSalt :: Int -> UrlEndpointInput -> Int
hashWithSalt Int
_salt UrlEndpointInput' {Maybe Text
Text
url :: Text
healthUrl :: Maybe Text
$sel:url:UrlEndpointInput' :: UrlEndpointInput -> Text
$sel:healthUrl:UrlEndpointInput' :: UrlEndpointInput -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
healthUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
url

instance Prelude.NFData UrlEndpointInput where
  rnf :: UrlEndpointInput -> ()
rnf UrlEndpointInput' {Maybe Text
Text
url :: Text
healthUrl :: Maybe Text
$sel:url:UrlEndpointInput' :: UrlEndpointInput -> Text
$sel:healthUrl:UrlEndpointInput' :: UrlEndpointInput -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
healthUrl seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
url

instance Data.ToJSON UrlEndpointInput where
  toJSON :: UrlEndpointInput -> Value
toJSON UrlEndpointInput' {Maybe Text
Text
url :: Text
healthUrl :: Maybe Text
$sel:url:UrlEndpointInput' :: UrlEndpointInput -> Text
$sel:healthUrl:UrlEndpointInput' :: UrlEndpointInput -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"HealthUrl" 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
healthUrl,
            forall a. a -> Maybe a
Prelude.Just (Key
"Url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
url)
          ]
      )