{-# 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.Greengrass.Types.ConnectivityInfo
-- 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.Greengrass.Types.ConnectivityInfo where

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

-- | Information about a Greengrass core\'s connectivity.
--
-- /See:/ 'newConnectivityInfo' smart constructor.
data ConnectivityInfo = ConnectivityInfo'
  { -- | The port of the Greengrass core. Usually 8883.
    ConnectivityInfo -> Maybe Int
portNumber :: Prelude.Maybe Prelude.Int,
    -- | The ID of the connectivity information.
    ConnectivityInfo -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | Metadata for this endpoint.
    ConnectivityInfo -> Maybe Text
metadata :: Prelude.Maybe Prelude.Text,
    -- | The endpoint for the Greengrass core. Can be an IP address or DNS.
    ConnectivityInfo -> Maybe Text
hostAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectivityInfo -> ConnectivityInfo -> Bool
(ConnectivityInfo -> ConnectivityInfo -> Bool)
-> (ConnectivityInfo -> ConnectivityInfo -> Bool)
-> Eq ConnectivityInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectivityInfo -> ConnectivityInfo -> Bool
$c/= :: ConnectivityInfo -> ConnectivityInfo -> Bool
== :: ConnectivityInfo -> ConnectivityInfo -> Bool
$c== :: ConnectivityInfo -> ConnectivityInfo -> Bool
Prelude.Eq, ReadPrec [ConnectivityInfo]
ReadPrec ConnectivityInfo
Int -> ReadS ConnectivityInfo
ReadS [ConnectivityInfo]
(Int -> ReadS ConnectivityInfo)
-> ReadS [ConnectivityInfo]
-> ReadPrec ConnectivityInfo
-> ReadPrec [ConnectivityInfo]
-> Read ConnectivityInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectivityInfo]
$creadListPrec :: ReadPrec [ConnectivityInfo]
readPrec :: ReadPrec ConnectivityInfo
$creadPrec :: ReadPrec ConnectivityInfo
readList :: ReadS [ConnectivityInfo]
$creadList :: ReadS [ConnectivityInfo]
readsPrec :: Int -> ReadS ConnectivityInfo
$creadsPrec :: Int -> ReadS ConnectivityInfo
Prelude.Read, Int -> ConnectivityInfo -> ShowS
[ConnectivityInfo] -> ShowS
ConnectivityInfo -> String
(Int -> ConnectivityInfo -> ShowS)
-> (ConnectivityInfo -> String)
-> ([ConnectivityInfo] -> ShowS)
-> Show ConnectivityInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectivityInfo] -> ShowS
$cshowList :: [ConnectivityInfo] -> ShowS
show :: ConnectivityInfo -> String
$cshow :: ConnectivityInfo -> String
showsPrec :: Int -> ConnectivityInfo -> ShowS
$cshowsPrec :: Int -> ConnectivityInfo -> ShowS
Prelude.Show, (forall x. ConnectivityInfo -> Rep ConnectivityInfo x)
-> (forall x. Rep ConnectivityInfo x -> ConnectivityInfo)
-> Generic ConnectivityInfo
forall x. Rep ConnectivityInfo x -> ConnectivityInfo
forall x. ConnectivityInfo -> Rep ConnectivityInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectivityInfo x -> ConnectivityInfo
$cfrom :: forall x. ConnectivityInfo -> Rep ConnectivityInfo x
Prelude.Generic)

-- |
-- Create a value of 'ConnectivityInfo' 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:
--
-- 'portNumber', 'connectivityInfo_portNumber' - The port of the Greengrass core. Usually 8883.
--
-- 'id', 'connectivityInfo_id' - The ID of the connectivity information.
--
-- 'metadata', 'connectivityInfo_metadata' - Metadata for this endpoint.
--
-- 'hostAddress', 'connectivityInfo_hostAddress' - The endpoint for the Greengrass core. Can be an IP address or DNS.
newConnectivityInfo ::
  ConnectivityInfo
newConnectivityInfo :: ConnectivityInfo
newConnectivityInfo =
  ConnectivityInfo' :: Maybe Int
-> Maybe Text -> Maybe Text -> Maybe Text -> ConnectivityInfo
ConnectivityInfo'
    { $sel:portNumber:ConnectivityInfo' :: Maybe Int
portNumber = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ConnectivityInfo' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metadata:ConnectivityInfo' :: Maybe Text
metadata = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hostAddress:ConnectivityInfo' :: Maybe Text
hostAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The port of the Greengrass core. Usually 8883.
connectivityInfo_portNumber :: Lens.Lens' ConnectivityInfo (Prelude.Maybe Prelude.Int)
connectivityInfo_portNumber :: (Maybe Int -> f (Maybe Int))
-> ConnectivityInfo -> f ConnectivityInfo
connectivityInfo_portNumber = (ConnectivityInfo -> Maybe Int)
-> (ConnectivityInfo -> Maybe Int -> ConnectivityInfo)
-> Lens ConnectivityInfo ConnectivityInfo (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectivityInfo' {Maybe Int
portNumber :: Maybe Int
$sel:portNumber:ConnectivityInfo' :: ConnectivityInfo -> Maybe Int
portNumber} -> Maybe Int
portNumber) (\s :: ConnectivityInfo
s@ConnectivityInfo' {} Maybe Int
a -> ConnectivityInfo
s {$sel:portNumber:ConnectivityInfo' :: Maybe Int
portNumber = Maybe Int
a} :: ConnectivityInfo)

-- | The ID of the connectivity information.
connectivityInfo_id :: Lens.Lens' ConnectivityInfo (Prelude.Maybe Prelude.Text)
connectivityInfo_id :: (Maybe Text -> f (Maybe Text))
-> ConnectivityInfo -> f ConnectivityInfo
connectivityInfo_id = (ConnectivityInfo -> Maybe Text)
-> (ConnectivityInfo -> Maybe Text -> ConnectivityInfo)
-> Lens ConnectivityInfo ConnectivityInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectivityInfo' {Maybe Text
id :: Maybe Text
$sel:id:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
id} -> Maybe Text
id) (\s :: ConnectivityInfo
s@ConnectivityInfo' {} Maybe Text
a -> ConnectivityInfo
s {$sel:id:ConnectivityInfo' :: Maybe Text
id = Maybe Text
a} :: ConnectivityInfo)

-- | Metadata for this endpoint.
connectivityInfo_metadata :: Lens.Lens' ConnectivityInfo (Prelude.Maybe Prelude.Text)
connectivityInfo_metadata :: (Maybe Text -> f (Maybe Text))
-> ConnectivityInfo -> f ConnectivityInfo
connectivityInfo_metadata = (ConnectivityInfo -> Maybe Text)
-> (ConnectivityInfo -> Maybe Text -> ConnectivityInfo)
-> Lens ConnectivityInfo ConnectivityInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectivityInfo' {Maybe Text
metadata :: Maybe Text
$sel:metadata:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
metadata} -> Maybe Text
metadata) (\s :: ConnectivityInfo
s@ConnectivityInfo' {} Maybe Text
a -> ConnectivityInfo
s {$sel:metadata:ConnectivityInfo' :: Maybe Text
metadata = Maybe Text
a} :: ConnectivityInfo)

-- | The endpoint for the Greengrass core. Can be an IP address or DNS.
connectivityInfo_hostAddress :: Lens.Lens' ConnectivityInfo (Prelude.Maybe Prelude.Text)
connectivityInfo_hostAddress :: (Maybe Text -> f (Maybe Text))
-> ConnectivityInfo -> f ConnectivityInfo
connectivityInfo_hostAddress = (ConnectivityInfo -> Maybe Text)
-> (ConnectivityInfo -> Maybe Text -> ConnectivityInfo)
-> Lens ConnectivityInfo ConnectivityInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectivityInfo' {Maybe Text
hostAddress :: Maybe Text
$sel:hostAddress:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
hostAddress} -> Maybe Text
hostAddress) (\s :: ConnectivityInfo
s@ConnectivityInfo' {} Maybe Text
a -> ConnectivityInfo
s {$sel:hostAddress:ConnectivityInfo' :: Maybe Text
hostAddress = Maybe Text
a} :: ConnectivityInfo)

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

instance Prelude.Hashable ConnectivityInfo

instance Prelude.NFData ConnectivityInfo

instance Core.ToJSON ConnectivityInfo where
  toJSON :: ConnectivityInfo -> Value
toJSON ConnectivityInfo' {Maybe Int
Maybe Text
hostAddress :: Maybe Text
metadata :: Maybe Text
id :: Maybe Text
portNumber :: Maybe Int
$sel:hostAddress:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
$sel:metadata:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
$sel:id:ConnectivityInfo' :: ConnectivityInfo -> Maybe Text
$sel:portNumber:ConnectivityInfo' :: ConnectivityInfo -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PortNumber" 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
portNumber,
            (Text
"Id" 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
id,
            (Text
"Metadata" 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
metadata,
            (Text
"HostAddress" 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
hostAddress
          ]
      )