{-# 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-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)
--
-- 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.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:/ 'newGetStaticIp' smart constructor.
data GetStaticIp = GetStaticIp'
  { -- | The name of the static IP in Lightsail.
    GetStaticIp -> Text
staticIpName :: Prelude.Text
  }
  deriving (GetStaticIp -> GetStaticIp -> Bool
(GetStaticIp -> GetStaticIp -> Bool)
-> (GetStaticIp -> GetStaticIp -> Bool) -> Eq GetStaticIp
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]
(Int -> ReadS GetStaticIp)
-> ReadS [GetStaticIp]
-> ReadPrec GetStaticIp
-> ReadPrec [GetStaticIp]
-> Read 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
(Int -> GetStaticIp -> ShowS)
-> (GetStaticIp -> String)
-> ([GetStaticIp] -> ShowS)
-> Show GetStaticIp
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. GetStaticIp -> Rep GetStaticIp x)
-> (forall x. Rep GetStaticIp x -> GetStaticIp)
-> Generic GetStaticIp
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' :: Text -> GetStaticIp
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 :: (Text -> f Text) -> GetStaticIp -> f GetStaticIp
getStaticIp_staticIpName = (GetStaticIp -> Text)
-> (GetStaticIp -> Text -> GetStaticIp)
-> Lens GetStaticIp GetStaticIp Text Text
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 :: GetStaticIp -> Request GetStaticIp
request = Service -> GetStaticIp -> Request GetStaticIp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStaticIp)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetStaticIp))
-> Logger
-> Service
-> Proxy GetStaticIp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStaticIp)))
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 StaticIp -> Int -> GetStaticIpResponse
GetStaticIpResponse'
            (Maybe StaticIp -> Int -> GetStaticIpResponse)
-> Either String (Maybe StaticIp)
-> Either String (Int -> GetStaticIpResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe StaticIp)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"staticIp")
            Either String (Int -> GetStaticIpResponse)
-> Either String Int -> Either String GetStaticIpResponse
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 GetStaticIp

instance Prelude.NFData GetStaticIp

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

instance Core.ToQuery GetStaticIp where
  toQuery :: GetStaticIp -> QueryString
toQuery = QueryString -> GetStaticIp -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetStaticIpResponse -> GetStaticIpResponse -> Bool)
-> (GetStaticIpResponse -> GetStaticIpResponse -> Bool)
-> Eq GetStaticIpResponse
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]
(Int -> ReadS GetStaticIpResponse)
-> ReadS [GetStaticIpResponse]
-> ReadPrec GetStaticIpResponse
-> ReadPrec [GetStaticIpResponse]
-> Read 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
(Int -> GetStaticIpResponse -> ShowS)
-> (GetStaticIpResponse -> String)
-> ([GetStaticIpResponse] -> ShowS)
-> Show GetStaticIpResponse
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. GetStaticIpResponse -> Rep GetStaticIpResponse x)
-> (forall x. Rep GetStaticIpResponse x -> GetStaticIpResponse)
-> Generic GetStaticIpResponse
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' :: Maybe StaticIp -> Int -> GetStaticIpResponse
GetStaticIpResponse'
    { $sel:staticIp:GetStaticIpResponse' :: Maybe StaticIp
staticIp = Maybe 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 :: (Maybe StaticIp -> f (Maybe StaticIp))
-> GetStaticIpResponse -> f GetStaticIpResponse
getStaticIpResponse_staticIp = (GetStaticIpResponse -> Maybe StaticIp)
-> (GetStaticIpResponse -> Maybe StaticIp -> GetStaticIpResponse)
-> Lens
     GetStaticIpResponse
     GetStaticIpResponse
     (Maybe StaticIp)
     (Maybe 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 :: (Int -> f Int) -> GetStaticIpResponse -> f GetStaticIpResponse
getStaticIpResponse_httpStatus = (GetStaticIpResponse -> Int)
-> (GetStaticIpResponse -> Int -> GetStaticIpResponse)
-> Lens GetStaticIpResponse GetStaticIpResponse Int Int
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