{-# 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.GroundStation.Types.DataflowEndpoint
-- 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.GroundStation.Types.DataflowEndpoint where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GroundStation.Types.EndpointStatus
import Amazonka.GroundStation.Types.SocketAddress
import qualified Amazonka.Prelude as Prelude

-- | Information about a dataflow endpoint.
--
-- /See:/ 'newDataflowEndpoint' smart constructor.
data DataflowEndpoint = DataflowEndpoint'
  { -- | Socket address of a dataflow endpoint.
    DataflowEndpoint -> Maybe SocketAddress
address :: Prelude.Maybe SocketAddress,
    -- | Maximum transmission unit (MTU) size in bytes of a dataflow endpoint.
    DataflowEndpoint -> Maybe Natural
mtu :: Prelude.Maybe Prelude.Natural,
    -- | Name of a dataflow endpoint.
    DataflowEndpoint -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Status of a dataflow endpoint.
    DataflowEndpoint -> Maybe EndpointStatus
status :: Prelude.Maybe EndpointStatus
  }
  deriving (DataflowEndpoint -> DataflowEndpoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataflowEndpoint -> DataflowEndpoint -> Bool
$c/= :: DataflowEndpoint -> DataflowEndpoint -> Bool
== :: DataflowEndpoint -> DataflowEndpoint -> Bool
$c== :: DataflowEndpoint -> DataflowEndpoint -> Bool
Prelude.Eq, ReadPrec [DataflowEndpoint]
ReadPrec DataflowEndpoint
Int -> ReadS DataflowEndpoint
ReadS [DataflowEndpoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataflowEndpoint]
$creadListPrec :: ReadPrec [DataflowEndpoint]
readPrec :: ReadPrec DataflowEndpoint
$creadPrec :: ReadPrec DataflowEndpoint
readList :: ReadS [DataflowEndpoint]
$creadList :: ReadS [DataflowEndpoint]
readsPrec :: Int -> ReadS DataflowEndpoint
$creadsPrec :: Int -> ReadS DataflowEndpoint
Prelude.Read, Int -> DataflowEndpoint -> ShowS
[DataflowEndpoint] -> ShowS
DataflowEndpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataflowEndpoint] -> ShowS
$cshowList :: [DataflowEndpoint] -> ShowS
show :: DataflowEndpoint -> String
$cshow :: DataflowEndpoint -> String
showsPrec :: Int -> DataflowEndpoint -> ShowS
$cshowsPrec :: Int -> DataflowEndpoint -> ShowS
Prelude.Show, forall x. Rep DataflowEndpoint x -> DataflowEndpoint
forall x. DataflowEndpoint -> Rep DataflowEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataflowEndpoint x -> DataflowEndpoint
$cfrom :: forall x. DataflowEndpoint -> Rep DataflowEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'DataflowEndpoint' 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', 'dataflowEndpoint_address' - Socket address of a dataflow endpoint.
--
-- 'mtu', 'dataflowEndpoint_mtu' - Maximum transmission unit (MTU) size in bytes of a dataflow endpoint.
--
-- 'name', 'dataflowEndpoint_name' - Name of a dataflow endpoint.
--
-- 'status', 'dataflowEndpoint_status' - Status of a dataflow endpoint.
newDataflowEndpoint ::
  DataflowEndpoint
newDataflowEndpoint :: DataflowEndpoint
newDataflowEndpoint =
  DataflowEndpoint'
    { $sel:address:DataflowEndpoint' :: Maybe SocketAddress
address = forall a. Maybe a
Prelude.Nothing,
      $sel:mtu:DataflowEndpoint' :: Maybe Natural
mtu = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DataflowEndpoint' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:status:DataflowEndpoint' :: Maybe EndpointStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | Socket address of a dataflow endpoint.
dataflowEndpoint_address :: Lens.Lens' DataflowEndpoint (Prelude.Maybe SocketAddress)
dataflowEndpoint_address :: Lens' DataflowEndpoint (Maybe SocketAddress)
dataflowEndpoint_address = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataflowEndpoint' {Maybe SocketAddress
address :: Maybe SocketAddress
$sel:address:DataflowEndpoint' :: DataflowEndpoint -> Maybe SocketAddress
address} -> Maybe SocketAddress
address) (\s :: DataflowEndpoint
s@DataflowEndpoint' {} Maybe SocketAddress
a -> DataflowEndpoint
s {$sel:address:DataflowEndpoint' :: Maybe SocketAddress
address = Maybe SocketAddress
a} :: DataflowEndpoint)

-- | Maximum transmission unit (MTU) size in bytes of a dataflow endpoint.
dataflowEndpoint_mtu :: Lens.Lens' DataflowEndpoint (Prelude.Maybe Prelude.Natural)
dataflowEndpoint_mtu :: Lens' DataflowEndpoint (Maybe Natural)
dataflowEndpoint_mtu = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataflowEndpoint' {Maybe Natural
mtu :: Maybe Natural
$sel:mtu:DataflowEndpoint' :: DataflowEndpoint -> Maybe Natural
mtu} -> Maybe Natural
mtu) (\s :: DataflowEndpoint
s@DataflowEndpoint' {} Maybe Natural
a -> DataflowEndpoint
s {$sel:mtu:DataflowEndpoint' :: Maybe Natural
mtu = Maybe Natural
a} :: DataflowEndpoint)

