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