{-# 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.IoT1ClickDevices.UnclaimDevice
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates a device from your AWS account using its device ID.
module Amazonka.IoT1ClickDevices.UnclaimDevice
  ( -- * Creating a Request
    UnclaimDevice (..),
    newUnclaimDevice,

    -- * Request Lenses
    unclaimDevice_deviceId,

    -- * Destructuring the Response
    UnclaimDeviceResponse (..),
    newUnclaimDeviceResponse,

    -- * Response Lenses
    unclaimDeviceResponse_state,
    unclaimDeviceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT1ClickDevices.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUnclaimDevice' smart constructor.
data UnclaimDevice = UnclaimDevice'
  { -- | The unique identifier of the device.
    UnclaimDevice -> Text
deviceId :: Prelude.Text
  }
  deriving (UnclaimDevice -> UnclaimDevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnclaimDevice -> UnclaimDevice -> Bool
$c/= :: UnclaimDevice -> UnclaimDevice -> Bool
== :: UnclaimDevice -> UnclaimDevice -> Bool
$c== :: UnclaimDevice -> UnclaimDevice -> Bool
Prelude.Eq, ReadPrec [UnclaimDevice]
ReadPrec UnclaimDevice
Int -> ReadS UnclaimDevice
ReadS [UnclaimDevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnclaimDevice]
$creadListPrec :: ReadPrec [UnclaimDevice]
readPrec :: ReadPrec UnclaimDevice
$creadPrec :: ReadPrec UnclaimDevice
readList :: ReadS [UnclaimDevice]
$creadList :: ReadS [UnclaimDevice]
readsPrec :: Int -> ReadS UnclaimDevice
$creadsPrec :: Int -> ReadS UnclaimDevice
Prelude.Read, Int -> UnclaimDevice -> ShowS
[UnclaimDevice] -> ShowS
UnclaimDevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnclaimDevice] -> ShowS
$cshowList :: [UnclaimDevice] -> ShowS
show :: UnclaimDevice -> String
$cshow :: UnclaimDevice -> String
showsPrec :: Int -> UnclaimDevice -> ShowS
$cshowsPrec :: Int -> UnclaimDevice -> ShowS
Prelude.Show, forall x. Rep UnclaimDevice x -> UnclaimDevice
forall x. UnclaimDevice -> Rep UnclaimDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnclaimDevice x -> UnclaimDevice
$cfrom :: forall x. UnclaimDevice -> Rep UnclaimDevice x
Prelude.Generic)

-- |
-- Create a value of 'UnclaimDevice' 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:
--
-- 'deviceId', 'unclaimDevice_deviceId' - The unique identifier of the device.
newUnclaimDevice ::
  -- | 'deviceId'
  Prelude.Text ->
  UnclaimDevice
newUnclaimDevice :: Text -> UnclaimDevice
newUnclaimDevice Text
pDeviceId_ =
  UnclaimDevice' {$sel:deviceId:UnclaimDevice' :: Text
deviceId = Text
pDeviceId_}

-- | The unique identifier of the device.
unclaimDevice_deviceId :: Lens.Lens' UnclaimDevice Prelude.Text
unclaimDevice_deviceId :: Lens' UnclaimDevice Text
unclaimDevice_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnclaimDevice' {Text
deviceId :: Text
$sel:deviceId:UnclaimDevice' :: UnclaimDevice -> Text
deviceId} -> Text
deviceId) (\s :: UnclaimDevice
s@UnclaimDevice' {} Text
a -> UnclaimDevice
s {$sel:deviceId:UnclaimDevice' :: Text
deviceId = Text
a} :: UnclaimDevice)

instance Core.AWSRequest UnclaimDevice where
  type
    AWSResponse UnclaimDevice =
      UnclaimDeviceResponse
  request :: (Service -> Service) -> UnclaimDevice -> Request UnclaimDevice
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UnclaimDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnclaimDevice)))
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 Text -> Int -> UnclaimDeviceResponse
UnclaimDeviceResponse'
            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
"state")
            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 UnclaimDevice where
  hashWithSalt :: Int -> UnclaimDevice -> Int
hashWithSalt Int
_salt UnclaimDevice' {Text
deviceId :: Text
$sel:deviceId:UnclaimDevice' :: UnclaimDevice -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceId

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

instance Data.ToHeaders UnclaimDevice where
  toHeaders :: UnclaimDevice -> 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.ToJSON UnclaimDevice where
  toJSON :: UnclaimDevice -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath UnclaimDevice where
  toPath :: UnclaimDevice -> ByteString
toPath UnclaimDevice' {Text
deviceId :: Text
$sel:deviceId:UnclaimDevice' :: UnclaimDevice -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/devices/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
deviceId, ByteString
"/unclaim"]

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

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

-- |
-- Create a value of 'UnclaimDeviceResponse' 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:
--
-- 'state', 'unclaimDeviceResponse_state' - The device\'s final claim state.
--
-- 'httpStatus', 'unclaimDeviceResponse_httpStatus' - The response's http status code.
newUnclaimDeviceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UnclaimDeviceResponse
newUnclaimDeviceResponse :: Int -> UnclaimDeviceResponse
newUnclaimDeviceResponse Int
pHttpStatus_ =
  UnclaimDeviceResponse'
    { $sel:state:UnclaimDeviceResponse' :: Maybe Text
state = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UnclaimDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The device\'s final claim state.
unclaimDeviceResponse_state :: Lens.Lens' UnclaimDeviceResponse (Prelude.Maybe Prelude.Text)
unclaimDeviceResponse_state :: Lens' UnclaimDeviceResponse (Maybe Text)
unclaimDeviceResponse_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnclaimDeviceResponse' {Maybe Text
state :: Maybe Text
$sel:state:UnclaimDeviceResponse' :: UnclaimDeviceResponse -> Maybe Text
state} -> Maybe Text
state) (\s :: UnclaimDeviceResponse
s@UnclaimDeviceResponse' {} Maybe Text
a -> UnclaimDeviceResponse
s {$sel:state:UnclaimDeviceResponse' :: Maybe Text
state = Maybe Text
a} :: UnclaimDeviceResponse)

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

instance Prelude.NFData UnclaimDeviceResponse where
  rnf :: UnclaimDeviceResponse -> ()
rnf UnclaimDeviceResponse' {Int
Maybe Text
httpStatus :: Int
state :: Maybe Text
$sel:httpStatus:UnclaimDeviceResponse' :: UnclaimDeviceResponse -> Int
$sel:state:UnclaimDeviceResponse' :: UnclaimDeviceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus