{-# 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.GetThingRuntimeConfiguration
-- 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)
--
-- Get the runtime configuration of a thing.
module Amazonka.Greengrass.GetThingRuntimeConfiguration
  ( -- * Creating a Request
    GetThingRuntimeConfiguration (..),
    newGetThingRuntimeConfiguration,

    -- * Request Lenses
    getThingRuntimeConfiguration_thingName,

    -- * Destructuring the Response
    GetThingRuntimeConfigurationResponse (..),
    newGetThingRuntimeConfigurationResponse,

    -- * Response Lenses
    getThingRuntimeConfigurationResponse_runtimeConfiguration,
    getThingRuntimeConfigurationResponse_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:/ 'newGetThingRuntimeConfiguration' smart constructor.
data GetThingRuntimeConfiguration = GetThingRuntimeConfiguration'
  { -- | The thing name.
    GetThingRuntimeConfiguration -> Text
thingName :: Prelude.Text
  }
  deriving (GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
(GetThingRuntimeConfiguration
 -> GetThingRuntimeConfiguration -> Bool)
-> (GetThingRuntimeConfiguration
    -> GetThingRuntimeConfiguration -> Bool)
-> Eq GetThingRuntimeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
$c/= :: GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
== :: GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
$c== :: GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
Prelude.Eq, ReadPrec [GetThingRuntimeConfiguration]
ReadPrec GetThingRuntimeConfiguration
Int -> ReadS GetThingRuntimeConfiguration
ReadS [GetThingRuntimeConfiguration]
(Int -> ReadS GetThingRuntimeConfiguration)
-> ReadS [GetThingRuntimeConfiguration]
-> ReadPrec GetThingRuntimeConfiguration
-> ReadPrec [GetThingRuntimeConfiguration]
-> Read GetThingRuntimeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetThingRuntimeConfiguration]
$creadListPrec :: ReadPrec [GetThingRuntimeConfiguration]
readPrec :: ReadPrec GetThingRuntimeConfiguration
$creadPrec :: ReadPrec GetThingRuntimeConfiguration
readList :: ReadS [GetThingRuntimeConfiguration]
$creadList :: ReadS [GetThingRuntimeConfiguration]
readsPrec :: Int -> ReadS GetThingRuntimeConfiguration
$creadsPrec :: Int -> ReadS GetThingRuntimeConfiguration
Prelude.Read, Int -> GetThingRuntimeConfiguration -> ShowS
[GetThingRuntimeConfiguration] -> ShowS
GetThingRuntimeConfiguration -> String
(Int -> GetThingRuntimeConfiguration -> ShowS)
-> (GetThingRuntimeConfiguration -> String)
-> ([GetThingRuntimeConfiguration] -> ShowS)
-> Show GetThingRuntimeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetThingRuntimeConfiguration] -> ShowS
$cshowList :: [GetThingRuntimeConfiguration] -> ShowS
show :: GetThingRuntimeConfiguration -> String
$cshow :: GetThingRuntimeConfiguration -> String
showsPrec :: Int -> GetThingRuntimeConfiguration -> ShowS
$cshowsPrec :: Int -> GetThingRuntimeConfiguration -> ShowS
Prelude.Show, (forall x.
 GetThingRuntimeConfiguration -> Rep GetThingRuntimeConfiguration x)
-> (forall x.
    Rep GetThingRuntimeConfiguration x -> GetThingRuntimeConfiguration)
-> Generic GetThingRuntimeConfiguration
forall x.
Rep GetThingRuntimeConfiguration x -> GetThingRuntimeConfiguration
forall x.
GetThingRuntimeConfiguration -> Rep GetThingRuntimeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetThingRuntimeConfiguration x -> GetThingRuntimeConfiguration
$cfrom :: forall x.
GetThingRuntimeConfiguration -> Rep GetThingRuntimeConfiguration x
Prelude.Generic)

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

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

instance Core.AWSRequest GetThingRuntimeConfiguration where
  type
    AWSResponse GetThingRuntimeConfiguration =
      GetThingRuntimeConfigurationResponse
  request :: GetThingRuntimeConfiguration
