{-# 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.Inspector2.ListUsageTotals
(
ListUsageTotals (..),
newListUsageTotals,
listUsageTotals_accountIds,
listUsageTotals_maxResults,
listUsageTotals_nextToken,
ListUsageTotalsResponse (..),
newListUsageTotalsResponse,
listUsageTotalsResponse_nextToken,
listUsageTotalsResponse_totals,
listUsageTotalsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListUsageTotals = ListUsageTotals'
{
ListUsageTotals -> Maybe (NonEmpty Text)
accountIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
ListUsageTotals -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListUsageTotals -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (ListUsageTotals -> ListUsageTotals -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListUsageTotals -> ListUsageTotals -> Bool
$c/= :: ListUsageTotals -> ListUsageTotals -> Bool
== :: ListUsageTotals -> ListUsageTotals -> Bool
$c== :: ListUsageTotals -> ListUsageTotals -> Bool
Prelude.Eq, ReadPrec [ListUsageTotals]
ReadPrec ListUsageTotals
Int -> ReadS ListUsageTotals
ReadS [ListUsageTotals]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListUsageTotals]
$creadListPrec :: ReadPrec [ListUsageTotals]
readPrec :: ReadPrec ListUsageTotals
$creadPrec :: ReadPrec ListUsageTotals
readList :: ReadS [ListUsageTotals]
$creadList :: ReadS [ListUsageTotals]
readsPrec :: Int -> ReadS ListUsageTotals
$creadsPrec :: Int -> ReadS ListUsageTotals
Prelude.Read, Int -> ListUsageTotals -> ShowS
[ListUsageTotals] -> ShowS
ListUsageTotals -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListUsageTotals] -> ShowS
$cshowList :: [ListUsageTotals] -> ShowS
show :: ListUsageTotals -> String
$cshow :: ListUsageTotals -> String
showsPrec :: Int -> ListUsageTotals -> ShowS
$cshowsPrec :: Int -> ListUsageTotals -> ShowS
Prelude.Show, forall x. Rep ListUsageTotals x -> ListUsageTotals
forall x. ListUsageTotals -> Rep ListUsageTotals x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListUsageTotals x -> ListUsageTotals
$cfrom :: forall x. ListUsageTotals -> Rep ListUsageTotals x
Prelude.Generic)
newListUsageTotals ::
ListUsageTotals
newListUsageTotals :: ListUsageTotals
newListUsageTotals =
ListUsageTotals'
{ $sel:accountIds:ListUsageTotals' :: Maybe (NonEmpty Text)
accountIds = forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:ListUsageTotals' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListUsageTotals' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
}
listUsageTotals_accountIds :: Lens.Lens' ListUsageTotals (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
listUsageTotals_accountIds :: Lens' ListUsageTotals (Maybe (NonEmpty Text))
listUsageTotals_accountIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotals' {Maybe (NonEmpty Text)
accountIds :: Maybe (NonEmpty Text)
$sel:accountIds:ListUsageTotals' :: ListUsageTotals -> Maybe (NonEmpty Text)
accountIds} -> Maybe (NonEmpty Text)
accountIds) (\s :: ListUsageTotals
s@ListUsageTotals' {} Maybe (NonEmpty Text)
a -> ListUsageTotals
s {$sel:accountIds:ListUsageTotals' :: Maybe (NonEmpty Text)
accountIds = Maybe (NonEmpty Text)
a} :: ListUsageTotals) 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
listUsageTotals_maxResults :: Lens.Lens' ListUsageTotals (Prelude.Maybe Prelude.Natural)
listUsageTotals_maxResults :: Lens' ListUsageTotals (Maybe Natural)
listUsageTotals_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotals' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListUsageTotals' :: ListUsageTotals -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListUsageTotals
s@ListUsageTotals' {} Maybe Natural
a -> ListUsageTotals
s {$sel:maxResults:ListUsageTotals' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListUsageTotals)
listUsageTotals_nextToken :: Lens.Lens' ListUsageTotals (Prelude.Maybe Prelude.Text)
listUsageTotals_nextToken :: Lens' ListUsageTotals (Maybe Text)
listUsageTotals_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotals' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListUsageTotals' :: ListUsageTotals -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListUsageTotals
s@ListUsageTotals' {} Maybe Text
a -> ListUsageTotals
s {$sel:nextToken:ListUsageTotals' :: Maybe Text
nextToken = Maybe Text
a} :: ListUsageTotals)
instance Core.AWSPager ListUsageTotals where
page :: ListUsageTotals
-> AWSResponse ListUsageTotals -> Maybe ListUsageTotals
page ListUsageTotals
rq AWSResponse ListUsageTotals
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListUsageTotals
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListUsageTotalsResponse (Maybe Text)
listUsageTotalsResponse_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 ListUsageTotals
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListUsageTotalsResponse (Maybe [UsageTotal])
listUsageTotalsResponse_totals
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.$ ListUsageTotals
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListUsageTotals (Maybe Text)
listUsageTotals_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListUsageTotals
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListUsageTotalsResponse (Maybe Text)
listUsageTotalsResponse_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 ListUsageTotals where
type
AWSResponse ListUsageTotals =
ListUsageTotalsResponse
request :: (Service -> Service) -> ListUsageTotals -> Request ListUsageTotals
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 ListUsageTotals
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListUsageTotals)))
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 [UsageTotal] -> Int -> ListUsageTotalsResponse
ListUsageTotalsResponse'
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
"totals" 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 ListUsageTotals where
hashWithSalt :: Int -> ListUsageTotals -> Int
hashWithSalt Int
_salt ListUsageTotals' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
accountIds :: Maybe (NonEmpty Text)
$sel:nextToken:ListUsageTotals' :: ListUsageTotals -> Maybe Text
$sel:maxResults:ListUsageTotals' :: ListUsageTotals -> Maybe Natural
$sel:accountIds:ListUsageTotals' :: ListUsageTotals -> Maybe (NonEmpty Text)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
accountIds
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 ListUsageTotals where
rnf :: ListUsageTotals -> ()
rnf ListUsageTotals' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
accountIds :: Maybe (NonEmpty Text)
$sel:nextToken:ListUsageTotals' :: ListUsageTotals -> Maybe Text
$sel:maxResults:ListUsageTotals' :: ListUsageTotals -> Maybe Natural
$sel:accountIds:ListUsageTotals' :: ListUsageTotals -> Maybe (NonEmpty Text)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
accountIds
seq :: forall a b. a -> b -> b
`Prelude.seq` 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 ListUsageTotals where
toHeaders :: ListUsageTotals -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListUsageTotals where
toJSON :: ListUsageTotals -> Value
toJSON ListUsageTotals' {Maybe Natural
Maybe (NonEmpty Text)
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
accountIds :: Maybe (NonEmpty Text)
$sel:nextToken:ListUsageTotals' :: ListUsageTotals -> Maybe Text
$sel:maxResults:ListUsageTotals' :: ListUsageTotals -> Maybe Natural
$sel:accountIds:ListUsageTotals' :: ListUsageTotals -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"accountIds" 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 (NonEmpty Text)
accountIds,
(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 ListUsageTotals where
toPath :: ListUsageTotals -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/usage/list"
instance Data.ToQuery ListUsageTotals where
toQuery :: ListUsageTotals -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ListUsageTotalsResponse = ListUsageTotalsResponse'
{
ListUsageTotalsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListUsageTotalsResponse -> Maybe [UsageTotal]
totals :: Prelude.Maybe [UsageTotal],
ListUsageTotalsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListUsageTotalsResponse -> ListUsageTotalsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListUsageTotalsResponse -> ListUsageTotalsResponse -> Bool
$c/= :: ListUsageTotalsResponse -> ListUsageTotalsResponse -> Bool
== :: ListUsageTotalsResponse -> ListUsageTotalsResponse -> Bool
$c== :: ListUsageTotalsResponse -> ListUsageTotalsResponse -> Bool
Prelude.Eq, ReadPrec [ListUsageTotalsResponse]
ReadPrec ListUsageTotalsResponse
Int -> ReadS ListUsageTotalsResponse
ReadS [ListUsageTotalsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListUsageTotalsResponse]
$creadListPrec :: ReadPrec [ListUsageTotalsResponse]
readPrec :: ReadPrec ListUsageTotalsResponse
$creadPrec :: ReadPrec ListUsageTotalsResponse
readList :: ReadS [ListUsageTotalsResponse]
$creadList :: ReadS [ListUsageTotalsResponse]
readsPrec :: Int -> ReadS ListUsageTotalsResponse
$creadsPrec :: Int -> ReadS ListUsageTotalsResponse
Prelude.Read, Int -> ListUsageTotalsResponse -> ShowS
[ListUsageTotalsResponse] -> ShowS
ListUsageTotalsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListUsageTotalsResponse] -> ShowS
$cshowList :: [ListUsageTotalsResponse] -> ShowS
show :: ListUsageTotalsResponse -> String
$cshow :: ListUsageTotalsResponse -> String
showsPrec :: Int -> ListUsageTotalsResponse -> ShowS
$cshowsPrec :: Int -> ListUsageTotalsResponse -> ShowS
Prelude.Show, forall x. Rep ListUsageTotalsResponse x -> ListUsageTotalsResponse
forall x. ListUsageTotalsResponse -> Rep ListUsageTotalsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListUsageTotalsResponse x -> ListUsageTotalsResponse
$cfrom :: forall x. ListUsageTotalsResponse -> Rep ListUsageTotalsResponse x
Prelude.Generic)
newListUsageTotalsResponse ::
Prelude.Int ->
ListUsageTotalsResponse
newListUsageTotalsResponse :: Int -> ListUsageTotalsResponse
newListUsageTotalsResponse Int
pHttpStatus_ =
ListUsageTotalsResponse'
{ $sel:nextToken:ListUsageTotalsResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:totals:ListUsageTotalsResponse' :: Maybe [UsageTotal]
totals = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListUsageTotalsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listUsageTotalsResponse_nextToken :: Lens.Lens' ListUsageTotalsResponse (Prelude.Maybe Prelude.Text)
listUsageTotalsResponse_nextToken :: Lens' ListUsageTotalsResponse (Maybe Text)
listUsageTotalsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotalsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListUsageTotalsResponse
s@ListUsageTotalsResponse' {} Maybe Text
a -> ListUsageTotalsResponse
s {$sel:nextToken:ListUsageTotalsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListUsageTotalsResponse)
listUsageTotalsResponse_totals :: Lens.Lens' ListUsageTotalsResponse (Prelude.Maybe [UsageTotal])
listUsageTotalsResponse_totals :: Lens' ListUsageTotalsResponse (Maybe [UsageTotal])
listUsageTotalsResponse_totals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotalsResponse' {Maybe [UsageTotal]
totals :: Maybe [UsageTotal]
$sel:totals:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> Maybe [UsageTotal]
totals} -> Maybe [UsageTotal]
totals) (\s :: ListUsageTotalsResponse
s@ListUsageTotalsResponse' {} Maybe [UsageTotal]
a -> ListUsageTotalsResponse
s {$sel:totals:ListUsageTotalsResponse' :: Maybe [UsageTotal]
totals = Maybe [UsageTotal]
a} :: ListUsageTotalsResponse) 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
listUsageTotalsResponse_httpStatus :: Lens.Lens' ListUsageTotalsResponse Prelude.Int
listUsageTotalsResponse_httpStatus :: Lens' ListUsageTotalsResponse Int
listUsageTotalsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsageTotalsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListUsageTotalsResponse
s@ListUsageTotalsResponse' {} Int
a -> ListUsageTotalsResponse
s {$sel:httpStatus:ListUsageTotalsResponse' :: Int
httpStatus = Int
a} :: ListUsageTotalsResponse)
instance Prelude.NFData ListUsageTotalsResponse where
rnf :: ListUsageTotalsResponse -> ()
rnf ListUsageTotalsResponse' {Int
Maybe [UsageTotal]
Maybe Text
httpStatus :: Int
totals :: Maybe [UsageTotal]
nextToken :: Maybe Text
$sel:httpStatus:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> Int
$sel:totals:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> Maybe [UsageTotal]
$sel:nextToken:ListUsageTotalsResponse' :: ListUsageTotalsResponse -> 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 [UsageTotal]
totals
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus