{-# 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.DeletePlacement
-- 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)
--
-- Deletes a placement. To delete a placement, it must not have any devices
-- associated with it.
--
-- When you delete a placement, all associated data becomes irretrievable.
module Amazonka.IoT1ClickProjects.DeletePlacement
  ( -- * Creating a Request
    DeletePlacement (..),
    newDeletePlacement,

    -- * Request Lenses
    deletePlacement_placementName,
    deletePlacement_projectName,

    -- * Destructuring the Response
    DeletePlacementResponse (..),
    newDeletePlacementResponse,

    -- * Response Lenses
    deletePlacementResponse_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:/ 'newDeletePlacement' smart constructor.
data DeletePlacement = DeletePlacement'
  { -- | The name of the empty placement to delete.
    DeletePlacement -> Text
placementName :: Prelude.Text,
    -- | The project containing the empty placement to delete.
    DeletePlacement -> Text
projectName :: Prelude.Text
  }
  deriving (DeletePlacement -> DeletePlacement -> Bool
(DeletePlacement -> DeletePlacement -> Bool)
-> (DeletePlacement -> DeletePlacement -> Bool)
-> Eq DeletePlacement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePlacement -> DeletePlacement -> Bool
$c/= :: DeletePlacement -> DeletePlacement -> Bool
== :: DeletePlacement -> DeletePlacement -> Bool
$c== :: DeletePlacement -> DeletePlacement -> Bool
Prelude.Eq, ReadPrec [DeletePlacement]
ReadPrec DeletePlacement
Int -> ReadS DeletePlacement
ReadS [DeletePlacement]
(Int -> ReadS DeletePlacement)
-> ReadS [DeletePlacement]
-> ReadPrec DeletePlacement
-> ReadPrec [DeletePlacement]
-> Read DeletePlacement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePlacement]
$creadListPrec :: ReadPrec [DeletePlacement]
readPrec :: ReadPrec DeletePlacement
$creadPrec :: ReadPrec DeletePlacement
readList :: ReadS [DeletePlacement]
$creadList :: ReadS [DeletePlacement]
readsPrec :: Int -> ReadS DeletePlacement
$creadsPrec :: Int -> ReadS DeletePlacement
Prelude.Read, Int -> DeletePlacement -> ShowS
[DeletePlacement] -> ShowS
DeletePlacement -> String
(Int -> DeletePlacement -> ShowS)
-> (DeletePlacement -> String)
-> ([DeletePlacement] -> ShowS)
-> Show DeletePlacement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePlacement] -> ShowS
$cshowList :: [DeletePlacement] -> ShowS
show :: DeletePlacement -> String
$cshow :: DeletePlacement -> String
showsPrec :: Int -> DeletePlacement -> ShowS
$cshowsPrec :: Int -> DeletePlacement -> ShowS
Prelude.Show, (forall x. DeletePlacement -> Rep DeletePlacement x)
-> (forall x. Rep DeletePlacement x -> DeletePlacement)
-> Generic DeletePlacement
forall x. Rep DeletePlacement x -> DeletePlacement
forall x. DeletePlacement -> Rep DeletePlacement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePlacement x -> DeletePlacement
$cfrom :: forall x. DeletePlacement -> Rep DeletePlacement x
Prelude.Generic)

-- |
-- Create a value of 'DeletePlacement' 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:
--
-- 'placementName', 'deletePlacement_placementName' - The name of the empty placement to delete.
--
-- 'projectName', 'deletePlacement_projectName' - The project containing the empty placement to delete.
newDeletePlacement ::
  -- | 'placementName'
  Prelude.Text ->
  -- | 'projectName'
  Prelude.Text ->
  DeletePlacement
newDeletePlacement :: Text -> Text -> DeletePlacement
newDeletePlacement Text
pPlacementName_ Text
pProjectName_ =
  DeletePlacement' :: Text -> Text -> DeletePlacement
DeletePlacement'
    { $sel:placementName:DeletePlacement' :: Text
placementName = Text
pPlacementName_,
      $sel:projectName:DeletePlacement' :: Text
projectName = Text
pProjectName_
    }

-- | The name of the empty placement to delete.
deletePlacement_placementName :: Lens.Lens' DeletePlacement Prelude.Text
deletePlacement_placementName :: (Text -> f Text) -> DeletePlacement -> f DeletePlacement
deletePlacement_placementName = (DeletePlacement -> Text)
-> (DeletePlacement -> Text -> DeletePlacement)
-> Lens DeletePlacement DeletePlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePlacement' {Text
placementName :: Text
$sel:placementName:DeletePlacement' :: DeletePlacement -> Text
placementName} -> Text
placementName) (\s :: DeletePlacement
s@DeletePlacement' {} Text
a -> DeletePlacement
s {$sel:placementName:DeletePlacement' :: Text
placementName = Text
a} :: DeletePlacement)

-- | The project containing the empty placement to delete.
deletePlacement_projectName :: Lens.Lens' DeletePlacement Prelude.Text
deletePlacement_projectName :: (Text -> f Text) -> DeletePlacement -> f DeletePlacement
deletePlacement_projectName = (DeletePlacement -> Text)
-> (DeletePlacement -> Text -> DeletePlacement)
-> Lens DeletePlacement DeletePlacement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePlacement' {Text
projectName :: Text
$sel:projectName:DeletePlacement' :: DeletePlacement -> Text
projectName} -> Text
projectName) (\s :: DeletePlacement
s@DeletePlacement' {} Text
a -> DeletePlacement
s {$sel:projectName:DeletePlacement' :: Text
projectName = Text
a} :: DeletePlacement)

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

instance Prelude.NFData DeletePlacement

instance Core.ToHeaders DeletePlacement where
  toHeaders :: DeletePlacement -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePlacement -> 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 DeletePlacement where
  toPath :: DeletePlacement -> ByteString
toPath DeletePlacement' {Text
projectName :: Text
placementName :: Text
$sel:projectName:DeletePlacement' :: DeletePlacement -> Text
$sel:placementName:DeletePlacement' :: DeletePlacement -> 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
      ]

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

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

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

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

instance Prelude.NFData DeletePlacementResponse