{-# 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-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)
--
-- 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.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:/ 'newUnassignVolume' smart constructor.
data UnassignVolume = UnassignVolume'
  { -- | The volume ID.
    UnassignVolume -> Text
volumeId :: Prelude.Text
  }
  deriving (UnassignVolume -> UnassignVolume -> Bool
(UnassignVolume -> UnassignVolume -> Bool)
-> (UnassignVolume -> UnassignVolume -> Bool) -> Eq UnassignVolume
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]
(Int -> ReadS UnassignVolume)
-> ReadS [UnassignVolume]
-> ReadPrec UnassignVolume
-> ReadPrec [UnassignVolume]
-> Read 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
(Int -> UnassignVolume -> ShowS)
-> (UnassignVolume -> String)
-> ([UnassignVolume] -> ShowS)
-> Show UnassignVolume
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. UnassignVolume -> Rep UnassignVolume x)
-> (forall x. Rep UnassignVolume x -> UnassignVolume)
-> Generic UnassignVolume
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' :: Text -> UnassignVolume
UnassignVolume' {$sel:volumeId:UnassignVolume' :: Text
volumeId = Text
pVolumeId_}

-- | The volume ID.
unassignVolume_volumeId :: Lens.Lens' UnassignVolume Prelude.Text
unassignVolume_volumeId :: (Text -> f Text) -> UnassignVolume -> f UnassignVolume
unassignVolume_volumeId = (UnassignVolume -> Text)
-> (UnassignVolume -> Text -> UnassignVolume)
-> Lens UnassignVolume UnassignVolume Text Text
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 :: UnassignVolume -> Request UnassignVolume
request = Service -> UnassignVolume -> Request UnassignVolume
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UnassignVolume
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnassignVolume)))
response =
    AWSResponse UnassignVolume
-> Logger
-> Service
-> Proxy UnassignVolume
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnassignVolume)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UnassignVolume
UnassignVolumeResponse
UnassignVolumeResponse'

instance Prelude.Hashable UnassignVolume

instance Prelude.NFData UnassignVolume

instance Core.ToHeaders UnassignVolume where
  toHeaders :: UnassignVolume -> [Header]
toHeaders =
    [Header] -> UnassignVolume -> [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.UnassignVolume" ::
                          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 UnassignVolume where
  toJSON :: UnassignVolume -> Value
toJSON UnassignVolume' {Text
volumeId :: Text
$sel:volumeId:UnassignVolume' :: UnassignVolume -> 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
"VolumeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
volumeId)]
      )

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

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

-- | /See:/ 'newUnassignVolumeResponse' smart constructor.
data UnassignVolumeResponse = UnassignVolumeResponse'
  {
  }
  deriving (UnassignVolumeResponse -> UnassignVolumeResponse -> Bool
(UnassignVolumeResponse -> UnassignVolumeResponse -> Bool)
-> (UnassignVolumeResponse -> UnassignVolumeResponse -> Bool)
-> Eq UnassignVolumeResponse
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]
(Int -> ReadS UnassignVolumeResponse)
-> ReadS [UnassignVolumeResponse]
-> ReadPrec UnassignVolumeResponse
-> ReadPrec [UnassignVolumeResponse]
-> Read 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
(Int -> UnassignVolumeResponse -> ShowS)
-> (UnassignVolumeResponse -> String)
-> ([UnassignVolumeResponse] -> ShowS)
-> Show UnassignVolumeResponse
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. UnassignVolumeResponse -> Rep UnassignVolumeResponse x)
-> (forall x.
    Rep UnassignVolumeResponse x -> UnassignVolumeResponse)
-> Generic UnassignVolumeResponse
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