{-# 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-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)
--
-- 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_message,
    getConnectivityInfoResponse_connectivityInfo,
    getConnectivityInfoResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types
import qualified Amazonka.Lens as Lens
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
(GetConnectivityInfo -> GetConnectivityInfo -> Bool)
-> (GetConnectivityInfo -> GetConnectivityInfo -> Bool)
-> Eq GetConnectivityInfo
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]
(Int -> ReadS GetConnectivityInfo)
-> ReadS [GetConnectivityInfo]
-> ReadPrec GetConnectivityInfo
-> ReadPrec [GetConnectivityInfo]
-> Read 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
(Int -> GetConnectivityInfo -> ShowS)
-> (GetConnectivityInfo -> String)
-> ([GetConnectivityInfo] -> ShowS)
-> Show GetConnectivityInfo
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. GetConnectivityInfo -> Rep GetConnectivityInfo x)
-> (forall x. Rep GetConnectivityInfo x -> GetConnectivityInfo)
-> Generic GetConnectivityInfo
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' :: Text -> GetConnectivityInfo
GetConnectivityInfo' {$sel:thingName:GetConnectivityInfo' :: Text
thingName = Text
pThingName_}

-- | The thing name.
getConnectivityInfo_thingName :: Lens.Lens' GetConnectivityInfo Prelude.Text
getConnectivityInfo_thingName :: (Text -> f Text) -> GetConnectivityInfo -> f GetConnectivityInfo
getConnectivityInfo_thingName = (GetConnectivityInfo -> Text)
-> (GetConnectivityInfo -> Text -> GetConnectivityInfo)
-> Lens GetConnectivityInfo GetConnectivityInfo Text Text
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 :: GetConnectivityInfo -> Request GetConnectivityInfo
request = Service -> GetConnectivityInfo -> Request GetConnectivityInfo
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetConnectivityInfo
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConnectivityInfo)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetConnectivityInfo))
-> Logger
-> Service
-> Proxy GetConnectivityInfo
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetConnectivityInfo)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe [ConnectivityInfo] -> Int -> GetConnectivityInfoResponse
GetConnectivityInfoResponse'
            (Maybe Text
 -> Maybe [ConnectivityInfo] -> Int -> GetConnectivityInfoResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [ConnectivityInfo] -> Int -> GetConnectivityInfoResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"message")
            Either
  String
  (Maybe [ConnectivityInfo] -> Int -> GetConnectivityInfoResponse)
-> Either String (Maybe [ConnectivityInfo])
-> Either String (Int -> GetConnectivityInfoResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [ConnectivityInfo]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ConnectivityInfo"
                            Either String (Maybe (Maybe [ConnectivityInfo]))
-> Maybe [ConnectivityInfo]
-> Either String (Maybe [ConnectivityInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ConnectivityInfo]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> GetConnectivityInfoResponse)
-> Either String Int -> Either String GetConnectivityInfoResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetConnectivityInfo

instance Prelude.NFData GetConnectivityInfo

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

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

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

-- | /See:/ 'newGetConnectivityInfoResponse' smart constructor.
data GetConnectivityInfoResponse = GetConnectivityInfoResponse'
  { -- | A message about the connectivity info request.
    GetConnectivityInfoResponse -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | Connectivity info list.
    GetConnectivityInfoResponse -> Maybe [ConnectivityInfo]
connectivityInfo :: Prelude.Maybe [ConnectivityInfo],
    -- | The response's http status code.
    GetConnectivityInfoResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetConnectivityInfoResponse -> GetConnectivityInfoResponse -> Bool
(GetConnectivityInfoResponse
 -> GetConnectivityInfoResponse -> Bool)
-> (GetConnectivityInfoResponse
    -> GetConnectivityInfoResponse -> Bool)
-> Eq GetConnectivityInfoResponse
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]
(Int -> ReadS GetConnectivityInfoResponse)
-> ReadS [GetConnectivityInfoResponse]
-> ReadPrec GetConnectivityInfoResponse
-> ReadPrec [GetConnectivityInfoResponse]
-> Read 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
(Int -> GetConnectivityInfoResponse -> ShowS)
-> (GetConnectivityInfoResponse -> String)
-> ([GetConnectivityInfoResponse] -> ShowS)
-> Show GetConnectivityInfoResponse
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.
 GetConnectivityInfoResponse -> Rep GetConnectivityInfoResponse x)
-> (forall x.
    Rep GetConnectivityInfoResponse x -> GetConnectivityInfoResponse)
-> Generic GetConnectivityInfoResponse
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:
--
-- 'message', 'getConnectivityInfoResponse_message' - A message about the connectivity info request.
--
-- 'connectivityInfo', 'getConnectivityInfoResponse_connectivityInfo' - Connectivity info list.
--
-- 'httpStatus', 'getConnectivityInfoResponse_httpStatus' - The response's http status code.
newGetConnectivityInfoResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetConnectivityInfoResponse
newGetConnectivityInfoResponse :: Int -> GetConnectivityInfoResponse
newGetConnectivityInfoResponse Int
pHttpStatus_ =
  GetConnectivityInfoResponse' :: Maybe Text
-> Maybe [ConnectivityInfo] -> Int -> GetConnectivityInfoResponse
GetConnectivityInfoResponse'
    { $sel:message:GetConnectivityInfoResponse' :: Maybe Text
message =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectivityInfo:GetConnectivityInfoResponse' :: Maybe [ConnectivityInfo]
connectivityInfo = Maybe [ConnectivityInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetConnectivityInfoResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A message about the connectivity info request.
getConnectivityInfoResponse_message :: Lens.Lens' GetConnectivityInfoResponse (Prelude.Maybe Prelude.Text)
getConnectivityInfoResponse_message :: (Maybe Text -> f (Maybe Text))
-> GetConnectivityInfoResponse -> f GetConnectivityInfoResponse
getConnectivityInfoResponse_message = (GetConnectivityInfoResponse -> Maybe Text)
-> (GetConnectivityInfoResponse
    -> Maybe Text -> GetConnectivityInfoResponse)
-> Lens
     GetConnectivityInfoResponse
     GetConnectivityInfoResponse
     (Maybe Text)
     (Maybe Text)
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)

-- | Connectivity info list.
getConnectivityInfoResponse_connectivityInfo :: Lens.Lens' GetConnectivityInfoResponse (Prelude.Maybe [ConnectivityInfo])
getConnectivityInfoResponse_connectivityInfo :: (Maybe [ConnectivityInfo] -> f (Maybe [ConnectivityInfo]))
-> GetConnectivityInfoResponse -> f GetConnectivityInfoResponse
getConnectivityInfoResponse_connectivityInfo = (GetConnectivityInfoResponse -> Maybe [ConnectivityInfo])
-> (GetConnectivityInfoResponse
    -> Maybe [ConnectivityInfo] -> GetConnectivityInfoResponse)
-> Lens
     GetConnectivityInfoResponse
     GetConnectivityInfoResponse
     (Maybe [ConnectivityInfo])
     (Maybe [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) ((Maybe [ConnectivityInfo] -> f (Maybe [ConnectivityInfo]))
 -> GetConnectivityInfoResponse -> f GetConnectivityInfoResponse)
-> ((Maybe [ConnectivityInfo] -> f (Maybe [ConnectivityInfo]))
    -> Maybe [ConnectivityInfo] -> f (Maybe [ConnectivityInfo]))
-> (Maybe [ConnectivityInfo] -> f (Maybe [ConnectivityInfo]))
-> GetConnectivityInfoResponse
-> f GetConnectivityInfoResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ConnectivityInfo]
  [ConnectivityInfo]
  [ConnectivityInfo]
  [ConnectivityInfo]
-> Iso
     (Maybe [ConnectivityInfo])
     (Maybe [ConnectivityInfo])
     (Maybe [ConnectivityInfo])
     (Maybe [ConnectivityInfo])
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 AnIso
  [ConnectivityInfo]
  [ConnectivityInfo]
  [ConnectivityInfo]
  [ConnectivityInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
getConnectivityInfoResponse_httpStatus :: Lens.Lens' GetConnectivityInfoResponse Prelude.Int
getConnectivityInfoResponse_httpStatus :: (Int -> f Int)
-> GetConnectivityInfoResponse -> f GetConnectivityInfoResponse
getConnectivityInfoResponse_httpStatus = (GetConnectivityInfoResponse -> Int)
-> (GetConnectivityInfoResponse
    -> Int -> GetConnectivityInfoResponse)
-> Lens
     GetConnectivityInfoResponse GetConnectivityInfoResponse Int Int
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