{-# 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.GetStaticIps
-- 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 all static IPs in the user\'s account.
--
-- This operation returns paginated results.
module Amazonka.Lightsail.GetStaticIps
  ( -- * Creating a Request
    GetStaticIps (..),
    newGetStaticIps,

    -- * Request Lenses
    getStaticIps_pageToken,

    -- * Destructuring the Response
    GetStaticIpsResponse (..),
    newGetStaticIpsResponse,

    -- * Response Lenses
    getStaticIpsResponse_nextPageToken,
    getStaticIpsResponse_staticIps,
    getStaticIpsResponse_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:/ 'newGetStaticIps' smart constructor.
data GetStaticIps = GetStaticIps'
  { -- | The token to advance to the next page of results from your request.
    --
    -- To get a page token, perform an initial @GetStaticIps@ request. If your
    -- results are paginated, the response will return a next page token that
    -- you can specify as the page token in a subsequent request.
    GetStaticIps -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text
  }
  deriving (GetStaticIps -> GetStaticIps -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStaticIps -> GetStaticIps -> Bool
$c/= :: GetStaticIps -> GetStaticIps -> Bool
== :: GetStaticIps -> GetStaticIps -> Bool
$c== :: GetStaticIps -> GetStaticIps -> Bool
Prelude.Eq, ReadPrec [GetStaticIps]
ReadPrec GetStaticIps
Int -> ReadS GetStaticIps
ReadS [GetStaticIps]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStaticIps]
$creadListPrec :: ReadPrec [GetStaticIps]
readPrec :: ReadPrec GetStaticIps
$creadPrec :: ReadPrec GetStaticIps
readList :: ReadS [GetStaticIps]
$creadList :: ReadS [GetStaticIps]
readsPrec :: Int -> ReadS GetStaticIps
$creadsPrec :: Int -> ReadS GetStaticIps
Prelude.Read, Int -> GetStaticIps -> ShowS
[GetStaticIps] -> ShowS
GetStaticIps -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStaticIps] -> ShowS
$cshowList :: [GetStaticIps] -> ShowS
show :: GetStaticIps -> String
$cshow :: GetStaticIps -> String
showsPrec :: Int -> GetStaticIps -> ShowS
$cshowsPrec :: Int -> GetStaticIps -> ShowS
Prelude.Show, forall x. Rep GetStaticIps x -> GetStaticIps
forall x. GetStaticIps -> Rep GetStaticIps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStaticIps x -> GetStaticIps
$cfrom :: forall x. GetStaticIps -> Rep GetStaticIps x
Prelude.Generic)

-- |
-- Create a value of 'GetStaticIps' 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:
--
-- 'pageToken', 'getStaticIps_pageToken' - The token to advance to the next page of results from your request.
--
-- To get a page token, perform an initial @GetStaticIps@ request. If your
-- results are paginated, the response will return a next page token that
-- you can specify as the page token in a subsequent request.
newGetStaticIps ::
  GetStaticIps
newGetStaticIps :: GetStaticIps
newGetStaticIps =
  GetStaticIps' {$sel:pageToken:GetStaticIps' :: Maybe Text
pageToken = forall a. Maybe a
Prelude.Nothing}

-- | The token to advance to the next page of results from your request.
--
-- To get a page token, perform an initial @GetStaticIps@ request. If your
-- results are paginated, the response will return a next page token that
-- you can specify as the page token in a subsequent request.
getStaticIps_pageToken :: Lens.Lens' GetStaticIps (Prelude.Maybe Prelude.Text)
getStaticIps_pageToken :: Lens' GetStaticIps (Maybe Text)
getStaticIps_pageToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIps' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetStaticIps' :: GetStaticIps -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: GetStaticIps
s@GetStaticIps' {} Maybe Text
a -> GetStaticIps
s {$sel:pageToken:GetStaticIps' :: Maybe Text
pageToken = Maybe Text
a} :: GetStaticIps)

instance Core.AWSPager GetStaticIps where
  page :: GetStaticIps -> AWSResponse GetStaticIps -> Maybe GetStaticIps
