{-# 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_maxResults,
listRoots_nextToken,
ListRootsResponse (..),
newListRootsResponse,
listRootsResponse_nextToken,
listRootsResponse_roots,
listRootsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListRoots -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (ListRoots -> ListRoots -> Bool
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]
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
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. 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'
{ $sel:maxResults:ListRoots' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListRoots' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
}
listRoots_maxResults :: Lens.Lens' ListRoots (Prelude.Maybe Prelude.Natural)
listRoots_maxResults :: Lens' ListRoots (Maybe Natural)
listRoots_maxResults = 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)
listRoots_nextToken :: Lens.Lens' ListRoots (Prelude.Maybe Prelude.Text)
listRoots_nextToken :: Lens' ListRoots (Maybe Text)
listRoots_nextToken = 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)
instance Core.AWSPager ListRoots where
page :: ListRoots -> AWSResponse ListRoots -> Maybe ListRoots
page ListRoots
rq AWSResponse ListRoots
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListRoots
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRootsResponse (Maybe Text)
listRootsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListRoots
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRootsResponse (Maybe [Root])
listRootsResponse_roots
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ ListRoots
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRoots (Maybe Text)
listRoots_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRoots
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRootsResponse (Maybe Text)
listRootsResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListRoots where
type AWSResponse ListRoots = ListRootsResponse
request :: (Service -> Service) -> ListRoots -> Request ListRoots
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListRoots
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRoots)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Maybe [Root] -> Int -> ListRootsResponse
ListRootsResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Roots" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable ListRoots where
hashWithSalt :: Int -> ListRoots -> Int
hashWithSalt Int
_salt ListRoots' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRoots' :: ListRoots -> Maybe Text
$sel:maxResults:ListRoots' :: ListRoots -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
instance Prelude.NFData ListRoots where
rnf :: ListRoots -> ()
rnf ListRoots' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRoots' :: ListRoots -> Maybe Text
$sel:maxResults:ListRoots' :: ListRoots -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
instance Data.ToHeaders ListRoots where
toHeaders :: ListRoots -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSOrganizationsV20161128.ListRoots" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListRoots where
toJSON :: ListRoots -> Value
toJSON ListRoots' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListRoots' :: ListRoots -> Maybe Text
$sel:maxResults:ListRoots' :: ListRoots -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
(Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
]
)
instance Data.ToPath ListRoots where
toPath :: ListRoots -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ListRoots where
toQuery :: ListRoots -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ListRootsResponse = ListRootsResponse'
{
ListRootsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListRootsResponse -> Maybe [Root]
roots :: Prelude.Maybe [Root],
ListRootsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListRootsResponse -> ListRootsResponse -> Bool
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]
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
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. 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'
{ $sel:nextToken:ListRootsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:roots:ListRootsResponse' :: Maybe [Root]
roots = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListRootsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listRootsResponse_nextToken :: Lens.Lens' ListRootsResponse (Prelude.Maybe Prelude.Text)
listRootsResponse_nextToken :: Lens' ListRootsResponse (Maybe Text)
listRootsResponse_nextToken = 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_roots :: Lens.Lens' ListRootsResponse (Prelude.Maybe [Root])
listRootsResponse_roots :: Lens' ListRootsResponse (Maybe [Root])
listRootsResponse_roots = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listRootsResponse_httpStatus :: Lens.Lens' ListRootsResponse Prelude.Int
listRootsResponse_httpStatus :: Lens' ListRootsResponse Int
listRootsResponse_httpStatus = 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 where
rnf :: ListRootsResponse -> ()
rnf ListRootsResponse' {Int
Maybe [Root]
Maybe Text
httpStatus :: Int
roots :: Maybe [Root]
nextToken :: Maybe Text
$sel:httpStatus:ListRootsResponse' :: ListRootsResponse -> Int
$sel:roots:ListRootsResponse' :: ListRootsResponse -> Maybe [Root]
$sel:nextToken:ListRootsResponse' :: ListRootsResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Root]
roots
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus