{-# 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.DisassociateElasticIp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disassociates an Elastic IP address from its instance. The address
-- 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.DisassociateElasticIp
  ( -- * Creating a Request
    DisassociateElasticIp (..),
    newDisassociateElasticIp,

    -- * Request Lenses
    disassociateElasticIp_elasticIp,

    -- * Destructuring the Response
    DisassociateElasticIpResponse (..),
    newDisassociateElasticIpResponse,
  )
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:/ 'newDisassociateElasticIp' smart constructor.
data DisassociateElasticIp = DisassociateElasticIp'
  { -- | The Elastic IP address.
    DisassociateElasticIp -> Text
elasticIp :: Prelude.Text
  }
  deriving (DisassociateElasticIp -> DisassociateElasticIp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateElasticIp -> DisassociateElasticIp -> Bool
$c/= :: DisassociateElasticIp -> DisassociateElasticIp -> Bool
== :: DisassociateElasticIp -> DisassociateElasticIp -> Bool
$c== :: DisassociateElasticIp -> DisassociateElasticIp -> Bool
Prelude.Eq, ReadPrec [DisassociateElasticIp]
ReadPrec DisassociateElasticIp
Int -> ReadS DisassociateElasticIp
ReadS [DisassociateElasticIp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateElasticIp]
$creadListPrec :: ReadPrec [DisassociateElasticIp]
readPrec :: ReadPrec DisassociateElasticIp
$creadPrec :: ReadPrec DisassociateElasticIp
readList :: ReadS [DisassociateElasticIp]
$creadList :: ReadS [DisassociateElasticIp]
readsPrec :: Int -> ReadS DisassociateElasticIp
$creadsPrec :: Int -> ReadS DisassociateElasticIp
Prelude.Read, Int -> DisassociateElasticIp -> ShowS
[DisassociateElasticIp] -> ShowS
DisassociateElasticIp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateElasticIp] -> ShowS
$cshowList :: [DisassociateElasticIp] -> ShowS
show :: DisassociateElasticIp -> String
$cshow :: DisassociateElasticIp -> String
showsPrec :: Int -> DisassociateElasticIp -> ShowS
$cshowsPrec :: Int -> DisassociateElasticIp -> ShowS
Prelude.Show, forall x. Rep DisassociateElasticIp x -> DisassociateElasticIp
forall x. DisassociateElasticIp -> Rep DisassociateElasticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateElasticIp x -> DisassociateElasticIp
$cfrom :: forall x. DisassociateElasticIp -> Rep DisassociateElasticIp x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateElasticIp' 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:
--
-- 'elasticIp', 'disassociateElasticIp_elasticIp' - The Elastic IP address.
newDisassociateElasticIp ::
  -- | 'elasticIp'
  Prelude.Text ->
  DisassociateElasticIp
newDisassociateElasticIp :: Text -> DisassociateElasticIp
newDisassociateElasticIp Text
pElasticIp_ =
  DisassociateElasticIp' {$sel:elasticIp:DisassociateElasticIp' :: Text
elasticIp = Text
pElasticIp_}

-- | The Elastic IP address.
disassociateElasticIp_elasticIp :: Lens.Lens' DisassociateElasticIp Prelude.Text
disassociateElasticIp_elasticIp :: Lens' DisassociateElasticIp Text
disassociateElasticIp_elasticIp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateElasticIp' {Text
elasticIp :: Text
$sel:elasticIp:DisassociateElasticIp' :: DisassociateElasticIp -> Text
elasticIp} -> Text
elasticIp) (\s :: DisassociateElasticIp
s@DisassociateElasticIp' {} Text
a -> DisassociateElasticIp
s {$sel:elasticIp:DisassociateElasticIp' :: Text
elasticIp = Text
a} :: DisassociateElasticIp)

instance Core.AWSRequest DisassociateElasticIp where
  type
    AWSResponse DisassociateElasticIp =
      DisassociateElasticIpResponse
  request :: (Service -> Service)
-> DisassociateElasticIp -> Request DisassociateElasticIp
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 DisassociateElasticIp
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateElasticIp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DisassociateElasticIpResponse
DisassociateElasticIpResponse'

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

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

instance Data.ToHeaders DisassociateElasticIp where
  toHeaders :: DisassociateElasticIp -> [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.DisassociateElasticIp" ::
                          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 DisassociateElasticIp where
  toJSON :: DisassociateElasticIp -> Value
toJSON DisassociateElasticIp' {Text
elasticIp :: Text
$sel:elasticIp:DisassociateElasticIp' :: DisassociateElasticIp -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ElasticIp" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
elasticIp)]
      )

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

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

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

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

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