{-# 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.AwsRedshiftClusterEndpoint
-- 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.AwsRedshiftClusterEndpoint where

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

-- | The connection endpoint for an Amazon Redshift cluster.
--
-- /See:/ 'newAwsRedshiftClusterEndpoint' smart constructor.
data AwsRedshiftClusterEndpoint = AwsRedshiftClusterEndpoint'
  { -- | The DNS address of the cluster.
    AwsRedshiftClusterEndpoint -> Maybe Text
address :: Prelude.Maybe Prelude.Text,
    -- | The port that the database engine listens on.
    AwsRedshiftClusterEndpoint -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool
(AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool)
-> (AwsRedshiftClusterEndpoint
    -> AwsRedshiftClusterEndpoint -> Bool)
-> Eq AwsRedshiftClusterEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool
$c/= :: AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool
== :: AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool
$c== :: AwsRedshiftClusterEndpoint -> AwsRedshiftClusterEndpoint -> Bool
Prelude.Eq, ReadPrec [AwsRedshiftClusterEndpoint]
ReadPrec AwsRedshiftClusterEndpoint
Int -> ReadS AwsRedshiftClusterEndpoint
ReadS [AwsRedshiftClusterEndpoint]
(Int -> ReadS AwsRedshiftClusterEndpoint)
-> ReadS [AwsRedshiftClusterEndpoint]
-> ReadPrec AwsRedshiftClusterEndpoint
-> ReadPrec [AwsRedshiftClusterEndpoint]
-> Read AwsRedshiftClusterEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsRedshiftClusterEndpoint]
$creadListPrec :: ReadPrec [AwsRedshiftClusterEndpoint]
readPrec :: ReadPrec AwsRedshiftClusterEndpoint
$creadPrec :: ReadPrec AwsRedshiftClusterEndpoint
readList :: ReadS [AwsRedshiftClusterEndpoint]
$creadList :: ReadS [AwsRedshiftClusterEndpoint]
readsPrec :: Int -> ReadS AwsRedshiftClusterEndpoint
$creadsPrec :: Int -> ReadS AwsRedshiftClusterEndpoint
Prelude.Read, Int -> AwsRedshiftClusterEndpoint -> ShowS
[AwsRedshiftClusterEndpoint] -> ShowS
AwsRedshiftClusterEndpoint -> String
(Int -> AwsRedshiftClusterEndpoint -> ShowS)
-> (AwsRedshiftClusterEndpoint -> String)
-> ([AwsRedshiftClusterEndpoint] -> ShowS)
-> Show AwsRedshiftClusterEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsRedshiftClusterEndpoint] -> ShowS
$cshowList :: [AwsRedshiftClusterEndpoint] -> ShowS
show :: AwsRedshiftClusterEndpoint -> String
$cshow :: AwsRedshiftClusterEndpoint -> String
showsPrec :: Int -> AwsRedshiftClusterEndpoint -> ShowS
$cshowsPrec :: Int -> AwsRedshiftClusterEndpoint -> ShowS
Prelude.Show, (forall x.
 AwsRedshiftClusterEndpoint -> Rep AwsRedshiftClusterEndpoint x)
-> (forall x.
    Rep AwsRedshiftClusterEndpoint x -> AwsRedshiftClusterEndpoint)
-> Generic AwsRedshiftClusterEndpoint
forall x.
Rep AwsRedshiftClusterEndpoint x -> AwsRedshiftClusterEndpoint
forall x.
AwsRedshiftClusterEndpoint -> Rep AwsRedshiftClusterEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsRedshiftClusterEndpoint x -> AwsRedshiftClusterEndpoint
$cfrom :: forall x.
AwsRedshiftClusterEndpoint -> Rep AwsRedshiftClusterEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'AwsRedshiftClusterEndpoint' 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', 'awsRedshiftClusterEndpoint_address' - The DNS address of the cluster.
--
-- 'port', 'awsRedshiftClusterEndpoint_port' - The port that the database engine listens on.
newAwsRedshiftClusterEndpoint ::
  AwsRedshiftClusterEndpoint
newAwsRedshiftClusterEndpoint :: AwsRedshiftClusterEndpoint
newAwsRedshiftClusterEndpoint =
  AwsRedshiftClusterEndpoint' :: Maybe Text -> Maybe Int -> AwsRedshiftClusterEndpoint
AwsRedshiftClusterEndpoint'
    { $sel:address:AwsRedshiftClusterEndpoint' :: Maybe Text
address =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:AwsRedshiftClusterEndpoint' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The DNS address of the cluster.
awsRedshiftClusterEndpoint_address :: Lens.Lens' AwsRedshiftClusterEndpoint (Prelude.Maybe Prelude.Text)
awsRedshiftClusterEndpoint_address :: (Maybe Text -> f (Maybe Text))
-> AwsRedshiftClusterEndpoint -> f AwsRedshiftClusterEndpoint
awsRedshiftClusterEndpoint_address = (AwsRedshiftClusterEndpoint -> Maybe Text)
-> (AwsRedshiftClusterEndpoint
    -> Maybe Text -> AwsRedshiftClusterEndpoint)
-> Lens
     AwsRedshiftClusterEndpoint
     AwsRedshiftClusterEndpoint
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsRedshiftClusterEndpoint' {Maybe Text
address :: Maybe Text
$sel:address:AwsRedshiftClusterEndpoint' :: AwsRedshiftClusterEndpoint -> Maybe Text
address} -> Maybe Text
address) (\s :: AwsRedshiftClusterEndpoint
s@AwsRedshiftClusterEndpoint' {} Maybe Text
a -> AwsRedshiftClusterEndpoint
s {$sel:address:AwsRedshiftClusterEndpoint' :: Maybe Text
address = Maybe Text
a} :: AwsRedshiftClusterEndpoint)

-- | The port that the database engine listens on.
awsRedshiftClusterEndpoint_port :: Lens.Lens' AwsRedshiftClusterEndpoint (Prelude.Maybe Prelude.Int)
awsRedshiftClusterEndpoint_port :: (Maybe Int -> f (Maybe Int))
-> AwsRedshiftClusterEndpoint -> f AwsRedshiftClusterEndpoint
awsRedshiftClusterEndpoint_port = (AwsRedshiftClusterEndpoint -> Maybe Int)
-> (AwsRedshiftClusterEndpoint
    -> Maybe Int -> AwsRedshiftClusterEndpoint)
-> Lens
     AwsRedshiftClusterEndpoint
     AwsRedshiftClusterEndpoint
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsRedshiftClusterEndpoint' {Maybe Int
port :: Maybe Int
$sel:port:AwsRedshiftClusterEndpoint' :: AwsRedshiftClusterEndpoint -> Maybe Int
port} -> Maybe Int
port) (\s :: AwsRedshiftClusterEndpoint
s@AwsRedshiftClusterEndpoint' {} Maybe Int
a -> AwsRedshiftClusterEndpoint
s {$sel:port:AwsRedshiftClusterEndpoint' :: Maybe Int
port = Maybe Int
a} :: AwsRedshiftClusterEndpoint)

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

instance Prelude.NFData AwsRedshiftClusterEndpoint

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