{-# 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.Transfer.ListServers
(
ListServers (..),
newListServers,
listServers_nextToken,
listServers_maxResults,
ListServersResponse (..),
newListServersResponse,
listServersResponse_nextToken,
listServersResponse_httpStatus,
listServersResponse_servers,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Transfer.Types
data ListServers = ListServers'
{
ListServers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListServers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
}
deriving (ListServers -> ListServers -> Bool
(ListServers -> ListServers -> Bool)
-> (ListServers -> ListServers -> Bool) -> Eq ListServers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListServers -> ListServers -> Bool
$c/= :: ListServers -> ListServers -> Bool
== :: ListServers -> ListServers -> Bool
$c== :: ListServers -> ListServers -> Bool
Prelude.Eq, ReadPrec [ListServers]
ReadPrec ListServers
Int -> ReadS ListServers
ReadS [ListServers]
(Int -> ReadS ListServers)
-> ReadS [ListServers]
-> ReadPrec ListServers
-> ReadPrec [ListServers]
-> Read ListServers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListServers]
$creadListPrec :: ReadPrec [ListServers]
readPrec :: ReadPrec ListServers
$creadPrec :: ReadPrec ListServers
readList :: ReadS [ListServers]
$creadList :: ReadS [ListServers]
readsPrec :: Int -> ReadS ListServers
$creadsPrec :: Int -> ReadS ListServers
Prelude.Read, Int -> ListServers -> ShowS
[ListServers] -> ShowS
ListServers -> String
(Int -> ListServers -> ShowS)
-> (ListServers -> String)
-> ([ListServers] -> ShowS)
-> Show ListServers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListServers] -> ShowS
$cshowList :: [ListServers] -> ShowS
show :: ListServers -> String
$cshow :: ListServers -> String
showsPrec :: Int -> ListServers -> ShowS
$cshowsPrec :: Int -> ListServers -> ShowS
Prelude.Show, (forall x. ListServers -> Rep ListServers x)
-> (forall x. Rep ListServers x -> ListServers)
-> Generic ListServers
forall x. Rep ListServers x -> ListServers
forall x. ListServers -> Rep ListServers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListServers x -> ListServers
$cfrom :: forall x. ListServers -> Rep ListServers x
Prelude.Generic)
newListServers ::
ListServers
newListServers :: ListServers
newListServers =
ListServers' :: Maybe Text -> Maybe Natural -> ListServers
ListServers'
{ $sel:nextToken:ListServers' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:ListServers' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
listServers_nextToken :: Lens.Lens' ListServers (Prelude.Maybe Prelude.Text)
listServers_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListServers -> f ListServers
listServers_nextToken = (ListServers -> Maybe Text)
-> (ListServers -> Maybe Text -> ListServers)
-> Lens ListServers ListServers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListServers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListServers' :: ListServers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListServers
s@ListServers' {} Maybe Text
a -> ListServers
s {$sel:nextToken:ListServers' :: Maybe Text
nextToken = Maybe Text
a} :: ListServers)
listServers_maxResults :: Lens.Lens' ListServers (Prelude.Maybe Prelude.Natural)
listServers_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListServers -> f ListServers
listServers_maxResults = (ListServers -> Maybe Natural)
-> (ListServers -> Maybe Natural -> ListServers)
-> Lens ListServers ListServers (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListServers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListServers' :: ListServers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListServers
s@ListServers' {} Maybe Natural
a -> ListServers
s {$sel:maxResults:ListServers' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListServers)
instance Core.AWSPager ListServers where
page :: ListServers -> AWSResponse ListServers -> Maybe ListServers
page ListServers
rq AWSResponse ListServers
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListServers
ListServersResponse
rs
ListServersResponse
-> Getting (First Text) ListServersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListServersResponse -> Const (First Text) ListServersResponse
Lens' ListServersResponse (Maybe Text)
listServersResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListServersResponse -> Const (First Text) ListServersResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListServersResponse 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 ListServers
forall a. Maybe a
Prelude.Nothing
| [ListedServer] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop (AWSResponse ListServers
ListServersResponse
rs ListServersResponse
-> Getting [ListedServer] ListServersResponse [ListedServer]
-> [ListedServer]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [ListedServer] ListServersResponse [ListedServer]
Lens' ListServersResponse [ListedServer]
listServersResponse_servers) =
Maybe ListServers
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListServers -> Maybe ListServers
forall a. a -> Maybe a
Prelude.Just (ListServers -> Maybe ListServers)
-> ListServers -> Maybe ListServers
forall a b. (a -> b) -> a -> b
Prelude.$
ListServers
rq
ListServers -> (ListServers -> ListServers) -> ListServers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListServers -> Identity ListServers
Lens ListServers ListServers (Maybe Text) (Maybe Text)
listServers_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListServers -> Identity ListServers)
-> Maybe Text -> ListServers -> ListServers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListServers
ListServersResponse
rs
ListServersResponse
-> Getting (First Text) ListServersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListServersResponse -> Const (First Text) ListServersResponse
Lens' ListServersResponse (Maybe Text)
listServersResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListServersResponse -> Const (First Text) ListServersResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListServersResponse 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 ListServers where
type AWSResponse ListServers = ListServersResponse
request :: ListServers -> Request ListServers
request = Service -> ListServers -> Request ListServers
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListServers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListServers)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListServers))
-> Logger
-> Service
-> Proxy ListServers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListServers)))
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 -> Int -> [ListedServer] -> ListServersResponse
ListServersResponse'
(Maybe Text -> Int -> [ListedServer] -> ListServersResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [ListedServer] -> ListServersResponse)
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
"NextToken")
Either String (Int -> [ListedServer] -> ListServersResponse)
-> Either String Int
-> Either String ([ListedServer] -> ListServersResponse)
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))
Either String ([ListedServer] -> ListServersResponse)
-> Either String [ListedServer]
-> Either String ListServersResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [ListedServer])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Servers" Either String (Maybe [ListedServer])
-> [ListedServer] -> Either String [ListedServer]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ListedServer]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable ListServers
instance Prelude.NFData ListServers
instance Core.ToHeaders ListServers where
toHeaders :: ListServers -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListServers -> 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
"TransferService.ListServers" ::
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 ListServers where
toJSON :: ListServers -> Value
toJSON ListServers' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListServers' :: ListServers -> Maybe Natural
$sel:nextToken:ListServers' :: ListServers -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"NextToken" 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
nextToken,
(Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
]
)
instance Core.ToPath ListServers where
toPath :: ListServers -> ByteString
toPath = ByteString -> ListServers -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListServers where
toQuery :: ListServers -> QueryString
toQuery = QueryString -> ListServers -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListServersResponse = ListServersResponse'
{
ListServersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListServersResponse -> Int
httpStatus :: Prelude.Int,
ListServersResponse -> [ListedServer]
servers :: [ListedServer]
}
deriving (ListServersResponse -> ListServersResponse -> Bool
(ListServersResponse -> ListServersResponse -> Bool)
-> (ListServersResponse -> ListServersResponse -> Bool)
-> Eq ListServersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListServersResponse -> ListServersResponse -> Bool
$c/= :: ListServersResponse -> ListServersResponse -> Bool
== :: ListServersResponse -> ListServersResponse -> Bool
$c== :: ListServersResponse -> ListServersResponse -> Bool
Prelude.Eq, ReadPrec [ListServersResponse]
ReadPrec ListServersResponse
Int -> ReadS ListServersResponse
ReadS [ListServersResponse]
(Int -> ReadS ListServersResponse)
-> ReadS [ListServersResponse]
-> ReadPrec ListServersResponse
-> ReadPrec [ListServersResponse]
-> Read ListServersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListServersResponse]
$creadListPrec :: ReadPrec [ListServersResponse]
readPrec :: ReadPrec ListServersResponse
$creadPrec :: ReadPrec ListServersResponse
readList :: ReadS [ListServersResponse]
$creadList :: ReadS [ListServersResponse]
readsPrec :: Int -> ReadS ListServersResponse
$creadsPrec :: Int -> ReadS ListServersResponse
Prelude.Read, Int -> ListServersResponse -> ShowS
[ListServersResponse] -> ShowS
ListServersResponse -> String
(Int -> ListServersResponse -> ShowS)
-> (ListServersResponse -> String)
-> ([ListServersResponse] -> ShowS)
-> Show ListServersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListServersResponse] -> ShowS
$cshowList :: [ListServersResponse] -> ShowS
show :: ListServersResponse -> String
$cshow :: ListServersResponse -> String
showsPrec :: Int -> ListServersResponse -> ShowS
$cshowsPrec :: Int -> ListServersResponse -> ShowS
Prelude.Show, (forall x. ListServersResponse -> Rep ListServersResponse x)
-> (forall x. Rep ListServersResponse x -> ListServersResponse)
-> Generic ListServersResponse
forall x. Rep ListServersResponse x -> ListServersResponse
forall x. ListServersResponse -> Rep ListServersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListServersResponse x -> ListServersResponse
$cfrom :: forall x. ListServersResponse -> Rep ListServersResponse x
Prelude.Generic)
newListServersResponse ::
Prelude.Int ->
ListServersResponse
newListServersResponse :: Int -> ListServersResponse
newListServersResponse Int
pHttpStatus_ =
ListServersResponse' :: Maybe Text -> Int -> [ListedServer] -> ListServersResponse
ListServersResponse'
{ $sel:nextToken:ListServersResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListServersResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:servers:ListServersResponse' :: [ListedServer]
servers = [ListedServer]
forall a. Monoid a => a
Prelude.mempty
}
listServersResponse_nextToken :: Lens.Lens' ListServersResponse (Prelude.Maybe Prelude.Text)
listServersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListServersResponse -> f ListServersResponse
listServersResponse_nextToken = (ListServersResponse -> Maybe Text)
-> (ListServersResponse -> Maybe Text -> ListServersResponse)
-> Lens' ListServersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListServersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListServersResponse' :: ListServersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListServersResponse
s@ListServersResponse' {} Maybe Text
a -> ListServersResponse
s {$sel:nextToken:ListServersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListServersResponse)
listServersResponse_httpStatus :: Lens.Lens' ListServersResponse Prelude.Int
listServersResponse_httpStatus :: (Int -> f Int) -> ListServersResponse -> f ListServersResponse
listServersResponse_httpStatus = (ListServersResponse -> Int)
-> (ListServersResponse -> Int -> ListServersResponse)
-> Lens ListServersResponse ListServersResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListServersResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListServersResponse' :: ListServersResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListServersResponse
s@ListServersResponse' {} Int
a -> ListServersResponse
s {$sel:httpStatus:ListServersResponse' :: Int
httpStatus = Int
a} :: ListServersResponse)
listServersResponse_servers :: Lens.Lens' ListServersResponse [ListedServer]
listServersResponse_servers :: ([ListedServer] -> f [ListedServer])
-> ListServersResponse -> f ListServersResponse
listServersResponse_servers = (ListServersResponse -> [ListedServer])
-> (ListServersResponse -> [ListedServer] -> ListServersResponse)
-> Lens' ListServersResponse [ListedServer]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListServersResponse' {[ListedServer]
servers :: [ListedServer]
$sel:servers:ListServersResponse' :: ListServersResponse -> [ListedServer]
servers} -> [ListedServer]
servers) (\s :: ListServersResponse
s@ListServersResponse' {} [ListedServer]
a -> ListServersResponse
s {$sel:servers:ListServersResponse' :: [ListedServer]
servers = [ListedServer]
a} :: ListServersResponse) (([ListedServer] -> f [ListedServer])
-> ListServersResponse -> f ListServersResponse)
-> (([ListedServer] -> f [ListedServer])
-> [ListedServer] -> f [ListedServer])
-> ([ListedServer] -> f [ListedServer])
-> ListServersResponse
-> f ListServersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ListedServer] -> f [ListedServer])
-> [ListedServer] -> f [ListedServer]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData ListServersResponse