{-# 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.IoT1ClickProjects.DisassociateDeviceFromPlacement
-- 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)
--
-- Removes a physical device from a placement.
module Amazonka.IoT1ClickProjects.DisassociateDeviceFromPlacement
  ( -- * Creating a Request
    DisassociateDeviceFromPlacement (..),
    newDisassociateDeviceFromPlacement,

    -- * Request Lenses
    disassociateDeviceFromPlacement_projectName,
    disassociateDeviceFromPlacement_placementName,
    disassociateDeviceFromPlacement_deviceTemplateName,

    -- * Destructuring the Response
    DisassociateDeviceFromPlacementResponse (..),
    newDisassociateDeviceFromPlacementResponse,

    -- * Response Lenses
    disassociateDeviceFromPlacementResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT1ClickProjects.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:/ 'newDisassociateDeviceFromPlacement' smart constructor.
data DisassociateDeviceFromPlacement = DisassociateDeviceFromPlacement'
  { -- | The name of the project that contains the placement.
    DisassociateDeviceFromPlacement -> Text
projectName :: Prelude.Text,
    -- | The name of the placement that the device should be removed from.
    DisassociateDeviceFromPlacement -> Text
placementName :: Prelude.Text,
    -- | The device ID that should be removed from the placement.
    DisassociateDeviceFromPlacement -> Text
deviceTemplateName :: Prelude.Text
  }
  deriving (DisassociateDeviceFromPlacement
-> DisassociateDeviceFromPlacement -> Bool
(DisassociateDeviceFromPlacement
 -> DisassociateDeviceFromPlacement -> Bool)
-> (DisassociateDeviceFromPlacement
    -> DisassociateDeviceFromPlacement -> Bool)
-> Eq DisassociateDeviceFromPlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateDeviceFromPlacement
-> DisassociateDeviceFromPlacement -> Bool
$c/= :: DisassociateDeviceFromPlacement
-> DisassociateDeviceFromPlacement -> Bool
== :: DisassociateDeviceFromPlacement
-> DisassociateDeviceFromPlacement -> Bool
$c== :: DisassociateDeviceFromPlacement
-> DisassociateDeviceFromPlacement -> Bool
Prelude.Eq, ReadPrec [DisassociateDeviceFromPlacement]
ReadPrec DisassociateDeviceFromPlacement
Int -> ReadS DisassociateDeviceFromPlacement
ReadS [DisassociateDeviceFromPlacement]
(Int -> ReadS DisassociateDeviceFromPlacement)
-> ReadS [DisassociateDeviceFromPlacement]
-> ReadPrec DisassociateDeviceFromPlacement
-> ReadPrec [DisassociateDeviceFromPlacement]
-> Read DisassociateDeviceFromPlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateDeviceFromPlacement]
$creadListPrec :: ReadPrec [DisassociateDeviceFromPlacement]
readPrec :: ReadPrec DisassociateDeviceFromPlacement
$creadPrec :: ReadPrec DisassociateDeviceFromPlacement
readList :: ReadS [DisassociateDeviceFromPlacement]
$creadList :: ReadS [DisassociateDeviceFromPlacement]
readsPrec :: Int -> ReadS DisassociateDeviceFromPlacement
$creadsPrec :: Int -> ReadS DisassociateDeviceFromPlacement
Prelude.Read, Int -> DisassociateDeviceFromPlacement -> ShowS
[DisassociateDeviceFromPlacement] -> ShowS
DisassociateDeviceFromPlacement -> String
(Int -> DisassociateDeviceFromPlacement -> ShowS)
-> (DisassociateDeviceFromPlacement -> String)
-> ([DisassociateDeviceFromPlacement] -> ShowS)
-> Show DisassociateDeviceFromPlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateDeviceFromPlacement] -> ShowS
$cshowList :: [DisassociateDeviceFromPlacement] -> ShowS
show :: DisassociateDeviceFromPlacement -> String
$cshow :: DisassociateDeviceFromPlacement -> String
showsPrec :: Int -> DisassociateDeviceFromPlacement -> ShowS
$cshowsPrec :: Int -> DisassociateDeviceFromPlacement -> ShowS
Prelude.Show, (forall x.
 DisassociateDeviceFromPlacement
 -> Rep DisassociateDeviceFromPlacement x)
-> (forall x.
    Rep DisassociateDeviceFromPlacement x
    -> DisassociateDeviceFromPlacement)
-> Generic DisassociateDeviceFromPlacement
forall x.
Rep DisassociateDeviceFromPlacement x
-> DisassociateDeviceFromPlacement
forall x.
DisassociateDeviceFromPlacement
-> Rep DisassociateDeviceFromPlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateDeviceFromPlacement x
-> DisassociateDeviceFromPlacement
$cfrom :: forall x.
DisassociateDeviceFromPlacement
-> Rep DisassociateDeviceFromPlacement x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateDeviceFromPlacement' 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:
--
-- 'projectName', 'disassociateDeviceFromPlacement_projectName' - The name of the project that contains the placement.
--
-- 'placementName', 'disassociateDeviceFromPlacement_placementName' - The name of the placement that the device should be removed from.
--
-- 'deviceTemplateName', 'disassociateDeviceFromPlacement_deviceTemplateName' - The device ID that should be removed from the placement.
newDisassociateDeviceFromPlacement ::
  -- | 'projectName'
  Prelude.Text ->
  -- | 'placementName'
  Prelude.Text ->
  -- | 'deviceTemplateName'
  Prelude.Text ->
  DisassociateDeviceFromPlacement
newDisassociateDeviceFromPlacement :: Text -> Text -> Text -> DisassociateDeviceFromPlacement
newDisassociateDeviceFromPlacement
  Text
pProjectName_
  Text
pPlacementName_
  Text
pDeviceTemplateName_ =
    DisassociateDeviceFromPlacement' :: Text -> Text -> Text -> DisassociateDeviceFromPlacement
DisassociateDeviceFromPlacement'
      { $sel:projectName:DisassociateDeviceFromPlacement' :: Text
projectName =
          Text
pProjectName_,
        $sel:placementName:DisassociateDeviceFromPlacement' :: Text
placementName = Text
pPlacementName_,
        $sel:deviceTemplateName:DisassociateDeviceFromPlacement' :: Text
deviceTemplateName = Text
pDeviceTemplateName_
      }

-- | The name of the project that contains the placement.
disassociateDeviceFromPlacement_projectName :: Lens.Lens' DisassociateDeviceFromPlacement Prelude.Text
disassociateDeviceFromPlacement_projectName :: (Text -> f Text)
-> DisassociateDeviceFromPlacement
-> f DisassociateDeviceFromPlacement
disassociateDeviceFromPlacement_projectName = (DisassociateDeviceFromPlacement -> Text)
-> (DisassociateDeviceFromPlacement
    -> Text -> DisassociateDeviceFromPlacement)
-> Lens
     DisassociateDeviceFromPlacement
     DisassociateDeviceFromPlacement
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDeviceFromPlacement' {Text
projectName :: Text
$sel:projectName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
projectName} -> Text
projectName) (\s :: DisassociateDeviceFromPlacement
s@DisassociateDeviceFromPlacement' {} Text
a -> DisassociateDeviceFromPlacement
s {$sel:projectName:DisassociateDeviceFromPlacement' :: Text
projectName = Text
a} :: DisassociateDeviceFromPlacement)

-- | The name of the placement that the device should be removed from.
disassociateDeviceFromPlacement_placementName :: Lens.Lens' DisassociateDeviceFromPlacement Prelude.Text
disassociateDeviceFromPlacement_placementName :: (Text -> f Text)
-> DisassociateDeviceFromPlacement
-> f DisassociateDeviceFromPlacement
disassociateDeviceFromPlacement_placementName = (DisassociateDeviceFromPlacement -> Text)
-> (DisassociateDeviceFromPlacement
    -> Text -> DisassociateDeviceFromPlacement)
-> Lens
     DisassociateDeviceFromPlacement
     DisassociateDeviceFromPlacement
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDeviceFromPlacement' {Text
placementName :: Text
$sel:placementName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
placementName} -> Text
placementName) (\s :: DisassociateDeviceFromPlacement
s@DisassociateDeviceFromPlacement' {} Text
a -> DisassociateDeviceFromPlacement
s {$sel:placementName:DisassociateDeviceFromPlacement' :: Text
placementName = Text
a} :: DisassociateDeviceFromPlacement)

-- | The device ID that should be removed from the placement.
disassociateDeviceFromPlacement_deviceTemplateName :: Lens.Lens' DisassociateDeviceFromPlacement Prelude.Text
disassociateDeviceFromPlacement_deviceTemplateName :: (Text -> f Text)
-> DisassociateDeviceFromPlacement
-> f DisassociateDeviceFromPlacement
disassociateDeviceFromPlacement_deviceTemplateName = (DisassociateDeviceFromPlacement -> Text)
-> (DisassociateDeviceFromPlacement
    -> Text -> DisassociateDeviceFromPlacement)
-> Lens
     DisassociateDeviceFromPlacement
     DisassociateDeviceFromPlacement
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDeviceFromPlacement' {Text
deviceTemplateName :: Text
$sel:deviceTemplateName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
deviceTemplateName} -> Text
deviceTemplateName) (\s :: DisassociateDeviceFromPlacement
s@DisassociateDeviceFromPlacement' {} Text
a -> DisassociateDeviceFromPlacement
s {$sel:deviceTemplateName:DisassociateDeviceFromPlacement' :: Text
deviceTemplateName = Text
a} :: DisassociateDeviceFromPlacement)

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

instance
  Prelude.NFData
    DisassociateDeviceFromPlacement

instance
  Core.ToHeaders
    DisassociateDeviceFromPlacement
  where
  toHeaders :: DisassociateDeviceFromPlacement -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DisassociateDeviceFromPlacement -> 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 DisassociateDeviceFromPlacement where
  toPath :: DisassociateDeviceFromPlacement -> ByteString
toPath DisassociateDeviceFromPlacement' {Text
deviceTemplateName :: Text
placementName :: Text
projectName :: Text
$sel:deviceTemplateName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
$sel:placementName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
$sel:projectName:DisassociateDeviceFromPlacement' :: DisassociateDeviceFromPlacement -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectName,
        ByteString
"/placements/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
placementName,
        ByteString
"/devices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceTemplateName
      ]

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

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

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

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

instance
  Prelude.NFData
    DisassociateDeviceFromPlacementResponse