{-# 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.CloudTrail.ListTrails
(
ListTrails (..),
newListTrails,
listTrails_nextToken,
ListTrailsResponse (..),
newListTrailsResponse,
listTrailsResponse_nextToken,
listTrailsResponse_trails,
listTrailsResponse_httpStatus,
)
where
import Amazonka.CloudTrail.Types
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
data ListTrails = ListTrails'
{
ListTrails -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (ListTrails -> ListTrails -> Bool
(ListTrails -> ListTrails -> Bool)
-> (ListTrails -> ListTrails -> Bool) -> Eq ListTrails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrails -> ListTrails -> Bool
$c/= :: ListTrails -> ListTrails -> Bool
== :: ListTrails -> ListTrails -> Bool
$c== :: ListTrails -> ListTrails -> Bool
Prelude.Eq, ReadPrec [ListTrails]
ReadPrec ListTrails
Int -> ReadS ListTrails
ReadS [ListTrails]
(Int -> ReadS ListTrails)
-> ReadS [ListTrails]
-> ReadPrec ListTrails
-> ReadPrec [ListTrails]
-> Read ListTrails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrails]
$creadListPrec :: ReadPrec [ListTrails]
readPrec :: ReadPrec ListTrails
$creadPrec :: ReadPrec ListTrails
readList :: ReadS [ListTrails]
$creadList :: ReadS [ListTrails]
readsPrec :: Int -> ReadS ListTrails
$creadsPrec :: Int -> ReadS ListTrails
Prelude.Read, Int -> ListTrails -> ShowS
[ListTrails] -> ShowS
ListTrails -> String
(Int -> ListTrails -> ShowS)
-> (ListTrails -> String)
-> ([ListTrails] -> ShowS)
-> Show ListTrails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrails] -> ShowS
$cshowList :: [ListTrails] -> ShowS
show :: ListTrails -> String
$cshow :: ListTrails -> String
showsPrec :: Int -> ListTrails -> ShowS
$cshowsPrec :: Int -> ListTrails -> ShowS
Prelude.Show, (forall x. ListTrails -> Rep ListTrails x)
-> (forall x. Rep ListTrails x -> ListTrails) -> Generic ListTrails
forall x. Rep ListTrails x -> ListTrails
forall x. ListTrails -> Rep ListTrails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrails x -> ListTrails
$cfrom :: forall x. ListTrails -> Rep ListTrails x
Prelude.Generic)
newListTrails ::
ListTrails
newListTrails :: ListTrails
newListTrails =
ListTrails' :: Maybe Text -> ListTrails
ListTrails' {$sel:nextToken:ListTrails' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing}
listTrails_nextToken :: Lens.Lens' ListTrails (Prelude.Maybe Prelude.Text)
listTrails_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListTrails -> f ListTrails
listTrails_nextToken = (ListTrails -> Maybe Text)
-> (ListTrails -> Maybe Text -> ListTrails)
-> Lens ListTrails ListTrails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrails' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrails' :: ListTrails -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrails
s@ListTrails' {} Maybe Text
a -> ListTrails
s {$sel:nextToken:ListTrails' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrails)
instance Core.AWSPager ListTrails where
page :: ListTrails -> AWSResponse ListTrails -> Maybe ListTrails
page ListTrails
rq AWSResponse ListTrails
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTrails
ListTrailsResponse
rs
ListTrailsResponse
-> Getting (First Text) ListTrailsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTrailsResponse -> Const (First Text) ListTrailsResponse
Lens' ListTrailsResponse (Maybe Text)
listTrailsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListTrailsResponse -> Const (First Text) ListTrailsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTrailsResponse 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 ListTrails
forall a. Maybe a
Prelude.Nothing
| Maybe [TrailInfo] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTrails
ListTrailsResponse
rs
ListTrailsResponse
-> Getting (First [TrailInfo]) ListTrailsResponse [TrailInfo]
-> Maybe [TrailInfo]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [TrailInfo]
-> Const (First [TrailInfo]) (Maybe [TrailInfo]))
-> ListTrailsResponse
-> Const (First [TrailInfo]) ListTrailsResponse
Lens' ListTrailsResponse (Maybe [TrailInfo])
listTrailsResponse_trails ((Maybe [TrailInfo]
-> Const (First [TrailInfo]) (Maybe [TrailInfo]))
-> ListTrailsResponse
-> Const (First [TrailInfo]) ListTrailsResponse)
-> (([TrailInfo] -> Const (First [TrailInfo]) [TrailInfo])
-> Maybe [TrailInfo]
-> Const (First [TrailInfo]) (Maybe [TrailInfo]))
-> Getting (First [TrailInfo]) ListTrailsResponse [TrailInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TrailInfo] -> Const (First [TrailInfo]) [TrailInfo])
-> Maybe [TrailInfo]
-> Const (First [TrailInfo]) (Maybe [TrailInfo])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListTrails
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListTrails -> Maybe ListTrails
forall a. a -> Maybe a
Prelude.Just (ListTrails -> Maybe ListTrails) -> ListTrails -> Maybe ListTrails
forall a b. (a -> b) -> a -> b
Prelude.$
ListTrails
rq
ListTrails -> (ListTrails -> ListTrails) -> ListTrails
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListTrails -> Identity ListTrails
Lens ListTrails ListTrails (Maybe Text) (Maybe Text)
listTrails_nextToken
((Maybe Text -> Identity (Maybe Text))
-> ListTrails -> Identity ListTrails)
-> Maybe Text -> ListTrails -> ListTrails
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTrails
ListTrailsResponse
rs
ListTrailsResponse
-> Getting (First Text) ListTrailsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListTrailsResponse -> Const (First Text) ListTrailsResponse
Lens' ListTrailsResponse (Maybe Text)
listTrailsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListTrailsResponse -> Const (First Text) ListTrailsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListTrailsResponse 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 ListTrails where
type AWSResponse ListTrails = ListTrailsResponse
request :: ListTrails -> Request ListTrails
request = Service -> ListTrails -> Request ListTrails
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListTrails
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTrails)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListTrails))
-> Logger
-> Service
-> Proxy ListTrails
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTrails)))
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 [TrailInfo] -> Int -> ListTrailsResponse
ListTrailsResponse'
(Maybe Text -> Maybe [TrailInfo] -> Int -> ListTrailsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [TrailInfo] -> Int -> ListTrailsResponse)
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 (Maybe [TrailInfo] -> Int -> ListTrailsResponse)
-> Either String (Maybe [TrailInfo])
-> Either String (Int -> ListTrailsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [TrailInfo]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Trails" Either String (Maybe (Maybe [TrailInfo]))
-> Maybe [TrailInfo] -> Either String (Maybe [TrailInfo])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [TrailInfo]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> ListTrailsResponse)
-> Either String Int -> Either String ListTrailsResponse
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 ListTrails
instance Prelude.NFData ListTrails
instance Core.ToHeaders ListTrails where
toHeaders :: ListTrails -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListTrails -> 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
"com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.ListTrails" ::
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 ListTrails where
toJSON :: ListTrails -> Value
toJSON ListTrails' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrails' :: ListTrails -> 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]
)
instance Core.ToPath ListTrails where
toPath :: ListTrails -> ByteString
toPath = ByteString -> ListTrails -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListTrails where
toQuery :: ListTrails -> QueryString
toQuery = QueryString -> ListTrails -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ListTrailsResponse = ListTrailsResponse'
{
ListTrailsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListTrailsResponse -> Maybe [TrailInfo]
trails :: Prelude.Maybe [TrailInfo],
ListTrailsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListTrailsResponse -> ListTrailsResponse -> Bool
(ListTrailsResponse -> ListTrailsResponse -> Bool)
-> (ListTrailsResponse -> ListTrailsResponse -> Bool)
-> Eq ListTrailsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrailsResponse -> ListTrailsResponse -> Bool
$c/= :: ListTrailsResponse -> ListTrailsResponse -> Bool
== :: ListTrailsResponse -> ListTrailsResponse -> Bool
$c== :: ListTrailsResponse -> ListTrailsResponse -> Bool
Prelude.Eq, ReadPrec [ListTrailsResponse]
ReadPrec ListTrailsResponse
Int -> ReadS ListTrailsResponse
ReadS [ListTrailsResponse]
(Int -> ReadS ListTrailsResponse)
-> ReadS [ListTrailsResponse]
-> ReadPrec ListTrailsResponse
-> ReadPrec [ListTrailsResponse]
-> Read ListTrailsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrailsResponse]
$creadListPrec :: ReadPrec [ListTrailsResponse]
readPrec :: ReadPrec ListTrailsResponse
$creadPrec :: ReadPrec ListTrailsResponse
readList :: ReadS [ListTrailsResponse]
$creadList :: ReadS [ListTrailsResponse]
readsPrec :: Int -> ReadS ListTrailsResponse
$creadsPrec :: Int -> ReadS ListTrailsResponse
Prelude.Read, Int -> ListTrailsResponse -> ShowS
[ListTrailsResponse] -> ShowS
ListTrailsResponse -> String
(Int -> ListTrailsResponse -> ShowS)
-> (ListTrailsResponse -> String)
-> ([ListTrailsResponse] -> ShowS)
-> Show ListTrailsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrailsResponse] -> ShowS
$cshowList :: [ListTrailsResponse] -> ShowS
show :: ListTrailsResponse -> String
$cshow :: ListTrailsResponse -> String
showsPrec :: Int -> ListTrailsResponse -> ShowS
$cshowsPrec :: Int -> ListTrailsResponse -> ShowS
Prelude.Show, (forall x. ListTrailsResponse -> Rep ListTrailsResponse x)
-> (forall x. Rep ListTrailsResponse x -> ListTrailsResponse)
-> Generic ListTrailsResponse
forall x. Rep ListTrailsResponse x -> ListTrailsResponse
forall x. ListTrailsResponse -> Rep ListTrailsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrailsResponse x -> ListTrailsResponse
$cfrom :: forall x. ListTrailsResponse -> Rep ListTrailsResponse x
Prelude.Generic)
newListTrailsResponse ::
Prelude.Int ->
ListTrailsResponse
newListTrailsResponse :: Int -> ListTrailsResponse
newListTrailsResponse Int
pHttpStatus_ =
ListTrailsResponse' :: Maybe Text -> Maybe [TrailInfo] -> Int -> ListTrailsResponse
ListTrailsResponse'
{ $sel:nextToken:ListTrailsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:trails:ListTrailsResponse' :: Maybe [TrailInfo]
trails = Maybe [TrailInfo]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListTrailsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listTrailsResponse_nextToken :: Lens.Lens' ListTrailsResponse (Prelude.Maybe Prelude.Text)
listTrailsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListTrailsResponse -> f ListTrailsResponse
listTrailsResponse_nextToken = (ListTrailsResponse -> Maybe Text)
-> (ListTrailsResponse -> Maybe Text -> ListTrailsResponse)
-> Lens' ListTrailsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrailsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrailsResponse' :: ListTrailsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrailsResponse
s@ListTrailsResponse' {} Maybe Text
a -> ListTrailsResponse
s {$sel:nextToken:ListTrailsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrailsResponse)
listTrailsResponse_trails :: Lens.Lens' ListTrailsResponse (Prelude.Maybe [TrailInfo])
listTrailsResponse_trails :: (Maybe [TrailInfo] -> f (Maybe [TrailInfo]))
-> ListTrailsResponse -> f ListTrailsResponse
listTrailsResponse_trails = (ListTrailsResponse -> Maybe [TrailInfo])
-> (ListTrailsResponse -> Maybe [TrailInfo] -> ListTrailsResponse)
-> Lens' ListTrailsResponse (Maybe [TrailInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrailsResponse' {Maybe [TrailInfo]
trails :: Maybe [TrailInfo]
$sel:trails:ListTrailsResponse' :: ListTrailsResponse -> Maybe [TrailInfo]
trails} -> Maybe [TrailInfo]
trails) (\s :: ListTrailsResponse
s@ListTrailsResponse' {} Maybe [TrailInfo]
a -> ListTrailsResponse
s {$sel:trails:ListTrailsResponse' :: Maybe [TrailInfo]
trails = Maybe [TrailInfo]
a} :: ListTrailsResponse) ((Maybe [TrailInfo] -> f (Maybe [TrailInfo]))
-> ListTrailsResponse -> f ListTrailsResponse)
-> ((Maybe [TrailInfo] -> f (Maybe [TrailInfo]))
-> Maybe [TrailInfo] -> f (Maybe [TrailInfo]))
-> (Maybe [TrailInfo] -> f (Maybe [TrailInfo]))
-> ListTrailsResponse
-> f ListTrailsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TrailInfo] [TrailInfo] [TrailInfo] [TrailInfo]
-> Iso
(Maybe [TrailInfo])
(Maybe [TrailInfo])
(Maybe [TrailInfo])
(Maybe [TrailInfo])
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 [TrailInfo] [TrailInfo] [TrailInfo] [TrailInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listTrailsResponse_httpStatus :: Lens.Lens' ListTrailsResponse Prelude.Int
listTrailsResponse_httpStatus :: (Int -> f Int) -> ListTrailsResponse -> f ListTrailsResponse
listTrailsResponse_httpStatus = (ListTrailsResponse -> Int)
-> (ListTrailsResponse -> Int -> ListTrailsResponse)
-> Lens ListTrailsResponse ListTrailsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrailsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTrailsResponse' :: ListTrailsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTrailsResponse
s@ListTrailsResponse' {} Int
a -> ListTrailsResponse
s {$sel:httpStatus:ListTrailsResponse' :: Int
httpStatus = Int
a} :: ListTrailsResponse)
instance Prelude.NFData ListTrailsResponse