{-# 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.GetStaticIp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns information about an Amazon Lightsail static IP.
module Amazonka.Lightsail.GetStaticIp
  ( -- * Creating a Request
    GetStaticIp (..),
    newGetStaticIp,

    -- * Request Lenses
    getStaticIp_staticIpName,

    -- * Destructuring the Response
    GetStaticIpResponse (..),
    newGetStaticIpResponse,

    -- * Response Lenses
    getStaticIpResponse_staticIp,
    getStaticIpResponse_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:/ 'newGetStaticIp' smart constructor.
data GetStaticIp = GetStaticIp'
  { -- | The name of the static IP in Lightsail.
    GetStaticIp -> Text
staticIpName :: Prelude.Text
  }
  deriving (GetStaticIp -> GetStaticIp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStaticIp -> GetStaticIp -> Bool
$c/= :: GetStaticIp -> GetStaticIp -> Bool
== :: GetStaticIp -> GetStaticIp -> Bool
$c== :: GetStaticIp -> GetStaticIp -> Bool
Prelude.Eq, ReadPrec [GetStaticIp]
ReadPrec GetStaticIp
Int -> ReadS GetStaticIp
ReadS [GetStaticIp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStaticIp]
$creadListPrec :: ReadPrec [GetStaticIp]
readPrec :: ReadPrec GetStaticIp
$creadPrec :: ReadPrec GetStaticIp
readList :: ReadS [GetStaticIp]
$creadList :: ReadS [GetStaticIp]
readsPrec :: Int -> ReadS GetStaticIp
$creadsPrec :: Int -> ReadS GetStaticIp
Prelude.Read, Int -> GetStaticIp -> ShowS
[GetStaticIp] -> ShowS
GetStaticIp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStaticIp] -> ShowS
$cshowList :: [GetStaticIp] -> ShowS
show :: GetStaticIp -> String
$cshow :: GetStaticIp -> String
showsPrec :: Int -> GetStaticIp -> ShowS
$cshowsPrec :: Int -> GetStaticIp -> ShowS
Prelude.Show, forall x. Rep GetStaticIp x -> GetStaticIp
forall x. GetStaticIp -> Rep GetStaticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStaticIp x -> GetStaticIp
$cfrom :: forall x. GetStaticIp -> Rep GetStaticIp x
Prelude.Generic)

-- |
-- Create a value of 'GetStaticIp' 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', 'getStaticIp_staticIpName' - The name of the static IP in Lightsail.
newGetStaticIp ::
  -- | 'staticIpName'
  Prelude.Text ->
  GetStaticIp
newGetStaticIp :: Text -> GetStaticIp
newGetStaticIp Text
pStaticIpName_ =
  GetStaticIp' {$sel:staticIpName:GetStaticIp' :: Text
staticIpName = Text
pStaticIpName_}

-- | The name of the static IP in Lightsail.
getStaticIp_staticIpName :: Lens.Lens' GetStaticIp Prelude.Text
getStaticIp_staticIpName :: Lens' GetStaticIp Text
getStaticIp_staticIpName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:GetStaticIp' :: GetStaticIp -> Text
staticIpName} -> Text
staticIpName) (\s :: GetStaticIp
s@GetStaticIp' {} Text
a -> GetStaticIp
s {$sel:staticIpName:GetStaticIp' :: Text
staticIpName = Text
a} :: GetStaticIp)

instance Core.AWSRequest GetStaticIp where
  type AWSResponse GetStaticIp = GetStaticIpResponse
  request :: (Service -> Service) -> GetStaticIp -> Request GetStaticIp
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 GetStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStaticIp)))
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 StaticIp -> Int -> GetStaticIpResponse
GetStaticIpResponse'
            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
"staticIp")
            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 GetStaticIp where
  hashWithSalt :: Int -> GetStaticIp -> Int
hashWithSalt Int
_salt GetStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:GetStaticIp' :: GetStaticIp -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
staticIpName

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

instance Data.ToHeaders GetStaticIp where
  toHeaders :: GetStaticIp -> 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.GetStaticIp" ::
                          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 GetStaticIp where
  toJSON :: GetStaticIp -> Value
toJSON GetStaticIp' {Text
staticIpName :: Text
$sel:staticIpName:GetStaticIp' :: GetStaticIp -> 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 GetStaticIp where
  toPath :: GetStaticIp -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newGetStaticIpResponse' smart constructor.
data GetStaticIpResponse = GetStaticIpResponse'
  { -- | An array of key-value pairs containing information about the requested
    -- static IP.
    GetStaticIpResponse -> Maybe StaticIp
staticIp :: Prelude.Maybe StaticIp,
    -- | The response's http status code.
    GetStaticIpResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStaticIpResponse -> GetStaticIpResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStaticIpResponse -> GetStaticIpResponse -> Bool
$c/= :: GetStaticIpResponse -> GetStaticIpResponse -> Bool
== :: GetStaticIpResponse -> GetStaticIpResponse -> Bool
$c== :: GetStaticIpResponse -> GetStaticIpResponse -> Bool
Prelude.Eq, ReadPrec [GetStaticIpResponse]
ReadPrec GetStaticIpResponse
Int -> ReadS GetStaticIpResponse
ReadS [GetStaticIpResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStaticIpResponse]
$creadListPrec :: ReadPrec [GetStaticIpResponse]
readPrec :: ReadPrec GetStaticIpResponse
$creadPrec :: ReadPrec GetStaticIpResponse
readList :: ReadS [GetStaticIpResponse]
$creadList :: ReadS [GetStaticIpResponse]
readsPrec :: Int -> ReadS GetStaticIpResponse
$creadsPrec :: Int -> ReadS GetStaticIpResponse
Prelude.Read, Int -> GetStaticIpResponse -> ShowS
[GetStaticIpResponse] -> ShowS
GetStaticIpResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStaticIpResponse] -> ShowS
$cshowList :: [GetStaticIpResponse] -> ShowS
show :: GetStaticIpResponse -> String
$cshow :: GetStaticIpResponse -> String
showsPrec :: Int -> GetStaticIpResponse -> ShowS
$cshowsPrec :: Int -> GetStaticIpResponse -> ShowS
Prelude.Show, forall x. Rep GetStaticIpResponse x -> GetStaticIpResponse
forall x. GetStaticIpResponse -> Rep GetStaticIpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStaticIpResponse x -> GetStaticIpResponse
$cfrom :: forall x. GetStaticIpResponse -> Rep GetStaticIpResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStaticIpResponse' 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:
--
-- 'staticIp', 'getStaticIpResponse_staticIp' - An array of key-value pairs containing information about the requested
-- static IP.
--
-- 'httpStatus', 'getStaticIpResponse_httpStatus' - The response's http status code.
newGetStaticIpResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStaticIpResponse
newGetStaticIpResponse :: Int -> GetStaticIpResponse
newGetStaticIpResponse Int
pHttpStatus_ =
  GetStaticIpResponse'
    { $sel:staticIp:GetStaticIpResponse' :: Maybe StaticIp
staticIp = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetStaticIpResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of key-value pairs containing information about the requested
-- static IP.
getStaticIpResponse_staticIp :: Lens.Lens' GetStaticIpResponse (Prelude.Maybe StaticIp)
getStaticIpResponse_staticIp :: Lens' GetStaticIpResponse (Maybe StaticIp)
getStaticIpResponse_staticIp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIpResponse' {Maybe StaticIp
staticIp :: Maybe StaticIp
$sel:staticIp:GetStaticIpResponse' :: GetStaticIpResponse -> Maybe StaticIp
staticIp} -> Maybe StaticIp
staticIp) (\s :: GetStaticIpResponse
s@GetStaticIpResponse' {} Maybe StaticIp
a -> GetStaticIpResponse
s {$sel:staticIp:GetStaticIpResponse' :: Maybe StaticIp
staticIp = Maybe StaticIp
a} :: GetStaticIpResponse)

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

instance Prelude.NFData GetStaticIpResponse where
  rnf :: GetStaticIpResponse -> ()
rnf GetStaticIpResponse' {Int
Maybe StaticIp
httpStatus :: Int
staticIp :: Maybe StaticIp
$sel:httpStatus:GetStaticIpResponse' :: GetStaticIpResponse -> Int
$sel:staticIp:GetStaticIpResponse' :: GetStaticIpResponse -> Maybe StaticIp
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StaticIp
staticIp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus