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