-> Request GetThingRuntimeConfiguration
request = Service
-> GetThingRuntimeConfiguration
-> Request GetThingRuntimeConfiguration
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetThingRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThingRuntimeConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetThingRuntimeConfiguration))
-> Logger
-> Service
-> Proxy GetThingRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThingRuntimeConfiguration)))
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 RuntimeConfiguration
-> Int -> GetThingRuntimeConfigurationResponse
GetThingRuntimeConfigurationResponse'
            (Maybe RuntimeConfiguration
 -> Int -> GetThingRuntimeConfigurationResponse)
-> Either String (Maybe RuntimeConfiguration)
-> Either String (Int -> GetThingRuntimeConfigurationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RuntimeConfiguration)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RuntimeConfiguration")
            Either String (Int -> GetThingRuntimeConfigurationResponse)
-> Either String Int
-> Either String GetThingRuntimeConfigurationResponse
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
    GetThingRuntimeConfiguration

instance Prelude.NFData GetThingRuntimeConfiguration

instance Core.ToHeaders GetThingRuntimeConfiguration where
  toHeaders :: GetThingRuntimeConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetThingRuntimeConfiguration -> 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 GetThingRuntimeConfiguration where
  toPath :: GetThingRuntimeConfiguration -> ByteString
toPath GetThingRuntimeConfiguration' {Text
thingName :: Text
$sel:thingName:GetThingRuntimeConfiguration' :: GetThingRuntimeConfiguration -> 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
"/runtimeconfig"
      ]

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

-- | /See:/ 'newGetThingRuntimeConfigurationResponse' smart constructor.
data GetThingRuntimeConfigurationResponse = GetThingRuntimeConfigurationResponse'
  { -- | Runtime configuration for a thing.
    GetThingRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration :: Prelude.Maybe RuntimeConfiguration,
    -- | The response's http status code.
    GetThingRuntimeConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetThingRuntimeConfigurationResponse
-> GetThingRuntimeConfigurationResponse -> Bool
(GetThingRuntimeConfigurationResponse
 -> GetThingRuntimeConfigurationResponse -> Bool)
-> (GetThingRuntimeConfigurationResponse
    -> GetThingRuntimeConfigurationResponse -> Bool)
-> Eq GetThingRuntimeConfigurationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetThingRuntimeConfigurationResponse
-> GetThingRuntimeConfigurationResponse -> Bool
$c/= :: GetThingRuntimeConfigurationResponse
-> GetThingRuntimeConfigurationResponse -> Bool
== :: GetThingRuntimeConfigurationResponse
-> GetThingRuntimeConfigurationResponse -> Bool
$c== :: GetThingRuntimeConfigurationResponse
-> GetThingRuntimeConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [GetThingRuntimeConfigurationResponse]
ReadPrec GetThingRuntimeConfigurationResponse
Int -> ReadS GetThingRuntimeConfigurationResponse
ReadS [GetThingRuntimeConfigurationResponse]
(Int -> ReadS GetThingRuntimeConfigurationResponse)
-> ReadS [GetThingRuntimeConfigurationResponse]
-> ReadPrec GetThingRuntimeConfigurationResponse
-> ReadPrec [GetThingRuntimeConfigurationResponse]
-> Read GetThingRuntimeConfigurationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetThingRuntimeConfigurationResponse]
$creadListPrec :: ReadPrec [GetThingRuntimeConfigurationResponse]
readPrec :: ReadPrec GetThingRuntimeConfigurationResponse
$creadPrec :: ReadPrec GetThingRuntimeConfigurationResponse
readList :: ReadS [GetThingRuntimeConfigurationResponse]
$creadList :: ReadS [GetThingRuntimeConfigurationResponse]
readsPrec :: Int -> ReadS GetThingRuntimeConfigurationResponse
$creadsPrec :: Int -> ReadS GetThingRuntimeConfigurationResponse
Prelude.Read, Int -> GetThingRuntimeConfigurationResponse -> ShowS
[GetThingRuntimeConfigurationResponse] -> ShowS
GetThingRuntimeConfigurationResponse -> String
(Int -> GetThingRuntimeConfigurationResponse -> ShowS)
-> (GetThingRuntimeConfigurationResponse -> String)
-> ([GetThingRuntimeConfigurationResponse] -> ShowS)
-> Show GetThingRuntimeConfigurationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetThingRuntimeConfigurationResponse] -> ShowS
$cshowList :: [GetThingRuntimeConfigurationResponse] -> ShowS
show :: GetThingRuntimeConfigurationResponse -> String
$cshow :: GetThingRuntimeConfigurationResponse -> String
showsPrec :: Int -> GetThingRuntimeConfigurationResponse -> ShowS
$cshowsPrec :: Int -> GetThingRuntimeConfigurationResponse -> ShowS
Prelude.Show, (forall x.
 GetThingRuntimeConfigurationResponse
 -> Rep GetThingRuntimeConfigurationResponse x)
-> (forall x.
    Rep GetThingRuntimeConfigurationResponse x
    -> GetThingRuntimeConfigurationResponse)
-> Generic GetThingRuntimeConfigurationResponse
forall x.
Rep GetThingRuntimeConfigurationResponse x
-> GetThingRuntimeConfigurationResponse
forall x.
GetThingRuntimeConfigurationResponse
-> Rep GetThingRuntimeConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetThingRuntimeConfigurationResponse x
-> GetThingRuntimeConfigurationResponse
$cfrom :: forall x.
GetThingRuntimeConfigurationResponse
-> Rep GetThingRuntimeConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetThingRuntimeConfigurationResponse' 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:
--
-- 'runtimeConfiguration', 'getThingRuntimeConfigurationResponse_runtimeConfiguration' - Runtime configuration for a thing.
--
-- 'httpStatus', 'getThingRuntimeConfigurationResponse_httpStatus' - The response's http status code.
newGetThingRuntimeConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetThingRuntimeConfigurationResponse
newGetThingRuntimeConfigurationResponse :: Int -> GetThingRuntimeConfigurationResponse
newGetThingRuntimeConfigurationResponse Int
pHttpStatus_ =
  GetThingRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
-> Int -> GetThingRuntimeConfigurationResponse
GetThingRuntimeConfigurationResponse'
    { $sel:runtimeConfiguration:GetThingRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration =
        Maybe RuntimeConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetThingRuntimeConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Runtime configuration for a thing.
getThingRuntimeConfigurationResponse_runtimeConfiguration :: Lens.Lens' GetThingRuntimeConfigurationResponse (Prelude.Maybe RuntimeConfiguration)
getThingRuntimeConfigurationResponse_runtimeConfiguration :: (Maybe RuntimeConfiguration -> f (Maybe RuntimeConfiguration))
-> GetThingRuntimeConfigurationResponse
-> f GetThingRuntimeConfigurationResponse
getThingRuntimeConfigurationResponse_runtimeConfiguration = (GetThingRuntimeConfigurationResponse
 -> Maybe RuntimeConfiguration)
-> (GetThingRuntimeConfigurationResponse
    -> Maybe RuntimeConfiguration
    -> GetThingRuntimeConfigurationResponse)
-> Lens
     GetThingRuntimeConfigurationResponse
     GetThingRuntimeConfigurationResponse
     (Maybe RuntimeConfiguration)
     (Maybe RuntimeConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetThingRuntimeConfigurationResponse' {Maybe RuntimeConfiguration
runtimeConfiguration :: Maybe RuntimeConfiguration
$sel:runtimeConfiguration:GetThingRuntimeConfigurationResponse' :: GetThingRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
runtimeConfiguration} -> Maybe RuntimeConfiguration
runtimeConfiguration) (\s :: GetThingRuntimeConfigurationResponse
s@GetThingRuntimeConfigurationResponse' {} Maybe RuntimeConfiguration
a -> GetThingRuntimeConfigurationResponse
s {$sel:runtimeConfiguration:GetThingRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
runtimeConfiguration = Maybe RuntimeConfiguration
a} :: GetThingRuntimeConfigurationResponse)

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

instance
  Prelude.NFData
    GetThingRuntimeConfigurationResponse