{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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:/ 'newGetThingRuntimeConfiguration' smart constructor.
data GetThingRuntimeConfiguration = GetThingRuntimeConfiguration'
  { -- | The thing name.
    GetThingRuntimeConfiguration -> Text
thingName :: Prelude.Text
  }
  deriving (GetThingRuntimeConfiguration
-> GetThingRuntimeConfiguration -> Bool
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]
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
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.
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'
    { $sel:thingName:GetThingRuntimeConfiguration' :: Text
thingName =
        Text
pThingName_
    }

-- | The thing name.
getThingRuntimeConfiguration_thingName :: Lens.Lens' GetThingRuntimeConfiguration Prelude.Text
getThingRuntimeConfiguration_thingName :: Lens' GetThingRuntimeConfiguration Text
getThingRuntimeConfiguration_thingName = 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 :: (Service -> Service)
-> GetThingRuntimeConfiguration
-> Request GetThingRuntimeConfiguration
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 GetThingRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetThingRuntimeConfiguration)))
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 RuntimeConfiguration
-> Int -> GetThingRuntimeConfigurationResponse
GetThingRuntimeConfigurationResponse'
            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
"RuntimeConfiguration")
            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
    GetThingRuntimeConfiguration
  where
  hashWithSalt :: Int -> GetThingRuntimeConfiguration -> Int
hashWithSalt Int
_salt GetThingRuntimeConfiguration' {Text
thingName :: Text
$sel:thingName:GetThingRuntimeConfiguration' :: GetThingRuntimeConfiguration -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingName

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

instance Data.ToHeaders GetThingRuntimeConfiguration where
  toHeaders :: GetThingRuntimeConfiguration -> 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 GetThingRuntimeConfiguration where
  toPath :: GetThingRuntimeConfiguration -> ByteString
toPath GetThingRuntimeConfiguration' {Text
thingName :: Text
$sel:thingName:GetThingRuntimeConfiguration' :: GetThingRuntimeConfiguration -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/things/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
thingName,
        ByteString
"/runtimeconfig"
      ]

instance Data.ToQuery GetThingRuntimeConfiguration where
  toQuery :: GetThingRuntimeConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:runtimeConfiguration:GetThingRuntimeConfigurationResponse' :: Maybe RuntimeConfiguration
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 :: Lens'
  GetThingRuntimeConfigurationResponse (Maybe RuntimeConfiguration)
getThingRuntimeConfigurationResponse_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 :: Lens' GetThingRuntimeConfigurationResponse Int
getThingRuntimeConfigurationResponse_httpStatus = 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
  where
  rnf :: GetThingRuntimeConfigurationResponse -> ()
rnf GetThingRuntimeConfigurationResponse' {Int
Maybe RuntimeConfiguration
httpStatus :: Int
runtimeConfiguration :: Maybe RuntimeConfiguration
$sel:httpStatus:GetThingRuntimeConfigurationResponse' :: GetThingRuntimeConfigurationResponse -> Int
$sel:runtimeConfiguration:GetThingRuntimeConfigurationResponse' :: GetThingRuntimeConfigurationResponse -> Maybe RuntimeConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RuntimeConfiguration
runtimeConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus