{-# 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-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)
--
-- 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.Lens as Lens
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
(ReleaseStaticIp -> ReleaseStaticIp -> Bool)
-> (ReleaseStaticIp -> ReleaseStaticIp -> Bool)
-> Eq ReleaseStaticIp
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]
(Int -> ReadS ReleaseStaticIp)
-> ReadS [ReleaseStaticIp]
-> ReadPrec ReleaseStaticIp
-> ReadPrec [ReleaseStaticIp]
-> Read 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
(Int -> ReleaseStaticIp -> ShowS)
-> (ReleaseStaticIp -> String)
-> ([ReleaseStaticIp] -> ShowS)
-> Show ReleaseStaticIp
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. ReleaseStaticIp -> Rep ReleaseStaticIp x)
-> (forall x. Rep ReleaseStaticIp x -> ReleaseStaticIp)
-> Generic ReleaseStaticIp
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' :: Text -> ReleaseStaticIp
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 :: (Text -> f Text) -> ReleaseStaticIp -> f ReleaseStaticIp
releaseStaticIp_staticIpName = (ReleaseStaticIp -> Text)
-> (ReleaseStaticIp -> Text -> ReleaseStaticIp)
-> Lens ReleaseStaticIp ReleaseStaticIp Text Text
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 :: ReleaseStaticIp -> Request ReleaseStaticIp
request = Service -> ReleaseStaticIp -> Request ReleaseStaticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ReleaseStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReleaseStaticIp)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ReleaseStaticIp))
-> Logger
-> Service
-> Proxy ReleaseStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ReleaseStaticIp)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> ReleaseStaticIpResponse
ReleaseStaticIpResponse'
            (Maybe [Operation] -> Int -> ReleaseStaticIpResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> ReleaseStaticIpResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ReleaseStaticIpResponse)
-> Either String Int -> Either String ReleaseStaticIpResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ReleaseStaticIp

instance Prelude.NFData ReleaseStaticIp

instance Core.ToHeaders ReleaseStaticIp where
  toHeaders :: ReleaseStaticIp -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ReleaseStaticIp -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.ReleaseStaticIp" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ReleaseStaticIp where
  toJSON :: ReleaseStaticIp -> Value
toJSON ReleaseStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:ReleaseStaticIp' :: ReleaseStaticIp -> 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
"staticIpName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
staticIpName)]
      )

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

instance Core.ToQuery ReleaseStaticIp where
  toQuery :: ReleaseStaticIp -> QueryString
toQuery = QueryString -> ReleaseStaticIp -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool)
-> (ReleaseStaticIpResponse -> ReleaseStaticIpResponse -> Bool)
-> Eq ReleaseStaticIpResponse
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]
(Int -> ReadS ReleaseStaticIpResponse)
-> ReadS [ReleaseStaticIpResponse]
-> ReadPrec ReleaseStaticIpResponse
-> ReadPrec [ReleaseStaticIpResponse]
-> Read 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
(Int -> ReleaseStaticIpResponse -> ShowS)
-> (ReleaseStaticIpResponse -> String)
-> ([ReleaseStaticIpResponse] -> ShowS)
-> Show ReleaseStaticIpResponse
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.
 ReleaseStaticIpResponse -> Rep ReleaseStaticIpResponse x)
-> (forall x.
    Rep ReleaseStaticIpResponse x -> ReleaseStaticIpResponse)
-> Generic ReleaseStaticIpResponse
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' :: Maybe [Operation] -> Int -> ReleaseStaticIpResponse
ReleaseStaticIpResponse'
    { $sel:operations:ReleaseStaticIpResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
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 :: (Maybe [Operation] -> f (Maybe [Operation]))
-> ReleaseStaticIpResponse -> f ReleaseStaticIpResponse
releaseStaticIpResponse_operations = (ReleaseStaticIpResponse -> Maybe [Operation])
-> (ReleaseStaticIpResponse
    -> Maybe [Operation] -> ReleaseStaticIpResponse)
-> Lens
     ReleaseStaticIpResponse
     ReleaseStaticIpResponse
     (Maybe [Operation])
     (Maybe [Operation])
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) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> ReleaseStaticIpResponse -> f ReleaseStaticIpResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> ReleaseStaticIpResponse
-> f ReleaseStaticIpResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
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 AnIso [Operation] [Operation] [Operation] [Operation]
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 :: (Int -> f Int)
-> ReleaseStaticIpResponse -> f ReleaseStaticIpResponse
releaseStaticIpResponse_httpStatus = (ReleaseStaticIpResponse -> Int)
-> (ReleaseStaticIpResponse -> Int -> ReleaseStaticIpResponse)
-> Lens ReleaseStaticIpResponse ReleaseStaticIpResponse Int Int
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