{-# 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 #-}
module Amazonka.Lightsail.GetInstances
(
GetInstances (..),
newGetInstances,
getInstances_pageToken,
GetInstancesResponse (..),
newGetInstancesResponse,
getInstancesResponse_nextPageToken,
getInstancesResponse_instances,
getInstancesResponse_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
data GetInstances = GetInstances'
{
GetInstances -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text
}
deriving (GetInstances -> GetInstances -> Bool
(GetInstances -> GetInstances -> Bool)
-> (GetInstances -> GetInstances -> Bool) -> Eq GetInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstances -> GetInstances -> Bool
$c/= :: GetInstances -> GetInstances -> Bool
== :: GetInstances -> GetInstances -> Bool
$c== :: GetInstances -> GetInstances -> Bool
Prelude.Eq, ReadPrec [GetInstances]
ReadPrec GetInstances
Int -> ReadS GetInstances
ReadS [GetInstances]
(Int -> ReadS GetInstances)
-> ReadS [GetInstances]
-> ReadPrec GetInstances
-> ReadPrec [GetInstances]
-> Read GetInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstances]
$creadListPrec :: ReadPrec [GetInstances]
readPrec :: ReadPrec GetInstances
$creadPrec :: ReadPrec GetInstances
readList :: ReadS [GetInstances]
$creadList :: ReadS [GetInstances]
readsPrec :: Int -> ReadS GetInstances
$creadsPrec :: Int -> ReadS GetInstances
Prelude.Read, Int -> GetInstances -> ShowS
[GetInstances] -> ShowS
GetInstances -> String
(Int -> GetInstances -> ShowS)
-> (GetInstances -> String)
-> ([GetInstances] -> ShowS)
-> Show GetInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstances] -> ShowS
$cshowList :: [GetInstances] -> ShowS
show :: GetInstances -> String
$cshow :: GetInstances -> String
showsPrec :: Int -> GetInstances -> ShowS
$cshowsPrec :: Int -> GetInstances -> ShowS
Prelude.Show, (forall x. GetInstances -> Rep GetInstances x)
-> (forall x. Rep GetInstances x -> GetInstances)
-> Generic GetInstances
forall x. Rep GetInstances x -> GetInstances
forall x. GetInstances -> Rep GetInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInstances x -> GetInstances
$cfrom :: forall x. GetInstances -> Rep GetInstances x
Prelude.Generic)
newGetInstances ::
GetInstances
newGetInstances :: GetInstances
newGetInstances =
GetInstances' :: Maybe Text -> GetInstances
GetInstances' {$sel:pageToken:GetInstances' :: Maybe Text
pageToken = Maybe Text
forall a. Maybe a
Prelude.Nothing}
getInstances_pageToken :: Lens.Lens' GetInstances (Prelude.Maybe Prelude.Text)
getInstances_pageToken :: (Maybe Text -> f (Maybe Text)) -> GetInstances -> f GetInstances
getInstances_pageToken = (GetInstances -> Maybe Text)
-> (GetInstances -> Maybe Text -> GetInstances)
-> Lens GetInstances GetInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstances' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetInstances' :: GetInstances -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: GetInstances
s@GetInstances' {} Maybe Text
a -> GetInstances
s {$sel:pageToken:GetInstances' :: Maybe Text
pageToken = Maybe Text
a} :: GetInstances)
instance Core.AWSPager GetInstances where
page :: GetInstances -> AWSResponse GetInstances -> Maybe GetInstances
page GetInstances
rq AWSResponse GetInstances
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetInstances
GetInstancesResponse
rs
GetInstancesResponse
-> Getting (First Text) GetInstancesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetInstancesResponse -> Const (First Text) GetInstancesResponse
Lens' GetInstancesResponse (Maybe Text)
getInstancesResponse_nextPageToken
((Maybe Text -> Const (First Text) (Maybe Text))
-> GetInstancesResponse -> Const (First Text) GetInstancesResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe GetInstances
forall a. Maybe a
Prelude.Nothing
| Maybe [Instance] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetInstances
GetInstancesResponse
rs
GetInstancesResponse
-> Getting (First [Instance]) GetInstancesResponse [Instance]
-> Maybe [Instance]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Instance] -> Const (First [Instance]) (Maybe [Instance]))
-> GetInstancesResponse
-> Const (First [Instance]) GetInstancesResponse
Lens' GetInstancesResponse (Maybe [Instance])
getInstancesResponse_instances ((Maybe [Instance] -> Const (First [Instance]) (Maybe [Instance]))
-> GetInstancesResponse
-> Const (First [Instance]) GetInstancesResponse)
-> (([Instance] -> Const (First [Instance]) [Instance])
-> Maybe [Instance] -> Const (First [Instance]) (Maybe [Instance]))
-> Getting (First [Instance]) GetInstancesResponse [Instance]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Instance] -> Const (First [Instance]) [Instance])
-> Maybe [Instance] -> Const (First [Instance]) (Maybe [Instance])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe GetInstances
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
GetInstances -> Maybe GetInstances
forall a. a -> Maybe a
Prelude.Just (GetInstances -> Maybe GetInstances)
-> GetInstances -> Maybe GetInstances
forall a b. (a -> b) -> a -> b
Prelude.$
GetInstances
rq
GetInstances -> (GetInstances -> GetInstances) -> GetInstances
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetInstances -> Identity GetInstances
Lens GetInstances GetInstances (Maybe Text) (Maybe Text)
getInstances_pageToken
((Maybe Text -> Identity (Maybe Text))
-> GetInstances -> Identity GetInstances)
-> Maybe Text -> GetInstances -> GetInstances
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetInstances
GetInstancesResponse
rs
GetInstancesResponse
-> Getting (First Text) GetInstancesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetInstancesResponse -> Const (First Text) GetInstancesResponse
Lens' GetInstancesResponse (Maybe Text)
getInstancesResponse_nextPageToken
((Maybe Text -> Const (First Text) (Maybe Text))
-> GetInstancesResponse -> Const (First Text) GetInstancesResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest GetInstances where
type AWSResponse GetInstances = GetInstancesResponse
request :: GetInstances -> Request GetInstances
request = Service -> GetInstances -> Request GetInstances
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetInstances)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetInstances))
-> Logger
-> Service
-> Proxy GetInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetInstances)))
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 Text -> Maybe [Instance] -> Int -> GetInstancesResponse
GetInstancesResponse'
(Maybe Text -> Maybe [Instance] -> Int -> GetInstancesResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [Instance] -> Int -> GetInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextPageToken")
Either String (Maybe [Instance] -> Int -> GetInstancesResponse)
-> Either String (Maybe [Instance])
-> Either String (Int -> GetInstancesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Instance]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"instances" Either String (Maybe (Maybe [Instance]))
-> Maybe [Instance] -> Either String (Maybe [Instance])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Instance]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetInstancesResponse)
-> Either String Int -> Either String GetInstancesResponse
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 GetInstances
instance Prelude.NFData GetInstances
instance Core.ToHeaders GetInstances where
toHeaders :: GetInstances -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetInstances -> 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.GetInstances" ::
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 GetInstances where
toJSON :: GetInstances -> Value
toJSON GetInstances' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:GetInstances' :: GetInstances -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"pageToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
pageToken]
)
instance Core.ToPath GetInstances where
toPath :: GetInstances -> ByteString
toPath = ByteString -> GetInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetInstances where
toQuery :: GetInstances -> QueryString
toQuery = QueryString -> GetInstances -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetInstancesResponse = GetInstancesResponse'
{
GetInstancesResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
GetInstancesResponse -> Maybe [Instance]
instances :: Prelude.Maybe [Instance],
GetInstancesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetInstancesResponse -> GetInstancesResponse -> Bool
(GetInstancesResponse -> GetInstancesResponse -> Bool)
-> (GetInstancesResponse -> GetInstancesResponse -> Bool)
-> Eq GetInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInstancesResponse -> GetInstancesResponse -> Bool
$c/= :: GetInstancesResponse -> GetInstancesResponse -> Bool
== :: GetInstancesResponse -> GetInstancesResponse -> Bool
$c== :: GetInstancesResponse -> GetInstancesResponse -> Bool
Prelude.Eq, ReadPrec [GetInstancesResponse]
ReadPrec GetInstancesResponse
Int -> ReadS GetInstancesResponse
ReadS [GetInstancesResponse]
(Int -> ReadS GetInstancesResponse)
-> ReadS [GetInstancesResponse]
-> ReadPrec GetInstancesResponse
-> ReadPrec [GetInstancesResponse]
-> Read GetInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInstancesResponse]
$creadListPrec :: ReadPrec [GetInstancesResponse]
readPrec :: ReadPrec GetInstancesResponse
$creadPrec :: ReadPrec GetInstancesResponse
readList :: ReadS [GetInstancesResponse]
$creadList :: ReadS [GetInstancesResponse]
readsPrec :: Int -> ReadS GetInstancesResponse
$creadsPrec :: Int -> ReadS GetInstancesResponse
Prelude.Read, Int -> GetInstancesResponse -> ShowS
[GetInstancesResponse] -> ShowS
GetInstancesResponse -> String
(Int -> GetInstancesResponse -> ShowS)
-> (GetInstancesResponse -> String)
-> ([GetInstancesResponse] -> ShowS)
-> Show GetInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInstancesResponse] -> ShowS
$cshowList :: [GetInstancesResponse] -> ShowS
show :: GetInstancesResponse -> String
$cshow :: GetInstancesResponse -> String
showsPrec :: Int -> GetInstancesResponse -> ShowS
$cshowsPrec :: Int -> GetInstancesResponse -> ShowS
Prelude.Show, (forall x. GetInstancesResponse -> Rep GetInstancesResponse x)
-> (forall x. Rep GetInstancesResponse x -> GetInstancesResponse)
-> Generic GetInstancesResponse
forall x. Rep GetInstancesResponse x -> GetInstancesResponse
forall x. GetInstancesResponse -> Rep GetInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInstancesResponse x -> GetInstancesResponse
$cfrom :: forall x. GetInstancesResponse -> Rep GetInstancesResponse x
Prelude.Generic)
newGetInstancesResponse ::
Prelude.Int ->
GetInstancesResponse
newGetInstancesResponse :: Int -> GetInstancesResponse
newGetInstancesResponse Int
pHttpStatus_ =
GetInstancesResponse' :: Maybe Text -> Maybe [Instance] -> Int -> GetInstancesResponse
GetInstancesResponse'
{ $sel:nextPageToken:GetInstancesResponse' :: Maybe Text
nextPageToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:instances:GetInstancesResponse' :: Maybe [Instance]
instances = Maybe [Instance]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getInstancesResponse_nextPageToken :: Lens.Lens' GetInstancesResponse (Prelude.Maybe Prelude.Text)
getInstancesResponse_nextPageToken :: (Maybe Text -> f (Maybe Text))
-> GetInstancesResponse -> f GetInstancesResponse
getInstancesResponse_nextPageToken = (GetInstancesResponse -> Maybe Text)
-> (GetInstancesResponse -> Maybe Text -> GetInstancesResponse)
-> Lens' GetInstancesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancesResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:GetInstancesResponse' :: GetInstancesResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: GetInstancesResponse
s@GetInstancesResponse' {} Maybe Text
a -> GetInstancesResponse
s {$sel:nextPageToken:GetInstancesResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: GetInstancesResponse)
getInstancesResponse_instances :: Lens.Lens' GetInstancesResponse (Prelude.Maybe [Instance])
getInstancesResponse_instances :: (Maybe [Instance] -> f (Maybe [Instance]))
-> GetInstancesResponse -> f GetInstancesResponse
getInstancesResponse_instances = (GetInstancesResponse -> Maybe [Instance])
-> (GetInstancesResponse
-> Maybe [Instance] -> GetInstancesResponse)
-> Lens' GetInstancesResponse (Maybe [Instance])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancesResponse' {Maybe [Instance]
instances :: Maybe [Instance]
$sel:instances:GetInstancesResponse' :: GetInstancesResponse -> Maybe [Instance]
instances} -> Maybe [Instance]
instances) (\s :: GetInstancesResponse
s@GetInstancesResponse' {} Maybe [Instance]
a -> GetInstancesResponse
s {$sel:instances:GetInstancesResponse' :: Maybe [Instance]
instances = Maybe [Instance]
a} :: GetInstancesResponse) ((Maybe [Instance] -> f (Maybe [Instance]))
-> GetInstancesResponse -> f GetInstancesResponse)
-> ((Maybe [Instance] -> f (Maybe [Instance]))
-> Maybe [Instance] -> f (Maybe [Instance]))
-> (Maybe [Instance] -> f (Maybe [Instance]))
-> GetInstancesResponse
-> f GetInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Instance] [Instance] [Instance] [Instance]
-> Iso
(Maybe [Instance])
(Maybe [Instance])
(Maybe [Instance])
(Maybe [Instance])
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 [Instance] [Instance] [Instance] [Instance]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getInstancesResponse_httpStatus :: Lens.Lens' GetInstancesResponse Prelude.Int
getInstancesResponse_httpStatus :: (Int -> f Int) -> GetInstancesResponse -> f GetInstancesResponse
getInstancesResponse_httpStatus = (GetInstancesResponse -> Int)
-> (GetInstancesResponse -> Int -> GetInstancesResponse)
-> Lens GetInstancesResponse GetInstancesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetInstancesResponse' :: GetInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetInstancesResponse
s@GetInstancesResponse' {} Int
a -> GetInstancesResponse
s {$sel:httpStatus:GetInstancesResponse' :: Int
httpStatus = Int
a} :: GetInstancesResponse)
instance Prelude.NFData GetInstancesResponse