{-# 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.Lightsail.ReleaseStaticIp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a specific static IP from your account.
module Amazonka.Lightsail.ReleaseStaticIp
  ( -- * Creating a Request
    ReleaseStaticIp (..),
    newReleaseStaticIp,

    -- * Request Lenses
    releaseStaticIp_staticIpName,

    -- * Destructuring the Response
    ReleaseStaticIpResponse (..),
    newReleaseStaticIpResponse,

    -- * Response Lenses
    releaseStaticIpResponse_operations,
    releaseStaticIpResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newReleaseStaticIp' smart constructor.
data ReleaseStaticIp = ReleaseStaticIp'
  { -- | The name of the static IP to delete.
    ReleaseStaticIp -> Text
staticIpName :: Prelude.Text
  }
  deriving (ReleaseStaticIp -> ReleaseStaticIp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReleaseStaticIp -> ReleaseStaticIp -> Bool
$c/= :: ReleaseStaticIp -> ReleaseStaticIp -> Bool
== :: ReleaseStaticIp -> ReleaseStaticIp -> Bool
$c== :: ReleaseStaticIp -> ReleaseStaticIp -> Bool
Prelude.Eq, ReadPrec [ReleaseStaticIp]
ReadPrec ReleaseStaticIp
Int -> ReadS ReleaseStaticIp
ReadS [ReleaseStaticIp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReleaseStaticIp]
$creadListPrec :: ReadPrec [ReleaseStaticIp]
readPrec :: ReadPrec ReleaseStaticIp
$creadPrec :: ReadPrec ReleaseStaticIp
readList :: ReadS [ReleaseStaticIp]
$creadList :: ReadS [ReleaseStaticIp]
readsPrec :: Int -> ReadS ReleaseStaticIp
$creadsPrec :: Int -> ReadS ReleaseStaticIp
Prelude.Read, Int -> ReleaseStaticIp -> ShowS
[ReleaseStaticIp] -> ShowS
ReleaseStaticIp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReleaseStaticIp] -> ShowS
$cshowList :: [ReleaseStaticIp] -> ShowS
show :: ReleaseStaticIp -> String
$cshow :: ReleaseStaticIp -> String
showsPrec :: Int -> ReleaseStaticIp -> ShowS
$cshowsPrec :: Int -> ReleaseStaticIp -> ShowS
Prelude.Show, forall x. Rep ReleaseStaticIp x -> ReleaseStaticIp
forall x. ReleaseStaticIp -> Rep ReleaseStaticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReleaseStaticIp x -> ReleaseStaticIp
$cfrom :: forall x. ReleaseStaticIp -> Rep ReleaseStaticIp x
Prelude.Generic)

-- |
-- Create a value of 'ReleaseStaticIp' 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:
--
-- 'staticIpName', 'releaseStaticIp_staticIpName' - The name of the static IP to delete.
newReleaseStaticIp ::
  -- | 'staticIpName'
  Prelude.Text ->
  ReleaseStaticIp
newReleaseStaticIp :: Text -> ReleaseStaticIp
newReleaseStaticIp Text
pStaticIpName_ =
  ReleaseStaticIp' {$sel:staticIpName:ReleaseStaticIp' :: Text
staticIpName = Text
pStaticIpName_}

-- | The name of the static IP to delete.
releaseStaticIp_staticIpName :: Lens.Lens' ReleaseStaticIp Prelude.Text
releaseStaticIp_staticIpName :: Lens' ReleaseStaticIp Text
releaseStaticIp_staticIpName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReleaseStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:ReleaseStaticIp' :: ReleaseStaticIp -> Text
staticIpName} -> Text
staticIpName) (\s :: ReleaseStaticIp
s@ReleaseStaticIp' {} Text
a -> ReleaseStaticIp
s {$sel:staticIpName:ReleaseStaticIp' :: Text
staticIpName = Text
a} :: ReleaseStaticIp)

instance Core.AWSRequest ReleaseStaticIp where
  type
    AWSResponse ReleaseStaticIp =
      ReleaseStaticIpResponse
  request :: (Service -> Service) -> ReleaseStaticIp -> Request ReleaseStaticIp
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 ReleaseStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReleaseStaticIp)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> ReleaseStaticIpResponse
ReleaseStaticIpResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

instance Data.ToHeaders ReleaseStaticIp where
  toHeaders :: ReleaseStaticIp -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.ReleaseStaticIp" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ReleaseStaticIp where
  toJSON :: ReleaseStaticIp -> Value
toJSON ReleaseStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:ReleaseStaticIp' :: ReleaseStaticIp -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"staticIpName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
staticIpName)]
      )

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

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

-- | /See:/ 'newReleaseStaticIpResponse' smart constructor.
data ReleaseStaticIpResponse = ReleaseStaticIpResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    ReleaseStaticIpResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    ReleaseStaticIpResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool
$c/= :: ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool
== :: ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool
$c== :: ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool
Prelude.Eq, ReadPrec [ReleaseStaticIpResponse]
ReadPrec ReleaseStaticIpResponse
Int -> ReadS ReleaseStaticIpResponse
ReadS [ReleaseStaticIpResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReleaseStaticIpResponse]
$creadListPrec :: ReadPrec [ReleaseStaticIpResponse]
readPrec :: ReadPrec ReleaseStaticIpResponse
$creadPrec :: ReadPrec ReleaseStaticIpResponse
readList :: ReadS [ReleaseStaticIpResponse]
$creadList :: ReadS [ReleaseStaticIpResponse]
readsPrec :: Int -> ReadS ReleaseStaticIpResponse
$creadsPrec :: Int -> ReadS ReleaseStaticIpResponse
Prelude.Read, Int -> ReleaseStaticIpResponse -> ShowS
[ReleaseStaticIpResponse] -> ShowS
ReleaseStaticIpResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReleaseStaticIpResponse] -> ShowS
$cshowList :: [ReleaseStaticIpResponse] -> ShowS
show :: ReleaseStaticIpResponse -> String
$cshow :: ReleaseStaticIpResponse -> String
showsPrec :: Int -> ReleaseStaticIpResponse -> ShowS
$cshowsPrec :: Int -> ReleaseStaticIpResponse -> ShowS
Prelude.Show, forall x. Rep ReleaseStaticIpResponse x -> ReleaseStaticIpResponse
forall x. ReleaseStaticIpResponse -> Rep ReleaseStaticIpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReleaseStaticIpResponse x -> ReleaseStaticIpResponse
$cfrom :: forall x. ReleaseStaticIpResponse -> Rep ReleaseStaticIpResponse x
Prelude.Generic)

-- |
-- Create a value of 'ReleaseStaticIpResponse' 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:
--
-- 'operations', 'releaseStaticIpResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'releaseStaticIpResponse_httpStatus' - The response's http status code.
newReleaseStaticIpResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ReleaseStaticIpResponse
newReleaseStaticIpResponse :: Int -> ReleaseStaticIpResponse
newReleaseStaticIpResponse Int
pHttpStatus_ =
  ReleaseStaticIpResponse'
    { $sel:operations:ReleaseStaticIpResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ReleaseStaticIpResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
releaseStaticIpResponse_operations :: Lens.Lens' ReleaseStaticIpResponse (Prelude.Maybe [Operation])
releaseStaticIpResponse_operations :: Lens' ReleaseStaticIpResponse (Maybe [Operation])
releaseStaticIpResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReleaseStaticIpResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:ReleaseStaticIpResponse' :: ReleaseStaticIpResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: ReleaseStaticIpResponse
s@ReleaseStaticIpResponse' {} Maybe [Operation]
a -> ReleaseStaticIpResponse
s {$sel:operations:ReleaseStaticIpResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: ReleaseStaticIpResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
releaseStaticIpResponse_httpStatus :: Lens.Lens' ReleaseStaticIpResponse Prelude.Int
releaseStaticIpResponse_httpStatus :: Lens' ReleaseStaticIpResponse Int
releaseStaticIpResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReleaseStaticIpResponse' {Int
httpStatus :: Int
$sel:httpStatus:ReleaseStaticIpResponse' :: ReleaseStaticIpResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ReleaseStaticIpResponse
s@ReleaseStaticIpResponse' {} Int
a -> ReleaseStaticIpResponse
s {$sel:httpStatus:ReleaseStaticIpResponse' :: Int
httpStatus = Int
a} :: ReleaseStaticIpResponse)

instance Prelude.NFData ReleaseStaticIpResponse where
  rnf :: ReleaseStaticIpResponse -> ()
rnf ReleaseStaticIpResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:ReleaseStaticIpResponse' :: ReleaseStaticIpResponse -> Int
$sel:operations:ReleaseStaticIpResponse' :: ReleaseStaticIpResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus