{-# 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.OpsWorks.DeleteLayer
-- 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 specified layer. You must first stop and then delete all
-- associated instances or unassign registered instances. For more
-- information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinglayers-basics-delete.html How to Delete a Layer>.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.DeleteLayer
  ( -- * Creating a Request
    DeleteLayer (..),
    newDeleteLayer,

    -- * Request Lenses
    deleteLayer_layerId,

    -- * Destructuring the Response
    DeleteLayerResponse (..),
    newDeleteLayerResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DeleteLayer' 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:
--
-- 'layerId', 'deleteLayer_layerId' - The layer ID.
newDeleteLayer ::
  -- | 'layerId'
  Prelude.Text ->
  DeleteLayer
newDeleteLayer :: Text -> DeleteLayer
newDeleteLayer Text
pLayerId_ =
  DeleteLayer' :: Text -> DeleteLayer
DeleteLayer' {$sel:layerId:DeleteLayer' :: Text
layerId = Text
pLayerId_}

-- | The layer ID.
deleteLayer_layerId :: Lens.Lens' DeleteLayer Prelude.Text
deleteLayer_layerId :: (Text -> f Text) -> DeleteLayer -> f DeleteLayer
deleteLayer_layerId = (DeleteLayer -> Text)
-> (DeleteLayer -> Text -> DeleteLayer)
-> Lens DeleteLayer DeleteLayer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteLayer' {Text
layerId :: Text
$sel:layerId:DeleteLayer' :: DeleteLayer -> Text
layerId} -> Text
layerId) (\s :: DeleteLayer
s@DeleteLayer' {} Text
a -> DeleteLayer
s {$sel:layerId:DeleteLayer' :: Text
layerId = Text
a} :: DeleteLayer)

instance Core.AWSRequest DeleteLayer where
  type AWSResponse DeleteLayer = DeleteLayerResponse
  request :: DeleteLayer -> Request DeleteLayer
request = Service -> DeleteLayer -> Request DeleteLayer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteLayer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteLayer)))
response = AWSResponse DeleteLayer
-> Logger
-> Service
-> Proxy DeleteLayer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteLayer)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteLayer
DeleteLayerResponse
DeleteLayerResponse'

instance Prelude.Hashable DeleteLayer

instance Prelude.NFData DeleteLayer

instance Core.ToHeaders DeleteLayer where
  toHeaders :: DeleteLayer -> [Header]
toHeaders =
    [Header] -> DeleteLayer -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.DeleteLayer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeleteLayer where
  toJSON :: DeleteLayer -> Value
toJSON DeleteLayer' {Text
layerId :: Text
$sel:layerId:DeleteLayer' :: DeleteLayer -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LayerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
layerId)]
      )

instance Core.ToPath DeleteLayer where
  toPath :: DeleteLayer -> ByteString
toPath = ByteString -> DeleteLayer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteLayerResponse' 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.
newDeleteLayerResponse ::
  DeleteLayerResponse
newDeleteLayerResponse :: DeleteLayerResponse
newDeleteLayerResponse = DeleteLayerResponse
DeleteLayerResponse'

instance Prelude.NFData DeleteLayerResponse