{-# 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.DeregisterVolume
-- 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)
--
-- Deregisters an Amazon EBS volume. The volume can then be registered by
-- another 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.DeregisterVolume
  ( -- * Creating a Request
    DeregisterVolume (..),
    newDeregisterVolume,

    -- * Request Lenses
    deregisterVolume_volumeId,

    -- * Destructuring the Response
    DeregisterVolumeResponse (..),
    newDeregisterVolumeResponse,
  )
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:/ 'newDeregisterVolume' smart constructor.
data DeregisterVolume = DeregisterVolume'
  { -- | The AWS OpsWorks Stacks volume ID, which is the GUID that AWS OpsWorks
    -- Stacks assigned to the instance when you registered the volume with the
    -- stack, not the Amazon EC2 volume ID.
    DeregisterVolume -> Text
volumeId :: Prelude.Text
  }
  deriving (DeregisterVolume -> DeregisterVolume -> Bool
(DeregisterVolume -> DeregisterVolume -> Bool)
-> (DeregisterVolume -> DeregisterVolume -> Bool)
-> Eq DeregisterVolume
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterVolume -> DeregisterVolume -> Bool
$c/= :: DeregisterVolume -> DeregisterVolume -> Bool
== :: DeregisterVolume -> DeregisterVolume -> Bool
$c== :: DeregisterVolume -> DeregisterVolume -> Bool
Prelude.Eq, ReadPrec [DeregisterVolume]
ReadPrec DeregisterVolume
Int -> ReadS DeregisterVolume
ReadS [DeregisterVolume]
(Int -> ReadS DeregisterVolume)
-> ReadS [DeregisterVolume]
-> ReadPrec DeregisterVolume
-> ReadPrec [DeregisterVolume]
-> Read DeregisterVolume
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterVolume]
$creadListPrec :: ReadPrec [DeregisterVolume]
readPrec :: ReadPrec DeregisterVolume
$creadPrec :: ReadPrec DeregisterVolume
readList :: ReadS [DeregisterVolume]
$creadList :: ReadS [DeregisterVolume]
readsPrec :: Int -> ReadS DeregisterVolume
$creadsPrec :: Int -> ReadS DeregisterVolume
Prelude.Read, Int -> DeregisterVolume -> ShowS
[DeregisterVolume] -> ShowS
DeregisterVolume -> String
(Int -> DeregisterVolume -> ShowS)
-> (DeregisterVolume -> String)
-> ([DeregisterVolume] -> ShowS)
-> Show DeregisterVolume
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterVolume] -> ShowS
$cshowList :: [DeregisterVolume] -> ShowS
show :: DeregisterVolume -> String
$cshow :: DeregisterVolume -> String
showsPrec :: Int -> DeregisterVolume -> ShowS
$cshowsPrec :: Int -> DeregisterVolume -> ShowS
Prelude.Show, (forall x. DeregisterVolume -> Rep DeregisterVolume x)
-> (forall x. Rep DeregisterVolume x -> DeregisterVolume)
-> Generic DeregisterVolume
forall x. Rep DeregisterVolume x -> DeregisterVolume
forall x. DeregisterVolume -> Rep DeregisterVolume x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterVolume x -> DeregisterVolume
$cfrom :: forall x. DeregisterVolume -> Rep DeregisterVolume x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterVolume' 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', 'deregisterVolume_volumeId' - The AWS OpsWorks Stacks volume ID, which is the GUID that AWS OpsWorks
-- Stacks assigned to the instance when you registered the volume with the
-- stack, not the Amazon EC2 volume ID.
newDeregisterVolume ::
  -- | 'volumeId'
  Prelude.Text ->
  DeregisterVolume
newDeregisterVolume :: Text -> DeregisterVolume
newDeregisterVolume Text
pVolumeId_ =
  DeregisterVolume' :: Text -> DeregisterVolume
DeregisterVolume' {$sel:volumeId:DeregisterVolume' :: Text
volumeId = Text
pVolumeId_}

-- | The AWS OpsWorks Stacks volume ID, which is the GUID that AWS OpsWorks
-- Stacks assigned to the instance when you registered the volume with the
-- stack, not the Amazon EC2 volume ID.
deregisterVolume_volumeId :: Lens.Lens' DeregisterVolume Prelude.Text
deregisterVolume_volumeId :: (Text -> f Text) -> DeregisterVolume -> f DeregisterVolume
deregisterVolume_volumeId = (DeregisterVolume -> Text)
-> (DeregisterVolume -> Text -> DeregisterVolume)
-> Lens DeregisterVolume DeregisterVolume Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterVolume' {Text
volumeId :: Text
$sel:volumeId:DeregisterVolume' :: DeregisterVolume -> Text
volumeId} -> Text
volumeId) (\s :: DeregisterVolume
s@DeregisterVolume' {} Text
a -> DeregisterVolume
s {$sel:volumeId:DeregisterVolume' :: Text
volumeId = Text
a} :: DeregisterVolume)

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

instance Prelude.Hashable DeregisterVolume

instance Prelude.NFData DeregisterVolume

instance Core.ToHeaders DeregisterVolume where
  toHeaders :: DeregisterVolume -> [Header]
toHeaders =
    [Header] -> DeregisterVolume -> [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.DeregisterVolume" ::
                          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 DeregisterVolume where
  toJSON :: DeregisterVolume -> Value
toJSON DeregisterVolume' {Text
volumeId :: Text
$sel:volumeId:DeregisterVolume' :: DeregisterVolume -> 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 DeregisterVolume where
  toPath :: DeregisterVolume -> ByteString
toPath = ByteString -> DeregisterVolume -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

instance Prelude.NFData DeregisterVolumeResponse