{-# 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.SecurityHub.Types.AwsRdsDbInstanceEndpoint
-- 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.SecurityHub.Types.AwsRdsDbInstanceEndpoint where

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

-- | Specifies the connection endpoint.
--
-- /See:/ 'newAwsRdsDbInstanceEndpoint' smart constructor.
data AwsRdsDbInstanceEndpoint = AwsRdsDbInstanceEndpoint'
  { -- | Specifies the ID that Amazon Route 53 assigns when you create a hosted
    -- zone.
    AwsRdsDbInstanceEndpoint -> Maybe Text
hostedZoneId :: Prelude.Maybe Prelude.Text,
    -- | Specifies the DNS address of the DB instance.
    AwsRdsDbInstanceEndpoint -> Maybe Text
address :: Prelude.Maybe Prelude.Text,
    -- | Specifies the port that the database engine is listening on.
    AwsRdsDbInstanceEndpoint -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool
(AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool)
-> (AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool)
-> Eq AwsRdsDbInstanceEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool
$c/= :: AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool
== :: AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool
$c== :: AwsRdsDbInstanceEndpoint -> AwsRdsDbInstanceEndpoint -> Bool
Prelude.Eq, ReadPrec [AwsRdsDbInstanceEndpoint]
ReadPrec AwsRdsDbInstanceEndpoint
Int -> ReadS AwsRdsDbInstanceEndpoint
ReadS [AwsRdsDbInstanceEndpoint]
(Int -> ReadS AwsRdsDbInstanceEndpoint)
-> ReadS [AwsRdsDbInstanceEndpoint]
-> ReadPrec AwsRdsDbInstanceEndpoint
-> ReadPrec [AwsRdsDbInstanceEndpoint]
-> Read AwsRdsDbInstanceEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsRdsDbInstanceEndpoint]
$creadListPrec :: ReadPrec [AwsRdsDbInstanceEndpoint]
readPrec :: ReadPrec AwsRdsDbInstanceEndpoint
$creadPrec :: ReadPrec AwsRdsDbInstanceEndpoint
readList :: ReadS [AwsRdsDbInstanceEndpoint]
$creadList :: ReadS [AwsRdsDbInstanceEndpoint]
readsPrec :: Int -> ReadS AwsRdsDbInstanceEndpoint
$creadsPrec :: Int -> ReadS AwsRdsDbInstanceEndpoint
Prelude.Read, Int -> AwsRdsDbInstanceEndpoint -> ShowS
[AwsRdsDbInstanceEndpoint] -> ShowS
AwsRdsDbInstanceEndpoint -> String
(Int -> AwsRdsDbInstanceEndpoint -> ShowS)
-> (AwsRdsDbInstanceEndpoint -> String)
-> ([AwsRdsDbInstanceEndpoint] -> ShowS)
-> Show AwsRdsDbInstanceEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsRdsDbInstanceEndpoint] -> ShowS
$cshowList :: [AwsRdsDbInstanceEndpoint] -> ShowS
show :: AwsRdsDbInstanceEndpoint -> String
$cshow :: AwsRdsDbInstanceEndpoint -> String
showsPrec :: Int -> AwsRdsDbInstanceEndpoint -> ShowS
$cshowsPrec :: Int -> AwsRdsDbInstanceEndpoint -> ShowS
Prelude.Show, (forall x.
 AwsRdsDbInstanceEndpoint -> Rep AwsRdsDbInstanceEndpoint x)
-> (forall x.
    Rep AwsRdsDbInstanceEndpoint x -> AwsRdsDbInstanceEndpoint)
-> Generic AwsRdsDbInstanceEndpoint
forall x.
Rep AwsRdsDbInstanceEndpoint x -> AwsRdsDbInstanceEndpoint
forall x.
AwsRdsDbInstanceEndpoint -> Rep AwsRdsDbInstanceEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsRdsDbInstanceEndpoint x -> AwsRdsDbInstanceEndpoint
$cfrom :: forall x.
AwsRdsDbInstanceEndpoint -> Rep AwsRdsDbInstanceEndpoint x
Prelude.Generic)

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

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

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

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

instance Core.FromJSON AwsRdsDbInstanceEndpoint where
  parseJSON :: Value -> Parser AwsRdsDbInstanceEndpoint
parseJSON =
    String
-> (Object -> Parser AwsRdsDbInstanceEndpoint)
-> Value
-> Parser AwsRdsDbInstanceEndpoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsRdsDbInstanceEndpoint"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Int -> AwsRdsDbInstanceEndpoint
AwsRdsDbInstanceEndpoint'
            (Maybe Text -> Maybe Text -> Maybe Int -> AwsRdsDbInstanceEndpoint)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Int -> AwsRdsDbInstanceEndpoint)
forall (f :: * -> *) a b. Functor 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
"HostedZoneId")
            Parser (Maybe Text -> Maybe Int -> AwsRdsDbInstanceEndpoint)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> AwsRdsDbInstanceEndpoint)
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
"Address")
            Parser (Maybe Int -> AwsRdsDbInstanceEndpoint)
-> Parser (Maybe Int) -> Parser AwsRdsDbInstanceEndpoint
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
"Port")
      )

instance Prelude.Hashable AwsRdsDbInstanceEndpoint

instance Prelude.NFData AwsRdsDbInstanceEndpoint

instance Core.ToJSON AwsRdsDbInstanceEndpoint where
  toJSON :: AwsRdsDbInstanceEndpoint -> Value
toJSON AwsRdsDbInstanceEndpoint' {Maybe Int
Maybe Text
port :: Maybe Int
address :: Maybe Text
hostedZoneId :: Maybe Text
$sel:port:AwsRdsDbInstanceEndpoint' :: AwsRdsDbInstanceEndpoint -> Maybe Int
$sel:address:AwsRdsDbInstanceEndpoint' :: AwsRdsDbInstanceEndpoint -> Maybe Text
$sel:hostedZoneId:AwsRdsDbInstanceEndpoint' :: AwsRdsDbInstanceEndpoint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HostedZoneId" 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
hostedZoneId,
            (Text
"Address" 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
address,
            (Text
"Port" 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
port
          ]
      )