{-# 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.RDS.Types.Endpoint
-- 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.RDS.Types.Endpoint 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

-- | This data type represents the information you need to connect to an
-- Amazon RDS DB instance. This data type is used as a response element in
-- the following actions:
--
-- -   @CreateDBInstance@
--
-- -   @DescribeDBInstances@
--
-- -   @DeleteDBInstance@
--
-- For the data structure that represents Amazon Aurora DB cluster
-- endpoints, see @DBClusterEndpoint@.
--
-- /See:/ 'newEndpoint' smart constructor.
data Endpoint = Endpoint'
  { -- | Specifies the DNS address of the DB instance.
    Endpoint -> Maybe Text
address :: Prelude.Maybe Prelude.Text,
    -- | Specifies the ID that Amazon Route 53 assigns when you create a hosted
    -- zone.
    Endpoint -> Maybe Text
hostedZoneId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the port that the database engine is listening on.
    Endpoint -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (Endpoint -> Endpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Endpoint -> Endpoint -> Bool
$c/= :: Endpoint -> Endpoint -> Bool
== :: Endpoint -> Endpoint -> Bool
$c== :: Endpoint -> Endpoint -> Bool
Prelude.Eq, ReadPrec [Endpoint]
ReadPrec Endpoint
Int -> ReadS Endpoint
ReadS [Endpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Endpoint]
$creadListPrec :: ReadPrec [Endpoint]
readPrec :: ReadPrec Endpoint
$creadPrec :: ReadPrec Endpoint
readList :: ReadS [Endpoint]
$creadList :: ReadS [Endpoint]
readsPrec :: Int -> ReadS Endpoint
$creadsPrec :: Int -> ReadS Endpoint
Prelude.Read, Int -> Endpoint -> ShowS
[Endpoint] -> ShowS
Endpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Endpoint] -> ShowS
$cshowList :: [Endpoint] -> ShowS
show :: Endpoint -> String
$cshow :: Endpoint -> String
showsPrec :: Int -> Endpoint -> ShowS
$cshowsPrec :: Int -> Endpoint -> ShowS
Prelude.Show, forall x. Rep Endpoint x -> Endpoint
forall x. Endpoint -> Rep Endpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Endpoint x -> Endpoint
$cfrom :: forall x. Endpoint -> Rep Endpoint x
Prelude.Generic)

-- |
-- Create a value of 'Endpoint' 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:
--
-- 'address', 'endpoint_address' - Specifies the DNS address of the DB instance.
--
-- 'hostedZoneId', 'endpoint_hostedZoneId' - Specifies the ID that Amazon Route 53 assigns when you create a hosted
-- zone.
--
-- 'port', 'endpoint_port' - Specifies the port that the database engine is listening on.
newEndpoint ::
  Endpoint
newEndpoint :: Endpoint
newEndpoint =
  Endpoint'
    { $sel:address:Endpoint' :: Maybe Text
address = forall a. Maybe a
Prelude.Nothing,
      $sel:hostedZoneId:Endpoint' :: Maybe Text
hostedZoneId = forall a. Maybe a
Prelude.Nothing,
      $sel:port:Endpoint' :: Maybe Int
port = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the DNS address of the DB instance.
endpoint_address :: Lens.Lens' Endpoint (Prelude.Maybe Prelude.Text)
endpoint_address :: Lens' Endpoint (Maybe Text)
endpoint_address = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Endpoint' {Maybe Text
address :: Maybe Text
$sel:address:Endpoint' :: Endpoint -> Maybe Text
address} -> Maybe Text
address) (\s :: Endpoint
s@Endpoint' {} Maybe Text
a -> Endpoint
s {$sel:address:Endpoint' :: Maybe Text
address = Maybe Text
a} :: Endpoint)

-- | Specifies the ID that Amazon Route 53 assigns when you create a hosted
-- zone.
endpoint_hostedZoneId :: Lens.Lens' Endpoint (Prelude.Maybe Prelude.Text)
endpoint_hostedZoneId :: Lens' Endpoint (Maybe Text)
endpoint_hostedZoneId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Endpoint' {Maybe Text
hostedZoneId :: Maybe Text
$sel:hostedZoneId:Endpoint' :: Endpoint -> Maybe Text
hostedZoneId} -> Maybe Text
hostedZoneId) (\s :: Endpoint
s@Endpoint' {} Maybe Text
a -> Endpoint
s {$sel:hostedZoneId:Endpoint' :: Maybe Text
hostedZoneId = Maybe Text
a} :: Endpoint)

-- | Specifies the port that the database engine is listening on.
endpoint_port :: Lens.Lens' Endpoint (Prelude.Maybe Prelude.Int)
endpoint_port :: Lens' Endpoint (Maybe Int)
endpoint_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Endpoint' {Maybe Int
port :: Maybe Int
$sel:port:Endpoint' :: Endpoint -> Maybe Int
port} -> Maybe Int
port) (\s :: Endpoint
s@Endpoint' {} Maybe Int
a -> Endpoint
s {$sel:port:Endpoint' :: Maybe Int
port = Maybe Int
a} :: Endpoint)

instance Data.FromXML Endpoint where
  parseXML :: [Node] -> Either String Endpoint
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Int -> Endpoint
Endpoint'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Address")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HostedZoneId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Port")

instance Prelude.Hashable Endpoint where
  hashWithSalt :: Int -> Endpoint -> Int
hashWithSalt Int
_salt Endpoint' {Maybe Int
Maybe Text
port :: Maybe Int
hostedZoneId :: Maybe Text
address :: Maybe Text
$sel:port:Endpoint' :: Endpoint -> Maybe Int
$sel:hostedZoneId:Endpoint' :: Endpoint -> Maybe Text
$sel:address:Endpoint' :: Endpoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
address
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hostedZoneId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
port

instance Prelude.NFData Endpoint where
  rnf :: Endpoint -> ()
rnf Endpoint' {Maybe Int
Maybe Text
port :: Maybe Int
hostedZoneId :: Maybe Text
address :: Maybe Text
$sel:port:Endpoint' :: Endpoint -> Maybe Int
$sel:hostedZoneId:Endpoint' :: Endpoint -> Maybe Text
$sel:address:Endpoint' :: Endpoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
address
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hostedZoneId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
port