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

    -- * Request Lenses
    updateThingRuntimeConfiguration_telemetryConfiguration,
    updateThingRuntimeConfiguration_thingName,

    -- * Destructuring the Response
    UpdateThingRuntimeConfigurationResponse (..),
    newUpdateThingRuntimeConfigurationResponse,

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

-- |
-- Create a value of 'UpdateThingRuntimeConfiguration' 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:
--
-- 'telemetryConfiguration', 'updateThingRuntimeConfiguration_telemetryConfiguration' - Configuration for telemetry service.
--
-- 'thingName', 'updateThingRuntimeConfiguration_thingName' - The thing name.
newUpdateThingRuntimeConfiguration ::
  -- | 'thingName'
  Prelude.Text ->
  UpdateThingRuntimeConfiguration
newUpdateThingRuntimeConfiguration :: Text -> UpdateThingRuntimeConfiguration
newUpdateThingRuntimeConfiguration Text
pThingName_ =
  UpdateThingRuntimeConfiguration' :: Maybe TelemetryConfigurationUpdate
-> Text -> UpdateThingRuntimeConfiguration
UpdateThingRuntimeConfiguration'
    { $sel:telemetryConfiguration:UpdateThingRuntimeConfiguration' :: Maybe TelemetryConfigurationUpdate
telemetryConfiguration =
        Maybe TelemetryConfigurationUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:UpdateThingRuntimeConfiguration' :: Text
thingName = Text
pThingName_
    }

-- | Configuration for telemetry service.
updateThingRuntimeConfiguration_telemetryConfiguration :: Lens.Lens' UpdateThingRuntimeConfiguration (Prelude.Maybe TelemetryConfigurationUpdate)
updateThingRuntimeConfiguration_telemetryConfiguration :: (Maybe TelemetryConfigurationUpdate
 -> f (Maybe TelemetryConfigurationUpdate))
-> UpdateThingRuntimeConfiguration
-> f UpdateThingRuntimeConfiguration
updateThingRuntimeConfiguration_telemetryConfiguration = (UpdateThingRuntimeConfiguration
 -> Maybe TelemetryConfigurationUpdate)
-> (UpdateThingRuntimeConfiguration
    -> Maybe TelemetryConfigurationUpdate
    -> UpdateThingRuntimeConfiguration)
-> Lens
     UpdateThingRuntimeConfiguration
     UpdateThingRuntimeConfiguration
     (Maybe TelemetryConfigurationUpdate)
     (Maybe TelemetryConfigurationUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThingRuntimeConfiguration' {Maybe TelemetryConfigurationUpdate
telemetryConfiguration :: Maybe TelemetryConfigurationUpdate
$sel:telemetryConfiguration:UpdateThingRuntimeConfiguration' :: UpdateThingRuntimeConfiguration
-> Maybe TelemetryConfigurationUpdate
telemetryConfiguration} -> Maybe TelemetryConfigurationUpdate
telemetryConfiguration) (\s :: UpdateThingRuntimeConfiguration
s@UpdateThingRuntimeConfiguration' {} Maybe TelemetryConfigurationUpdate
a -> UpdateThingRuntimeConfiguration
s {$sel:telemetryConfiguration:UpdateThingRuntimeConfiguration' :: Maybe TelemetryConfigurationUpdate
telemetryConfiguration = Maybe TelemetryConfigurationUpdate
a} :: UpdateThingRuntimeConfiguration)

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

instance
  Core.AWSRequest
    UpdateThingRuntimeConfiguration
  where
  type
    AWSResponse UpdateThingRuntimeConfiguration =
      UpdateThingRuntimeConfigurationResponse
  request :: UpdateThingRuntimeConfiguration
-> Request UpdateThingRuntimeConfiguration
request = Service
-> UpdateThingRuntimeConfiguration
-> Request UpdateThingRuntimeConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateThingRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdateThingRuntimeConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateThingRuntimeConfiguration))
-> Logger
-> Service
-> Proxy UpdateThingRuntimeConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdateThingRuntimeConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateThingRuntimeConfigurationResponse
UpdateThingRuntimeConfigurationResponse'
            (Int -> UpdateThingRuntimeConfigurationResponse)
-> Either String Int
-> Either String UpdateThingRuntimeConfigurationResponse
forall (f :: * -> *) a b. Functor 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
    UpdateThingRuntimeConfiguration

instance
  Prelude.NFData
    UpdateThingRuntimeConfiguration

instance
  Core.ToHeaders
    UpdateThingRuntimeConfiguration
  where
  toHeaders :: UpdateThingRuntimeConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateThingRuntimeConfiguration -> 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.ToJSON UpdateThingRuntimeConfiguration where
  toJSON :: UpdateThingRuntimeConfiguration -> Value
toJSON UpdateThingRuntimeConfiguration' {Maybe TelemetryConfigurationUpdate
Text
thingName :: Text
telemetryConfiguration :: Maybe TelemetryConfigurationUpdate
$sel:thingName:UpdateThingRuntimeConfiguration' :: UpdateThingRuntimeConfiguration -> Text
$sel:telemetryConfiguration:UpdateThingRuntimeConfiguration' :: UpdateThingRuntimeConfiguration
-> Maybe TelemetryConfigurationUpdate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TelemetryConfiguration" Text -> TelemetryConfigurationUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TelemetryConfigurationUpdate -> Pair)
-> Maybe TelemetryConfigurationUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TelemetryConfigurationUpdate
telemetryConfiguration
          ]
      )

instance Core.ToPath UpdateThingRuntimeConfiguration where
  toPath :: UpdateThingRuntimeConfiguration -> ByteString
toPath UpdateThingRuntimeConfiguration' {Maybe TelemetryConfigurationUpdate
Text
thingName :: Text
telemetryConfiguration :: Maybe TelemetryConfigurationUpdate
$sel:thingName:UpdateThingRuntimeConfiguration' :: UpdateThingRuntimeConfiguration -> Text
$sel:telemetryConfiguration:UpdateThingRuntimeConfiguration' :: UpdateThingRuntimeConfiguration
-> Maybe TelemetryConfigurationUpdate
..} =
    [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 UpdateThingRuntimeConfiguration where
  toQuery :: UpdateThingRuntimeConfiguration -> QueryString
toQuery = QueryString -> UpdateThingRuntimeConfiguration -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'UpdateThingRuntimeConfigurationResponse' 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:
--
-- 'httpStatus', 'updateThingRuntimeConfigurationResponse_httpStatus' - The response's http status code.
newUpdateThingRuntimeConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateThingRuntimeConfigurationResponse
newUpdateThingRuntimeConfigurationResponse :: Int -> UpdateThingRuntimeConfigurationResponse
newUpdateThingRuntimeConfigurationResponse
  Int
pHttpStatus_ =
    UpdateThingRuntimeConfigurationResponse' :: Int -> UpdateThingRuntimeConfigurationResponse
UpdateThingRuntimeConfigurationResponse'
      { $sel:httpStatus:UpdateThingRuntimeConfigurationResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    UpdateThingRuntimeConfigurationResponse