page GetStaticIps
rq AWSResponse GetStaticIps
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetStaticIps
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetStaticIpsResponse (Maybe Text)
getStaticIpsResponse_nextPageToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetStaticIps
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetStaticIpsResponse (Maybe [StaticIp])
getStaticIpsResponse_staticIps
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ GetStaticIps
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetStaticIps (Maybe Text)
getStaticIps_pageToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetStaticIps
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetStaticIpsResponse (Maybe Text)
getStaticIpsResponse_nextPageToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetStaticIps where
  type AWSResponse GetStaticIps = GetStaticIpsResponse
  request :: (Service -> Service) -> GetStaticIps -> Request GetStaticIps
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 GetStaticIps
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetStaticIps)))
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 Text -> Maybe [StaticIp] -> Int -> GetStaticIpsResponse
GetStaticIpsResponse'
            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
"nextPageToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"staticIps" 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 GetStaticIps where
  hashWithSalt :: Int -> GetStaticIps -> Int
hashWithSalt Int
_salt GetStaticIps' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetStaticIps' :: GetStaticIps -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pageToken

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

instance Data.ToHeaders GetStaticIps where
  toHeaders :: GetStaticIps -> 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.GetStaticIps" ::
                          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 GetStaticIps where
  toJSON :: GetStaticIps -> Value
toJSON GetStaticIps' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetStaticIps' :: GetStaticIps -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"pageToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
pageToken]
      )

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

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

-- | /See:/ 'newGetStaticIpsResponse' smart constructor.
data GetStaticIpsResponse = GetStaticIpsResponse'
  { -- | The token to advance to the next page of results from your request.
    --
    -- A next page token is not returned if there are no more results to
    -- display.
    --
    -- To get the next page of results, perform another @GetStaticIps@ request
    -- and specify the next page token using the @pageToken@ parameter.
    GetStaticIpsResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | An array of key-value pairs containing information about your get static
    -- IPs request.
    GetStaticIpsResponse -> Maybe [StaticIp]
staticIps :: Prelude.Maybe [StaticIp],
    -- | The response's http status code.
    GetStaticIpsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetStaticIpsResponse -> GetStaticIpsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetStaticIpsResponse -> GetStaticIpsResponse -> Bool
$c/= :: GetStaticIpsResponse -> GetStaticIpsResponse -> Bool
== :: GetStaticIpsResponse -> GetStaticIpsResponse -> Bool
$c== :: GetStaticIpsResponse -> GetStaticIpsResponse -> Bool
Prelude.Eq, ReadPrec [GetStaticIpsResponse]
ReadPrec GetStaticIpsResponse
Int -> ReadS GetStaticIpsResponse
ReadS [GetStaticIpsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetStaticIpsResponse]
$creadListPrec :: ReadPrec [GetStaticIpsResponse]
readPrec :: ReadPrec GetStaticIpsResponse
$creadPrec :: ReadPrec GetStaticIpsResponse
readList :: ReadS [GetStaticIpsResponse]
$creadList :: ReadS [GetStaticIpsResponse]
readsPrec :: Int -> ReadS GetStaticIpsResponse
$creadsPrec :: Int -> ReadS GetStaticIpsResponse
Prelude.Read, Int -> GetStaticIpsResponse -> ShowS
[GetStaticIpsResponse] -> ShowS
GetStaticIpsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetStaticIpsResponse] -> ShowS
$cshowList :: [GetStaticIpsResponse] -> ShowS
show :: GetStaticIpsResponse -> String
$cshow :: GetStaticIpsResponse -> String
showsPrec :: Int -> GetStaticIpsResponse -> ShowS
$cshowsPrec :: Int -> GetStaticIpsResponse -> ShowS
Prelude.Show, forall x. Rep GetStaticIpsResponse x -> GetStaticIpsResponse
forall x. GetStaticIpsResponse -> Rep GetStaticIpsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetStaticIpsResponse x -> GetStaticIpsResponse
$cfrom :: forall x. GetStaticIpsResponse -> Rep GetStaticIpsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetStaticIpsResponse' 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:
--
-- 'nextPageToken', 'getStaticIpsResponse_nextPageToken' - The token to advance to the next page of results from your request.
--
-- A next page token is not returned if there are no more results to
-- display.
--
-- To get the next page of results, perform another @GetStaticIps@ request
-- and specify the next page token using the @pageToken@ parameter.
--
-- 'staticIps', 'getStaticIpsResponse_staticIps' - An array of key-value pairs containing information about your get static
-- IPs request.
--
-- 'httpStatus', 'getStaticIpsResponse_httpStatus' - The response's http status code.
newGetStaticIpsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetStaticIpsResponse
newGetStaticIpsResponse :: Int -> GetStaticIpsResponse
newGetStaticIpsResponse Int
pHttpStatus_ =
  GetStaticIpsResponse'
    { $sel:nextPageToken:GetStaticIpsResponse' :: Maybe Text
nextPageToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:staticIps:GetStaticIpsResponse' :: Maybe [StaticIp]
staticIps = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetStaticIpsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to advance to the next page of results from your request.
--
-- A next page token is not returned if there are no more results to
-- display.
--
-- To get the next page of results, perform another @GetStaticIps@ request
-- and specify the next page token using the @pageToken@ parameter.
getStaticIpsResponse_nextPageToken :: Lens.Lens' GetStaticIpsResponse (Prelude.Maybe Prelude.Text)
getStaticIpsResponse_nextPageToken :: Lens' GetStaticIpsResponse (Maybe Text)
getStaticIpsResponse_nextPageToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIpsResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetStaticIpsResponse' :: GetStaticIpsResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetStaticIpsResponse
s@GetStaticIpsResponse' {} Maybe Text
a -> GetStaticIpsResponse
s {$sel:nextPageToken:GetStaticIpsResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetStaticIpsResponse)

-- | An array of key-value pairs containing information about your get static
-- IPs request.
getStaticIpsResponse_staticIps :: Lens.Lens' GetStaticIpsResponse (Prelude.Maybe [StaticIp])
getStaticIpsResponse_staticIps :: Lens' GetStaticIpsResponse (Maybe [StaticIp])
getStaticIpsResponse_staticIps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIpsResponse' {Maybe [StaticIp]
staticIps :: Maybe [StaticIp]
$sel:staticIps:GetStaticIpsResponse' :: GetStaticIpsResponse -> Maybe [StaticIp]
staticIps} -> Maybe [StaticIp]
staticIps) (\s :: GetStaticIpsResponse
s@GetStaticIpsResponse' {} Maybe [StaticIp]
a -> GetStaticIpsResponse
s {$sel:staticIps:GetStaticIpsResponse' :: Maybe [StaticIp]
staticIps = Maybe [StaticIp]
a} :: GetStaticIpsResponse) 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.
getStaticIpsResponse_httpStatus :: Lens.Lens' GetStaticIpsResponse Prelude.Int
getStaticIpsResponse_httpStatus :: Lens' GetStaticIpsResponse Int
getStaticIpsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetStaticIpsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetStaticIpsResponse' :: GetStaticIpsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetStaticIpsResponse
s@GetStaticIpsResponse' {} Int
a -> GetStaticIpsResponse
s {$sel:httpStatus:GetStaticIpsResponse' :: Int
httpStatus = Int
a} :: GetStaticIpsResponse)

instance Prelude.NFData GetStaticIpsResponse where
  rnf :: GetStaticIpsResponse -> ()
rnf GetStaticIpsResponse' {Int
Maybe [StaticIp]
Maybe Text
httpStatus :: Int
staticIps :: Maybe [StaticIp]
nextPageToken :: Maybe Text
$sel:httpStatus:GetStaticIpsResponse' :: GetStaticIpsResponse -> Int
$sel:staticIps:GetStaticIpsResponse' :: GetStaticIpsResponse -> Maybe [StaticIp]
$sel:nextPageToken:GetStaticIpsResponse' :: GetStaticIpsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextPageToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [StaticIp]
staticIps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus