{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetConnectivityInfo
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the connectivity information for a core.
module Amazonka.Greengrass.GetConnectivityInfo
  ( -- * Creating a Request
    GetConnectivityInfo (..),
    newGetConnectivityInfo,

    -- * Request Lenses
    getConnectivityInfo_thingName,

    -- * Destructuring the Response
    GetConnectivityInfoResponse (..),
    newGetConnectivityInfoResponse,

    -- * Response Lenses
    getConnectivityInfoResponse_connectivityInfo,
    getConnectivityInfoResponse_message,
    getConnectivityInfoResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Greengrass.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetConnectivityInfo' smart constructor.
data GetConnectivityInfo = GetConnectivityInfo'
  { -- | The thing name.
    GetConnectivityInfo -> Text
thingName :: Prelude.Text
  }
  deriving (GetConnectivityInfo -> GetConnectivityInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetConnectivityInfo -> GetConnectivityInfo -> Bool
$c/= :: GetConnectivityInfo -> GetConnectivityInfo -> Bool
== :: GetConnectivityInfo -> GetConnectivityInfo -> Bool
$c== :: GetConnectivityInfo -> GetConnectivityInfo -> Bool
Prelude.Eq, ReadPrec [GetConnectivityInfo]
ReadPrec GetConnectivityInfo
Int -> ReadS GetConnectivityInfo
ReadS [GetConnectivityInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetConnectivityInfo]
$creadListPrec :: ReadPrec [GetConnectivityInfo]
readPrec :: ReadPrec GetConnectivityInfo
$creadPrec :: ReadPrec GetConnectivityInfo
readList :: ReadS [GetConnectivityInfo]
$creadList :: ReadS [GetConnectivityInfo]
readsPrec :: Int -> ReadS GetConnectivityInfo
$creadsPrec :: Int -> ReadS GetConnectivityInfo
Prelude.Read, Int -> GetConnectivityInfo -> ShowS
[GetConnectivityInfo] -> ShowS
GetConnectivityInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetConnectivityInfo] -> ShowS
$cshowList :: [GetConnectivityInfo] -> ShowS
show :: GetConnectivityInfo -> String
$cshow :: GetConnectivityInfo -> String
showsPrec :: Int -> GetConnectivityInfo -> ShowS
$cshowsPrec :: Int -> GetConnectivityInfo -> ShowS
Prelude.Show, forall x. Rep GetConnectivityInfo x -> GetConnectivityInfo
forall x. GetConnectivityInfo -> Rep GetConnectivityInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetConnectivityInfo x -> GetConnectivityInfo
$cfrom :: forall x. GetConnectivityInfo -> Rep GetConnectivityInfo x
Prelude.Generic)

-- |
-- Create a value of 'GetConnectivityInfo' 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:
--
-- 'thingName', 'getConnectivityInfo_thingName' - The thing name.
newGetConnectivityInfo ::
  -- | 'thingName'
  Prelude.Text ->
  GetConnectivityInfo
newGetConnectivityInfo :: Text -> GetConnectivityInfo
newGetConnectivityInfo Text
pThingName_ =
  GetConnectivityInfo' {$sel:thingName:GetConnectivityInfo' :: Text
thingName = Text
pThingName_}

-- | The thing name.
getConnectivityInfo_thingName :: Lens.Lens' GetConnectivityInfo Prelude.Text
getConnectivityInfo_thingName :: Lens' GetConnectivityInfo Text
getConnectivityInfo_thingName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConnectivityInfo' {Text
thingName :: Text
$sel:thingName:GetConnectivityInfo' :: GetConnectivityInfo -> Text
thingName} -> Text
thingName) (\s :: GetConnectivityInfo
s@GetConnectivityInfo' {} Text
a -> GetConnectivityInfo
s {$sel:thingName:GetConnectivityInfo' :: Text
thingName = Text
a} :: GetConnectivityInfo)

instance Core.AWSRequest GetConnectivityInfo where
  type
    AWSResponse GetConnectivityInfo =
      GetConnectivityInfoResponse
  request :: (Service -> Service)
-> GetConnectivityInfo -> Request GetConnectivityInfo
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetConnectivityInfo
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConnectivityInfo)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ConnectivityInfo]
-> Maybe Text -> Int -> GetConnectivityInfoResponse
GetConnectivityInfoResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ConnectivityInfo"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"message")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetConnectivityInfo where
  hashWithSalt :: Int -> GetConnectivityInfo -> Int
hashWithSalt Int
_salt GetConnectivityInfo' {Text
thingName :: Text
$sel:thingName:GetConnectivityInfo' :: GetConnectivityInfo -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingName

instance Prelude.NFData GetConnectivityInfo where
  rnf :: GetConnectivityInfo -> ()
rnf GetConnectivityInfo' {Text
thingName :: Text
$sel:thingName:GetConnectivityInfo' :: GetConnectivityInfo -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
thingName

instance Data.ToHeaders GetConnectivityInfo where
  toHeaders :: GetConnectivityInfo -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetConnectivityInfo where
  toPath :: GetConnectivityInfo -> ByteString
toPath GetConnectivityInfo' {Text
thingName :: Text
$sel:thingName:GetConnectivityInfo' :: GetConnectivityInfo -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/things/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
thingName,
        ByteString
"/connectivityInfo"
      ]

instance Data.ToQuery GetConnectivityInfo where
  toQuery :: GetConnectivityInfo -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetConnectivityInfoResponse' smart constructor.
