{-# 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-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)
--
-- 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.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:/ 'newDisassociateElasticIp' smart constructor.
data DisassociateElasticIp = DisassociateElasticIp'
  { -- | The Elastic IP address.
    DisassociateElasticIp -> Text
elasticIp :: Prelude.Text
  }
  deriving (DisassociateElasticIp -> DisassociateElasticIp -> Bool
(DisassociateElasticIp -> DisassociateElasticIp -> Bool)
-> (DisassociateElasticIp -> DisassociateElasticIp -> Bool)
-> Eq DisassociateElasticIp
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]
(Int -> ReadS DisassociateElasticIp)
-> ReadS [DisassociateElasticIp]
-> ReadPrec DisassociateElasticIp
-> ReadPrec [DisassociateElasticIp]
-> Read 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
(Int -> DisassociateElasticIp -> ShowS)
-> (DisassociateElasticIp -> String)
-> ([DisassociateElasticIp] -> ShowS)
-> Show DisassociateElasticIp
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. DisassociateElasticIp -> Rep DisassociateElasticIp x)
-> (forall x. Rep DisassociateElasticIp x -> DisassociateElasticIp)
-> Generic DisassociateElasticIp
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' :: Text -> DisassociateElasticIp
DisassociateElasticIp' {$sel:elasticIp:DisassociateElasticIp' :: Text
elasticIp = Text
pElasticIp_}

-- | The Elastic IP address.
disassociateElasticIp_elasticIp :: Lens.Lens' DisassociateElasticIp Prelude.Text
disassociateElasticIp_elasticIp :: (Text -> f Text)
-> DisassociateElasticIp -> f DisassociateElasticIp
disassociateElasticIp_elasticIp = (DisassociateElasticIp -> Text)
-> (DisassociateElasticIp -> Text -> DisassociateElasticIp)
-> Lens DisassociateElasticIp DisassociateElasticIp Text Text
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 :: DisassociateElasticIp -> Request DisassociateElasticIp
request = Service -> DisassociateElasticIp -> Request DisassociateElasticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateElasticIp
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateElasticIp)))
response =
    AWSResponse DisassociateElasticIp
-> Logger
-> Service
-> Proxy DisassociateElasticIp
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateElasticIp)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DisassociateElasticIp
DisassociateElasticIpResponse
DisassociateElasticIpResponse'

instance Prelude.Hashable DisassociateElasticIp

instance Prelude.NFData DisassociateElasticIp

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

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

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

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