-- | Name of a dataflow endpoint.
dataflowEndpoint_name :: Lens.Lens' DataflowEndpoint (Prelude.Maybe Prelude.Text)
dataflowEndpoint_name :: Lens' DataflowEndpoint (Maybe Text)
dataflowEndpoint_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataflowEndpoint' {Maybe Text
name :: Maybe Text
$sel:name:DataflowEndpoint' :: DataflowEndpoint -> Maybe Text
name} -> Maybe Text
name) (\s :: DataflowEndpoint
s@DataflowEndpoint' {} Maybe Text
a -> DataflowEndpoint
s {$sel:name:DataflowEndpoint' :: Maybe Text
name = Maybe Text
a} :: DataflowEndpoint)

-- | Status of a dataflow endpoint.
dataflowEndpoint_status :: Lens.Lens' DataflowEndpoint (Prelude.Maybe EndpointStatus)
dataflowEndpoint_status :: Lens' DataflowEndpoint (Maybe EndpointStatus)
dataflowEndpoint_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataflowEndpoint' {Maybe EndpointStatus
status :: Maybe EndpointStatus
$sel:status:DataflowEndpoint' :: DataflowEndpoint -> Maybe EndpointStatus
status} -> Maybe EndpointStatus
status) (\s :: DataflowEndpoint
s@DataflowEndpoint' {} Maybe EndpointStatus
a -> DataflowEndpoint
s {$sel:status:DataflowEndpoint' :: Maybe EndpointStatus
status = Maybe EndpointStatus
a} :: DataflowEndpoint)

instance Data.FromJSON DataflowEndpoint where
  parseJSON :: Value -> Parser DataflowEndpoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataflowEndpoint"
      ( \Object
x ->
          Maybe SocketAddress
-> Maybe Natural
-> Maybe Text
-> Maybe EndpointStatus
-> DataflowEndpoint
DataflowEndpoint'
            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
"address")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"mtu")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"status")
      )

instance Prelude.Hashable DataflowEndpoint where
  hashWithSalt :: Int -> DataflowEndpoint -> Int
hashWithSalt Int
_salt DataflowEndpoint' {Maybe Natural
Maybe Text
Maybe EndpointStatus
Maybe SocketAddress
status :: Maybe EndpointStatus
name :: Maybe Text
mtu :: Maybe Natural
address :: Maybe SocketAddress
$sel:status:DataflowEndpoint' :: DataflowEndpoint -> Maybe EndpointStatus
$sel:name:DataflowEndpoint' :: DataflowEndpoint -> Maybe Text
$sel:mtu:DataflowEndpoint' :: DataflowEndpoint -> Maybe Natural
$sel:address:DataflowEndpoint' :: DataflowEndpoint -> Maybe SocketAddress
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SocketAddress
address
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
mtu
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EndpointStatus
status

instance Prelude.NFData DataflowEndpoint where
  rnf :: DataflowEndpoint -> ()
rnf DataflowEndpoint' {Maybe Natural
Maybe Text
Maybe EndpointStatus
Maybe SocketAddress
status :: Maybe EndpointStatus
name :: Maybe Text
mtu :: Maybe Natural
address :: Maybe SocketAddress
$sel:status:DataflowEndpoint' :: DataflowEndpoint -> Maybe EndpointStatus
$sel:name:DataflowEndpoint' :: DataflowEndpoint -> Maybe Text
$sel:mtu:DataflowEndpoint' :: DataflowEndpoint -> Maybe Natural
$sel:address:DataflowEndpoint' :: DataflowEndpoint -> Maybe SocketAddress
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SocketAddress
address
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
mtu
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EndpointStatus
status

instance Data.ToJSON DataflowEndpoint where
  toJSON :: DataflowEndpoint -> Value
toJSON DataflowEndpoint' {Maybe Natural
Maybe Text
Maybe EndpointStatus
Maybe SocketAddress
status :: Maybe EndpointStatus
name :: Maybe Text
mtu :: Maybe Natural
address :: Maybe SocketAddress
$sel:status:DataflowEndpoint' :: DataflowEndpoint -> Maybe EndpointStatus
$sel:name:DataflowEndpoint' :: DataflowEndpoint -> Maybe Text
$sel:mtu:DataflowEndpoint' :: DataflowEndpoint -> Maybe Natural
$sel:address:DataflowEndpoint' :: DataflowEndpoint -> Maybe SocketAddress
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"address" 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 SocketAddress
address,
            (Key
"mtu" 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 Natural
mtu,
            (Key
"name" 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
name,
            (Key
"status" 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 EndpointStatus
status
          ]
      )