data GetConnectivityInfoResponse = GetConnectivityInfoResponse'
  { -- | Connectivity info list.
    GetConnectivityInfoResponse -> Maybe [ConnectivityInfo]
connectivityInfo :: Prelude.Maybe [ConnectivityInfo],
    -- | A message about the connectivity info request.
    GetConnectivityInfoResponse -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetConnectivityInfoResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
$c/= :: GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
== :: GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
$c== :: GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
Prelude.Eq, ReadPrec [GetConnectivityInfoResponse]
ReadPrec GetConnectivityInfoResponse
Int -> ReadS GetConnectivityInfoResponse
ReadS [GetConnectivityInfoResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetConnectivityInfoResponse]
$creadListPrec :: ReadPrec [GetConnectivityInfoResponse]
readPrec :: ReadPrec GetConnectivityInfoResponse
$creadPrec :: ReadPrec GetConnectivityInfoResponse
readList :: ReadS [GetConnectivityInfoResponse]
$creadList :: ReadS [GetConnectivityInfoResponse]
readsPrec :: Int -> ReadS GetConnectivityInfoResponse
$creadsPrec :: Int -> ReadS GetConnectivityInfoResponse
Prelude.Read, Int -> GetConnectivityInfoResponse -> ShowS
[GetConnectivityInfoResponse] -> ShowS
GetConnectivityInfoResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetConnectivityInfoResponse] -> ShowS
$cshowList :: [GetConnectivityInfoResponse] -> ShowS
show :: GetConnectivityInfoResponse -> String
$cshow :: GetConnectivityInfoResponse -> String
showsPrec :: Int -> GetConnectivityInfoResponse -> ShowS
$cshowsPrec :: Int -> GetConnectivityInfoResponse -> ShowS
Prelude.Show, forall x.
Rep GetConnectivityInfoResponse x -> GetConnectivityInfoResponse
forall x.
GetConnectivityInfoResponse -> Rep GetConnectivityInfoResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetConnectivityInfoResponse x -> GetConnectivityInfoResponse
$cfrom :: forall x.
GetConnectivityInfoResponse -> Rep GetConnectivityInfoResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetConnectivityInfoResponse' 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:
--
-- 'connectivityInfo', 'getConnectivityInfoResponse_connectivityInfo' - Connectivity info list.
--
-- 'message', 'getConnectivityInfoResponse_message' - A message about the connectivity info request.
--
-- 'httpStatus', 'getConnectivityInfoResponse_httpStatus' - The response's http status code.
newGetConnectivityInfoResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetConnectivityInfoResponse
newGetConnectivityInfoResponse :: Int -> GetConnectivityInfoResponse
newGetConnectivityInfoResponse Int
pHttpStatus_ =
  GetConnectivityInfoResponse'
    { $sel:connectivityInfo:GetConnectivityInfoResponse' :: Maybe [ConnectivityInfo]
connectivityInfo =
        forall a. Maybe a
Prelude.Nothing,
      $sel:message:GetConnectivityInfoResponse' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetConnectivityInfoResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Connectivity info list.
getConnectivityInfoResponse_connectivityInfo :: Lens.Lens' GetConnectivityInfoResponse (Prelude.Maybe [ConnectivityInfo])
getConnectivityInfoResponse_connectivityInfo :: Lens' GetConnectivityInfoResponse (Maybe [ConnectivityInfo])
getConnectivityInfoResponse_connectivityInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConnectivityInfoResponse' {Maybe [ConnectivityInfo]
connectivityInfo :: Maybe [ConnectivityInfo]
$sel:connectivityInfo:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Maybe [ConnectivityInfo]
connectivityInfo} -> Maybe [ConnectivityInfo]
connectivityInfo) (\s :: GetConnectivityInfoResponse
s@GetConnectivityInfoResponse' {} Maybe [ConnectivityInfo]
a -> GetConnectivityInfoResponse
s {$sel:connectivityInfo:GetConnectivityInfoResponse' :: Maybe [ConnectivityInfo]
connectivityInfo = Maybe [ConnectivityInfo]
a} :: GetConnectivityInfoResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A message about the connectivity info request.
getConnectivityInfoResponse_message :: Lens.Lens' GetConnectivityInfoResponse (Prelude.Maybe Prelude.Text)
getConnectivityInfoResponse_message :: Lens' GetConnectivityInfoResponse (Maybe Text)
getConnectivityInfoResponse_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConnectivityInfoResponse' {Maybe Text
message :: Maybe Text
$sel:message:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Maybe Text
message} -> Maybe Text
message) (\s :: GetConnectivityInfoResponse
s@GetConnectivityInfoResponse' {} Maybe Text
a -> GetConnectivityInfoResponse
s {$sel:message:GetConnectivityInfoResponse' :: Maybe Text
message = Maybe Text
a} :: GetConnectivityInfoResponse)

-- | The response's http status code.
getConnectivityInfoResponse_httpStatus :: Lens.Lens' GetConnectivityInfoResponse Prelude.Int
getConnectivityInfoResponse_httpStatus :: Lens' GetConnectivityInfoResponse Int
getConnectivityInfoResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetConnectivityInfoResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetConnectivityInfoResponse
s@GetConnectivityInfoResponse' {} Int
a -> GetConnectivityInfoResponse
s {$sel:httpStatus:GetConnectivityInfoResponse' :: Int
httpStatus = Int
a} :: GetConnectivityInfoResponse)

instance Prelude.NFData GetConnectivityInfoResponse where
  rnf :: GetConnectivityInfoResponse -> ()
rnf GetConnectivityInfoResponse' {Int
Maybe [ConnectivityInfo]
Maybe Text
httpStatus :: Int
message :: Maybe Text
connectivityInfo :: Maybe [ConnectivityInfo]
$sel:httpStatus:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Int
$sel:message:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Maybe Text
$sel:connectivityInfo:GetConnectivityInfoResponse' :: GetConnectivityInfoResponse -> Maybe [ConnectivityInfo]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ConnectivityInfo]
connectivityInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus