{-# 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.UpdateDeviceDefinition
-- 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 a device definition.
module Amazonka.Greengrass.UpdateDeviceDefinition
  ( -- * Creating a Request
    UpdateDeviceDefinition (..),
    newUpdateDeviceDefinition,

    -- * Request Lenses
    updateDeviceDefinition_name,
    updateDeviceDefinition_deviceDefinitionId,

    -- * Destructuring the Response
    UpdateDeviceDefinitionResponse (..),
    newUpdateDeviceDefinitionResponse,

    -- * Response Lenses
    updateDeviceDefinitionResponse_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:/ 'newUpdateDeviceDefinition' smart constructor.
data UpdateDeviceDefinition = UpdateDeviceDefinition'
  { -- | The name of the definition.
    UpdateDeviceDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the device definition.
    UpdateDeviceDefinition -> Text
deviceDefinitionId :: Prelude.Text
  }
  deriving (UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool
(UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool)
-> (UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool)
-> Eq UpdateDeviceDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool
$c/= :: UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool
== :: UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool
$c== :: UpdateDeviceDefinition -> UpdateDeviceDefinition -> Bool
Prelude.Eq, ReadPrec [UpdateDeviceDefinition]
ReadPrec UpdateDeviceDefinition
Int -> ReadS UpdateDeviceDefinition
ReadS [UpdateDeviceDefinition]
(Int -> ReadS UpdateDeviceDefinition)
-> ReadS [UpdateDeviceDefinition]
-> ReadPrec UpdateDeviceDefinition
-> ReadPrec [UpdateDeviceDefinition]
-> Read UpdateDeviceDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDeviceDefinition]
$creadListPrec :: ReadPrec [UpdateDeviceDefinition]
readPrec :: ReadPrec UpdateDeviceDefinition
$creadPrec :: ReadPrec UpdateDeviceDefinition
readList :: ReadS [UpdateDeviceDefinition]
$creadList :: ReadS [UpdateDeviceDefinition]
readsPrec :: Int -> ReadS UpdateDeviceDefinition
$creadsPrec :: Int -> ReadS UpdateDeviceDefinition
Prelude.Read, Int -> UpdateDeviceDefinition -> ShowS
[UpdateDeviceDefinition] -> ShowS
UpdateDeviceDefinition -> String
(Int -> UpdateDeviceDefinition -> ShowS)
-> (UpdateDeviceDefinition -> String)
-> ([UpdateDeviceDefinition] -> ShowS)
-> Show UpdateDeviceDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDeviceDefinition] -> ShowS
$cshowList :: [UpdateDeviceDefinition] -> ShowS
show :: UpdateDeviceDefinition -> String
$cshow :: UpdateDeviceDefinition -> String
showsPrec :: Int -> UpdateDeviceDefinition -> ShowS
$cshowsPrec :: Int -> UpdateDeviceDefinition -> ShowS
Prelude.Show, (forall x. UpdateDeviceDefinition -> Rep UpdateDeviceDefinition x)
-> (forall x.
    Rep UpdateDeviceDefinition x -> UpdateDeviceDefinition)
-> Generic UpdateDeviceDefinition
forall x. Rep UpdateDeviceDefinition x -> UpdateDeviceDefinition
forall x. UpdateDeviceDefinition -> Rep UpdateDeviceDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDeviceDefinition x -> UpdateDeviceDefinition
$cfrom :: forall x. UpdateDeviceDefinition -> Rep UpdateDeviceDefinition x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDeviceDefinition' 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:
--
-- 'name', 'updateDeviceDefinition_name' - The name of the definition.
--
-- 'deviceDefinitionId', 'updateDeviceDefinition_deviceDefinitionId' - The ID of the device definition.
newUpdateDeviceDefinition ::
  -- | 'deviceDefinitionId'
  Prelude.Text ->
  UpdateDeviceDefinition
newUpdateDeviceDefinition :: Text -> UpdateDeviceDefinition
newUpdateDeviceDefinition Text
pDeviceDefinitionId_ =
  UpdateDeviceDefinition' :: Maybe Text -> Text -> UpdateDeviceDefinition
UpdateDeviceDefinition'
    { $sel:name:UpdateDeviceDefinition' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceDefinitionId:UpdateDeviceDefinition' :: Text
deviceDefinitionId = Text
pDeviceDefinitionId_
    }

-- | The name of the definition.
updateDeviceDefinition_name :: Lens.Lens' UpdateDeviceDefinition (Prelude.Maybe Prelude.Text)
updateDeviceDefinition_name :: (Maybe Text -> f (Maybe Text))
-> UpdateDeviceDefinition -> f UpdateDeviceDefinition
updateDeviceDefinition_name = (UpdateDeviceDefinition -> Maybe Text)
-> (UpdateDeviceDefinition -> Maybe Text -> UpdateDeviceDefinition)
-> Lens
     UpdateDeviceDefinition
     UpdateDeviceDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeviceDefinition' {Maybe Text
name :: Maybe Text
$sel:name:UpdateDeviceDefinition' :: UpdateDeviceDefinition -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateDeviceDefinition
s@UpdateDeviceDefinition' {} Maybe Text
a -> UpdateDeviceDefinition
s {$sel:name:UpdateDeviceDefinition' :: Maybe Text
name = Maybe Text
a} :: UpdateDeviceDefinition)

-- | The ID of the device definition.
updateDeviceDefinition_deviceDefinitionId :: Lens.Lens' UpdateDeviceDefinition Prelude.Text
updateDeviceDefinition_deviceDefinitionId :: (Text -> f Text)
-> UpdateDeviceDefinition -> f UpdateDeviceDefinition
updateDeviceDefinition_deviceDefinitionId = (UpdateDeviceDefinition -> Text)
-> (UpdateDeviceDefinition -> Text -> UpdateDeviceDefinition)
-> Lens UpdateDeviceDefinition UpdateDeviceDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeviceDefinition' {Text
deviceDefinitionId :: Text
$sel:deviceDefinitionId:UpdateDeviceDefinition' :: UpdateDeviceDefinition -> Text
deviceDefinitionId} -> Text
deviceDefinitionId) (\s :: UpdateDeviceDefinition
s@UpdateDeviceDefinition' {} Text
a -> UpdateDeviceDefinition
s {$sel:deviceDefinitionId:UpdateDeviceDefinition' :: Text
deviceDefinitionId = Text
a} :: UpdateDeviceDefinition)

instance Core.AWSRequest UpdateDeviceDefinition where
  type
    AWSResponse UpdateDeviceDefinition =
      UpdateDeviceDefinitionResponse
  request :: UpdateDeviceDefinition -> Request UpdateDeviceDefinition
request = Service -> UpdateDeviceDefinition -> Request UpdateDeviceDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDeviceDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDeviceDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateDeviceDefinition))
-> Logger
-> Service
-> Proxy UpdateDeviceDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDeviceDefinition)))
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 -> UpdateDeviceDefinitionResponse
UpdateDeviceDefinitionResponse'
            (Int -> UpdateDeviceDefinitionResponse)
-> Either String Int
-> Either String UpdateDeviceDefinitionResponse
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 UpdateDeviceDefinition

instance Prelude.NFData UpdateDeviceDefinition

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

instance Core.ToPath UpdateDeviceDefinition where
  toPath :: UpdateDeviceDefinition -> ByteString
toPath UpdateDeviceDefinition' {Maybe Text
Text
deviceDefinitionId :: Text
name :: Maybe Text
$sel:deviceDefinitionId:UpdateDeviceDefinition' :: UpdateDeviceDefinition -> Text
$sel:name:UpdateDeviceDefinition' :: UpdateDeviceDefinition -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/definition/devices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceDefinitionId
      ]

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

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

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

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

instance
  Prelude.NFData
    UpdateDeviceDefinitionResponse