{-# 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.DeregisterElasticIp
-- 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 a specified Elastic IP address. The address 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.DeregisterElasticIp
  ( -- * Creating a Request
    DeregisterElasticIp (..),
    newDeregisterElasticIp,

    -- * Request Lenses
    deregisterElasticIp_elasticIp,

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

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

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

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

instance Prelude.Hashable DeregisterElasticIp

instance Prelude.NFData DeregisterElasticIp

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

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

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

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

instance Prelude.NFData DeregisterElasticIpResponse