{-# 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.UnassignVolume
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Unassigns an assigned Amazon EBS volume. The volume remains registered
-- with the stack. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/resources.html Resource Management>.
--
-- __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.UnassignVolume
  ( -- * Creating a Request
    UnassignVolume (..),
    newUnassignVolume,

    -- * Request Lenses
    unassignVolume_volumeId,

    -- * Destructuring the Response
    UnassignVolumeResponse (..),
    newUnassignVolumeResponse,
  )
where

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

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

-- |
-- Create a value of 'UnassignVolume' 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:
--
-- 'volumeId', 'unassignVolume_volumeId' - The volume ID.
newUnassignVolume ::
  -- | 'volumeId'
  Prelude.Text ->
  UnassignVolume
newUnassignVolume :: Text -> UnassignVolume
newUnassignVolume Text
pVolumeId_ =
  UnassignVolume' {$sel:volumeId:UnassignVolume' :: Text
volumeId = Text
pVolumeId_}

-- | The volume ID.
unassignVolume_volumeId :: Lens.Lens' UnassignVolume Prelude.Text
unassignVolume_volumeId :: Lens' UnassignVolume Text
unassignVolume_volumeId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnassignVolume' {Text
volumeId :: Text
$sel:volumeId:UnassignVolume' :: UnassignVolume -> Text
volumeId} -> Text
volumeId) (\s :: UnassignVolume
s@UnassignVolume' {} Text
a -> UnassignVolume
s {$sel:volumeId:UnassignVolume' :: Text
volumeId = Text
a} :: UnassignVolume)

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

instance Prelude.Hashable UnassignVolume where
  hashWithSalt :: Int -> UnassignVolume -> Int
hashWithSalt Int
_salt UnassignVolume' {Text
volumeId :: Text
$sel:volumeId:UnassignVolume' :: UnassignVolume -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
volumeId

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

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

instance Data.ToJSON UnassignVolume where
  toJSON :: UnassignVolume -> Value
toJSON UnassignVolume' {Text
volumeId :: Text
$sel:volumeId:UnassignVolume' :: UnassignVolume -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"VolumeId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
volumeId)]
      )

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

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

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

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

instance Prelude.NFData UnassignVolumeResponse where
  rnf :: UnassignVolumeResponse -> ()
rnf UnassignVolumeResponse
_ = ()