{-# 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.Organizations.ListRoots
(
ListRoots (..),
newListRoots,
listRoots_nextToken,
listRoots_maxResults,
ListRootsResponse (..),
newListRootsResponse,
listRootsResponse_roots,
listRootsResponse_nextToken,
listRootsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListRoots = ListRoots'
{
ListRoots -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListRoots -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
}
deriving (ListRoots -> ListRoots -> Bool
(ListRoots -> ListRoots -> Bool)
-> (ListRoots -> ListRoots -> Bool) -> Eq ListRoots
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRoots -> ListRoots -> Bool
$c/= :: ListRoots -> ListRoots -> Bool
== :: ListRoots -> ListRoots -> Bool
$c== :: ListRoots -> ListRoots -> Bool
Prelude.Eq, ReadPrec [ListRoots]
ReadPrec ListRoots
Int -> ReadS ListRoots
ReadS [ListRoots]
(Int -> ReadS ListRoots)
-> ReadS [ListRoots]
-> ReadPrec ListRoots
-> ReadPrec [ListRoots]
-> Read ListRoots
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRoots]
$creadListPrec :: ReadPrec [ListRoots]
readPrec :: ReadPrec ListRoots
$creadPrec :: ReadPrec ListRoots
readList :: ReadS [ListRoots]
$creadList :: ReadS [ListRoots]
readsPrec :: Int -> ReadS ListRoots
$creadsPrec :: Int -> ReadS ListRoots
Prelude.Read, Int -> ListRoots -> ShowS
[ListRoots] -> ShowS
ListRoots -> String
(Int -> ListRoots -> ShowS)
-> (ListRoots -> String)
-> ([ListRoots] -> ShowS)
-> Show ListRoots
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRoots] -> ShowS
$cshowList :: [ListRoots] -> ShowS
show :: ListRoots -> String
$cshow :: ListRoots -> String
showsPrec :: Int -> ListRoots -> ShowS
$cshowsPrec :: Int -> ListRoots -> ShowS
Prelude.Show, (forall x. ListRoots -> Rep ListRoots x)
-> (forall x. Rep ListRoots x -> ListRoots) -> Generic ListRoots
forall x. Rep ListRoots x -> ListRoots
forall x. ListRoots -> Rep ListRoots x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRoots x -> ListRoots
$cfrom :: forall x. ListRoots -> Rep ListRoots x
Prelude.Generic)
newListRoots ::
ListRoots
newListRoots :: ListRoots
newListRoots =
ListRoots' :: Maybe Text -> Maybe Natural -> ListRoots
ListRoots'
{ $sel:nextToken:ListRoots' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:ListRoots' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
}
listRoots_nextToken :: Lens.Lens' ListRoots (Prelude.Maybe Prelude.Text)
listRoots_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListRoots -> f ListRoots
listRoots_nextToken = (ListRoots -> Maybe Text)
-> (ListRoots -> Maybe Text -> ListRoots)
-> Lens ListRoots ListRoots (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRoots' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRoots' :: ListRoots -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRoots
s@ListRoots' {} Maybe Text
a -> ListRoots
s {$sel:nextToken:ListRoots' :: Maybe Text
nextToken = Maybe Text
a} :: ListRoots)
listRoots_maxResults :: Lens.Lens' ListRoots (Prelude.Maybe Prelude.Natural)
listRoots_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListRoots -> f ListRoots
listRoots_maxResults = (ListRoots -> Maybe Natural)
-> (ListRoots -> Maybe Natural -> ListRoots)
-> Lens ListRoots ListRoots (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRoots' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListRoots' :: ListRoots -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListRoots
s@ListRoots' {} Maybe Natural
a -> ListRoots
s {$sel:maxResults:ListRoots' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListRoots)
instance Core.AWSPager ListRoots where
page :: ListRoots -> AWSResponse ListRoots -> Maybe ListRoots
page ListRoots
rq AWSResponse ListRoots
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListRoots
ListRootsResponse
rs
ListRootsResponse
-> Getting (First Text) ListRootsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListRootsResponse -> Const (First Text) ListRootsResponse
Lens' ListRootsResponse (Maybe Text)
listRootsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListRootsResponse -> Const (First Text) ListRootsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListRootsResponse 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 ListRoots
forall a. Maybe a
Prelude.Nothing
| Maybe [Root] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListRoots
ListRootsResponse
rs
ListRootsResponse
-> Getting (First [Root]) ListRootsResponse [Root] -> Maybe [Root]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Root] -> Const (First [Root]) (Maybe [Root]))
-> ListRootsResponse -> Const (First [Root]) ListRootsResponse
Lens' ListRootsResponse (Maybe [Root])
listRootsResponse_roots ((Maybe [Root] -> Const (First [Root]) (Maybe [Root]))
-> ListRootsResponse -> Const (First [Root]) ListRootsResponse)
-> (([Root] -> Const (First [Root]) [Root])
-> Maybe [Root] -> Const (First [Root]) (Maybe [Root]))
-> Getting (First [Root]) ListRootsResponse [Root]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Root] -> Const (First [Root]) [Root])
-> Maybe [Root] -> Const (First [Root]) (Maybe [Root])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListRoots
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListRoots -> Maybe ListRoots
forall a. a -> Maybe a
Prelude.Just (ListRoots -> Maybe ListRoots) -> ListRoots -> Maybe ListRoots
forall a b. (a -> b) -> a -> b
Prelude.$
ListRoots
rq
ListRoots -> (ListRoots -> ListRoots) -> ListRoots
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListRoots -> Identity ListRoots
Lens ListRoots ListRoots (Maybe Text) (Maybe Text)
listRoots_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListRoots -> Identity ListRoots)
-> Maybe Text -> ListRoots -> ListRoots
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRoots
ListRootsResponse
rs
ListRootsResponse
-> Getting (First Text) ListRootsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListRootsResponse -> Const (First Text) ListRootsResponse
Lens' ListRootsResponse (Maybe Text)
listRootsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListRootsResponse -> Const (First Text) ListRootsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListRootsResponse 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 ListRoots where
type AWSResponse ListRoots = ListRootsResponse
request :: ListRoots -> Request ListRoots
request = Service -> ListRoots -> Request ListRoots
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListRoots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRoots)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListRoots))
-> Logger
-> Service
-> Proxy ListRoots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRoots)))
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 [Root] -> Maybe Text -> Int -> ListRootsResponse
ListRootsResponse'
(Maybe [Root] -> Maybe Text -> Int -> ListRootsResponse)
-> Either String (Maybe [Root])
-> Either String (Maybe Text -> Int -> ListRootsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Root]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Roots" Either String (Maybe (Maybe [Root]))
-> Maybe [Root] -> Either String (Maybe [Root])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Root]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> ListRootsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListRootsResponse)
forall (f :: * -> *) a b. Applicative f => 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 -> ListRootsResponse)
-> Either String Int -> Either String ListRootsResponse
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 ListRoots
instance Prelude.NFData ListRoots
instance Core.ToHeaders ListRoots where
toHeaders :: ListRoots -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListRoots -> 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
"AWSOrganizationsV20161128.ListRoots" ::
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 ListRoots where
toJSON :: ListRoots -> Value
toJSON ListRoots' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListRoots' :: ListRoots -> Maybe Natural
$sel:nextToken:ListRoots' :: ListRoots -> 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 ListRoots where
toPath :: ListRoots -> ByteString
toPath = ByteString -> ListRoots -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListRoots where
toQuery :: ListRoots -> QueryString
toQuery = QueryString -> ListRoots -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListRootsResponse = ListRootsResponse'
{
ListRootsResponse -> Maybe [Root]
roots :: Prelude.Maybe [Root],
ListRootsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListRootsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListRootsResponse -> ListRootsResponse -> Bool
(ListRootsResponse -> ListRootsResponse -> Bool)
-> (ListRootsResponse -> ListRootsResponse -> Bool)
-> Eq ListRootsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRootsResponse -> ListRootsResponse -> Bool
$c/= :: ListRootsResponse -> ListRootsResponse -> Bool
== :: ListRootsResponse -> ListRootsResponse -> Bool
$c== :: ListRootsResponse -> ListRootsResponse -> Bool
Prelude.Eq, ReadPrec [ListRootsResponse]
ReadPrec ListRootsResponse
Int -> ReadS ListRootsResponse
ReadS [ListRootsResponse]
(Int -> ReadS ListRootsResponse)
-> ReadS [ListRootsResponse]
-> ReadPrec ListRootsResponse
-> ReadPrec [ListRootsResponse]
-> Read ListRootsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRootsResponse]
$creadListPrec :: ReadPrec [ListRootsResponse]
readPrec :: ReadPrec ListRootsResponse
$creadPrec :: ReadPrec ListRootsResponse
readList :: ReadS [ListRootsResponse]
$creadList :: ReadS [ListRootsResponse]
readsPrec :: Int -> ReadS ListRootsResponse
$creadsPrec :: Int -> ReadS ListRootsResponse
Prelude.Read, Int -> ListRootsResponse -> ShowS
[ListRootsResponse] -> ShowS
ListRootsResponse -> String
(Int -> ListRootsResponse -> ShowS)
-> (ListRootsResponse -> String)
-> ([ListRootsResponse] -> ShowS)
-> Show ListRootsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRootsResponse] -> ShowS
$cshowList :: [ListRootsResponse] -> ShowS
show :: ListRootsResponse -> String
$cshow :: ListRootsResponse -> String
showsPrec :: Int -> ListRootsResponse -> ShowS
$cshowsPrec :: Int -> ListRootsResponse -> ShowS
Prelude.Show, (forall x. ListRootsResponse -> Rep ListRootsResponse x)
-> (forall x. Rep ListRootsResponse x -> ListRootsResponse)
-> Generic ListRootsResponse
forall x. Rep ListRootsResponse x -> ListRootsResponse
forall x. ListRootsResponse -> Rep ListRootsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRootsResponse x -> ListRootsResponse
$cfrom :: forall x. ListRootsResponse -> Rep ListRootsResponse x
Prelude.Generic)
newListRootsResponse ::
Prelude.Int ->
ListRootsResponse
newListRootsResponse :: Int -> ListRootsResponse
newListRootsResponse Int
pHttpStatus_ =
ListRootsResponse' :: Maybe [Root] -> Maybe Text -> Int -> ListRootsResponse
ListRootsResponse'
{ $sel:roots:ListRootsResponse' :: Maybe [Root]
roots = Maybe [Root]
forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListRootsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListRootsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listRootsResponse_roots :: Lens.Lens' ListRootsResponse (Prelude.Maybe [Root])
listRootsResponse_roots :: (Maybe [Root] -> f (Maybe [Root]))
-> ListRootsResponse -> f ListRootsResponse
listRootsResponse_roots = (ListRootsResponse -> Maybe [Root])
-> (ListRootsResponse -> Maybe [Root] -> ListRootsResponse)
-> Lens' ListRootsResponse (Maybe [Root])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRootsResponse' {Maybe [Root]
roots :: Maybe [Root]
$sel:roots:ListRootsResponse' :: ListRootsResponse -> Maybe [Root]
roots} -> Maybe [Root]
roots) (\s :: ListRootsResponse
s@ListRootsResponse' {} Maybe [Root]
a -> ListRootsResponse
s {$sel:roots:ListRootsResponse' :: Maybe [Root]
roots = Maybe [Root]
a} :: ListRootsResponse) ((Maybe [Root] -> f (Maybe [Root]))
-> ListRootsResponse -> f ListRootsResponse)
-> ((Maybe [Root] -> f (Maybe [Root]))
-> Maybe [Root] -> f (Maybe [Root]))
-> (Maybe [Root] -> f (Maybe [Root]))
-> ListRootsResponse
-> f ListRootsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Root] [Root] [Root] [Root]
-> Iso (Maybe [Root]) (Maybe [Root]) (Maybe [Root]) (Maybe [Root])
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 [Root] [Root] [Root] [Root]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listRootsResponse_nextToken :: Lens.Lens' ListRootsResponse (Prelude.Maybe Prelude.Text)
listRootsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListRootsResponse -> f ListRootsResponse
listRootsResponse_nextToken = (ListRootsResponse -> Maybe Text)
-> (ListRootsResponse -> Maybe Text -> ListRootsResponse)
-> Lens' ListRootsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRootsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRootsResponse' :: ListRootsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRootsResponse
s@ListRootsResponse' {} Maybe Text
a -> ListRootsResponse
s {$sel:nextToken:ListRootsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRootsResponse)
listRootsResponse_httpStatus :: Lens.Lens' ListRootsResponse Prelude.Int
listRootsResponse_httpStatus :: (Int -> f Int) -> ListRootsResponse -> f ListRootsResponse
listRootsResponse_httpStatus = (ListRootsResponse -> Int)
-> (ListRootsResponse -> Int -> ListRootsResponse)
-> Lens ListRootsResponse ListRootsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRootsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListRootsResponse' :: ListRootsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListRootsResponse
s@ListRootsResponse' {} Int
a -> ListRootsResponse
s {$sel:httpStatus:ListRootsResponse' :: Int
httpStatus = Int
a} :: ListRootsResponse)
instance Prelude.NFData ListRootsResponse