{-# 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.IoT.GetPercentiles
(
GetPercentiles (..),
newGetPercentiles,
getPercentiles_percents,
getPercentiles_queryVersion,
getPercentiles_aggregationField,
getPercentiles_indexName,
getPercentiles_queryString,
GetPercentilesResponse (..),
newGetPercentilesResponse,
getPercentilesResponse_percentiles,
getPercentilesResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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 GetPercentiles = GetPercentiles'
{
GetPercentiles -> Maybe [Double]
percents :: Prelude.Maybe [Prelude.Double],
GetPercentiles -> Maybe Text
queryVersion :: Prelude.Maybe Prelude.Text,
GetPercentiles -> Maybe Text
aggregationField :: Prelude.Maybe Prelude.Text,
GetPercentiles -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
GetPercentiles -> Text
queryString :: Prelude.Text
}
deriving (GetPercentiles -> GetPercentiles -> Bool
(GetPercentiles -> GetPercentiles -> Bool)
-> (GetPercentiles -> GetPercentiles -> Bool) -> Eq GetPercentiles
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPercentiles -> GetPercentiles -> Bool
$c/= :: GetPercentiles -> GetPercentiles -> Bool
== :: GetPercentiles -> GetPercentiles -> Bool
$c== :: GetPercentiles -> GetPercentiles -> Bool
Prelude.Eq, ReadPrec [GetPercentiles]
ReadPrec GetPercentiles
Int -> ReadS GetPercentiles
ReadS [GetPercentiles]
(Int -> ReadS GetPercentiles)
-> ReadS [GetPercentiles]
-> ReadPrec GetPercentiles
-> ReadPrec [GetPercentiles]
-> Read GetPercentiles
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPercentiles]
$creadListPrec :: ReadPrec [GetPercentiles]
readPrec :: ReadPrec GetPercentiles
$creadPrec :: ReadPrec GetPercentiles
readList :: ReadS [GetPercentiles]
$creadList :: ReadS [GetPercentiles]
readsPrec :: Int -> ReadS GetPercentiles
$creadsPrec :: Int -> ReadS GetPercentiles
Prelude.Read, Int -> GetPercentiles -> ShowS
[GetPercentiles] -> ShowS
GetPercentiles -> String
(Int -> GetPercentiles -> ShowS)
-> (GetPercentiles -> String)
-> ([GetPercentiles] -> ShowS)
-> Show GetPercentiles
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPercentiles] -> ShowS
$cshowList :: [GetPercentiles] -> ShowS
show :: GetPercentiles -> String
$cshow :: GetPercentiles -> String
showsPrec :: Int -> GetPercentiles -> ShowS
$cshowsPrec :: Int -> GetPercentiles -> ShowS
Prelude.Show, (forall x. GetPercentiles -> Rep GetPercentiles x)
-> (forall x. Rep GetPercentiles x -> GetPercentiles)
-> Generic GetPercentiles
forall x. Rep GetPercentiles x -> GetPercentiles
forall x. GetPercentiles -> Rep GetPercentiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPercentiles x -> GetPercentiles
$cfrom :: forall x. GetPercentiles -> Rep GetPercentiles x
Prelude.Generic)
newGetPercentiles ::
Prelude.Text ->
GetPercentiles
newGetPercentiles :: Text -> GetPercentiles
newGetPercentiles Text
pQueryString_ =
GetPercentiles' :: Maybe [Double]
-> Maybe Text -> Maybe Text -> Maybe Text -> Text -> GetPercentiles
GetPercentiles'
{ $sel:percents:GetPercentiles' :: Maybe [Double]
percents = Maybe [Double]
forall a. Maybe a
Prelude.Nothing,
$sel:queryVersion:GetPercentiles' :: Maybe Text
queryVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:aggregationField:GetPercentiles' :: Maybe Text
aggregationField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:indexName:GetPercentiles' :: Maybe Text
indexName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:queryString:GetPercentiles' :: Text
queryString = Text
pQueryString_
}
getPercentiles_percents :: Lens.Lens' GetPercentiles (Prelude.Maybe [Prelude.Double])
getPercentiles_percents :: (Maybe [Double] -> f (Maybe [Double]))
-> GetPercentiles -> f GetPercentiles
getPercentiles_percents = (GetPercentiles -> Maybe [Double])
-> (GetPercentiles -> Maybe [Double] -> GetPercentiles)
-> Lens
GetPercentiles GetPercentiles (Maybe [Double]) (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentiles' {Maybe [Double]
percents :: Maybe [Double]
$sel:percents:GetPercentiles' :: GetPercentiles -> Maybe [Double]
percents} -> Maybe [Double]
percents) (\s :: GetPercentiles
s@GetPercentiles' {} Maybe [Double]
a -> GetPercentiles
s {$sel:percents:GetPercentiles' :: Maybe [Double]
percents = Maybe [Double]
a} :: GetPercentiles) ((Maybe [Double] -> f (Maybe [Double]))
-> GetPercentiles -> f GetPercentiles)
-> ((Maybe [Double] -> f (Maybe [Double]))
-> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> GetPercentiles
-> f GetPercentiles
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
(Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
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 [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getPercentiles_queryVersion :: Lens.Lens' GetPercentiles (Prelude.Maybe Prelude.Text)
getPercentiles_queryVersion :: (Maybe Text -> f (Maybe Text))
-> GetPercentiles -> f GetPercentiles
getPercentiles_queryVersion = (GetPercentiles -> Maybe Text)
-> (GetPercentiles -> Maybe Text -> GetPercentiles)
-> Lens GetPercentiles GetPercentiles (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentiles' {Maybe Text
queryVersion :: Maybe Text
$sel:queryVersion:GetPercentiles' :: GetPercentiles -> Maybe Text
queryVersion} -> Maybe Text
queryVersion) (\s :: GetPercentiles
s@GetPercentiles' {} Maybe Text
a -> GetPercentiles
s {$sel:queryVersion:GetPercentiles' :: Maybe Text
queryVersion = Maybe Text
a} :: GetPercentiles)
getPercentiles_aggregationField :: Lens.Lens' GetPercentiles (Prelude.Maybe Prelude.Text)
getPercentiles_aggregationField :: (Maybe Text -> f (Maybe Text))
-> GetPercentiles -> f GetPercentiles
getPercentiles_aggregationField = (GetPercentiles -> Maybe Text)
-> (GetPercentiles -> Maybe Text -> GetPercentiles)
-> Lens GetPercentiles GetPercentiles (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentiles' {Maybe Text
aggregationField :: Maybe Text
$sel:aggregationField:GetPercentiles' :: GetPercentiles -> Maybe Text
aggregationField} -> Maybe Text
aggregationField) (\s :: GetPercentiles
s@GetPercentiles' {} Maybe Text
a -> GetPercentiles
s {$sel:aggregationField:GetPercentiles' :: Maybe Text
aggregationField = Maybe Text
a} :: GetPercentiles)
getPercentiles_indexName :: Lens.Lens' GetPercentiles (Prelude.Maybe Prelude.Text)
getPercentiles_indexName :: (Maybe Text -> f (Maybe Text))
-> GetPercentiles -> f GetPercentiles
getPercentiles_indexName = (GetPercentiles -> Maybe Text)
-> (GetPercentiles -> Maybe Text -> GetPercentiles)
-> Lens GetPercentiles GetPercentiles (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentiles' {Maybe Text
indexName :: Maybe Text
$sel:indexName:GetPercentiles' :: GetPercentiles -> Maybe Text
indexName} -> Maybe Text
indexName) (\s :: GetPercentiles
s@GetPercentiles' {} Maybe Text
a -> GetPercentiles
s {$sel:indexName:GetPercentiles' :: Maybe Text
indexName = Maybe Text
a} :: GetPercentiles)
getPercentiles_queryString :: Lens.Lens' GetPercentiles Prelude.Text
getPercentiles_queryString :: (Text -> f Text) -> GetPercentiles -> f GetPercentiles
getPercentiles_queryString = (GetPercentiles -> Text)
-> (GetPercentiles -> Text -> GetPercentiles)
-> Lens GetPercentiles GetPercentiles Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentiles' {Text
queryString :: Text
$sel:queryString:GetPercentiles' :: GetPercentiles -> Text
queryString} -> Text
queryString) (\s :: GetPercentiles
s@GetPercentiles' {} Text
a -> GetPercentiles
s {$sel:queryString:GetPercentiles' :: Text
queryString = Text
a} :: GetPercentiles)
instance Core.AWSRequest GetPercentiles where
type
AWSResponse GetPercentiles =
GetPercentilesResponse
request :: GetPercentiles -> Request GetPercentiles
request = Service -> GetPercentiles -> Request GetPercentiles
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetPercentiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPercentiles)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetPercentiles))
-> Logger
-> Service
-> Proxy GetPercentiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPercentiles)))
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 [PercentPair] -> Int -> GetPercentilesResponse
GetPercentilesResponse'
(Maybe [PercentPair] -> Int -> GetPercentilesResponse)
-> Either String (Maybe [PercentPair])
-> Either String (Int -> GetPercentilesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PercentPair]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"percentiles" Either String (Maybe (Maybe [PercentPair]))
-> Maybe [PercentPair] -> Either String (Maybe [PercentPair])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PercentPair]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetPercentilesResponse)
-> Either String Int -> Either String GetPercentilesResponse
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 GetPercentiles
instance Prelude.NFData GetPercentiles
instance Core.ToHeaders GetPercentiles where
toHeaders :: GetPercentiles -> ResponseHeaders
toHeaders = ResponseHeaders -> GetPercentiles -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON GetPercentiles where
toJSON :: GetPercentiles -> Value
toJSON GetPercentiles' {Maybe [Double]
Maybe Text
Text
queryString :: Text
indexName :: Maybe Text
aggregationField :: Maybe Text
queryVersion :: Maybe Text
percents :: Maybe [Double]
$sel:queryString:GetPercentiles' :: GetPercentiles -> Text
$sel:indexName:GetPercentiles' :: GetPercentiles -> Maybe Text
$sel:aggregationField:GetPercentiles' :: GetPercentiles -> Maybe Text
$sel:queryVersion:GetPercentiles' :: GetPercentiles -> Maybe Text
$sel:percents:GetPercentiles' :: GetPercentiles -> Maybe [Double]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"percents" Text -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Double] -> Pair) -> Maybe [Double] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Double]
percents,
(Text
"queryVersion" 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
queryVersion,
(Text
"aggregationField" 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
aggregationField,
(Text
"indexName" 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
indexName,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"queryString" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
queryString)
]
)
instance Core.ToPath GetPercentiles where
toPath :: GetPercentiles -> ByteString
toPath = ByteString -> GetPercentiles -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/indices/percentiles"
instance Core.ToQuery GetPercentiles where
toQuery :: GetPercentiles -> QueryString
toQuery = QueryString -> GetPercentiles -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetPercentilesResponse = GetPercentilesResponse'
{
GetPercentilesResponse -> Maybe [PercentPair]
percentiles :: Prelude.Maybe [PercentPair],
GetPercentilesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetPercentilesResponse -> GetPercentilesResponse -> Bool
(GetPercentilesResponse -> GetPercentilesResponse -> Bool)
-> (GetPercentilesResponse -> GetPercentilesResponse -> Bool)
-> Eq GetPercentilesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPercentilesResponse -> GetPercentilesResponse -> Bool
$c/= :: GetPercentilesResponse -> GetPercentilesResponse -> Bool
== :: GetPercentilesResponse -> GetPercentilesResponse -> Bool
$c== :: GetPercentilesResponse -> GetPercentilesResponse -> Bool
Prelude.Eq, ReadPrec [GetPercentilesResponse]
ReadPrec GetPercentilesResponse
Int -> ReadS GetPercentilesResponse
ReadS [GetPercentilesResponse]
(Int -> ReadS GetPercentilesResponse)
-> ReadS [GetPercentilesResponse]
-> ReadPrec GetPercentilesResponse
-> ReadPrec [GetPercentilesResponse]
-> Read GetPercentilesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPercentilesResponse]
$creadListPrec :: ReadPrec [GetPercentilesResponse]
readPrec :: ReadPrec GetPercentilesResponse
$creadPrec :: ReadPrec GetPercentilesResponse
readList :: ReadS [GetPercentilesResponse]
$creadList :: ReadS [GetPercentilesResponse]
readsPrec :: Int -> ReadS GetPercentilesResponse
$creadsPrec :: Int -> ReadS GetPercentilesResponse
Prelude.Read, Int -> GetPercentilesResponse -> ShowS
[GetPercentilesResponse] -> ShowS
GetPercentilesResponse -> String
(Int -> GetPercentilesResponse -> ShowS)
-> (GetPercentilesResponse -> String)
-> ([GetPercentilesResponse] -> ShowS)
-> Show GetPercentilesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPercentilesResponse] -> ShowS
$cshowList :: [GetPercentilesResponse] -> ShowS
show :: GetPercentilesResponse -> String
$cshow :: GetPercentilesResponse -> String
showsPrec :: Int -> GetPercentilesResponse -> ShowS
$cshowsPrec :: Int -> GetPercentilesResponse -> ShowS
Prelude.Show, (forall x. GetPercentilesResponse -> Rep GetPercentilesResponse x)
-> (forall x.
Rep GetPercentilesResponse x -> GetPercentilesResponse)
-> Generic GetPercentilesResponse
forall x. Rep GetPercentilesResponse x -> GetPercentilesResponse
forall x. GetPercentilesResponse -> Rep GetPercentilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPercentilesResponse x -> GetPercentilesResponse
$cfrom :: forall x. GetPercentilesResponse -> Rep GetPercentilesResponse x
Prelude.Generic)
newGetPercentilesResponse ::
Prelude.Int ->
GetPercentilesResponse
newGetPercentilesResponse :: Int -> GetPercentilesResponse
newGetPercentilesResponse Int
pHttpStatus_ =
GetPercentilesResponse' :: Maybe [PercentPair] -> Int -> GetPercentilesResponse
GetPercentilesResponse'
{ $sel:percentiles:GetPercentilesResponse' :: Maybe [PercentPair]
percentiles =
Maybe [PercentPair]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetPercentilesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getPercentilesResponse_percentiles :: Lens.Lens' GetPercentilesResponse (Prelude.Maybe [PercentPair])
getPercentilesResponse_percentiles :: (Maybe [PercentPair] -> f (Maybe [PercentPair]))
-> GetPercentilesResponse -> f GetPercentilesResponse
getPercentilesResponse_percentiles = (GetPercentilesResponse -> Maybe [PercentPair])
-> (GetPercentilesResponse
-> Maybe [PercentPair] -> GetPercentilesResponse)
-> Lens
GetPercentilesResponse
GetPercentilesResponse
(Maybe [PercentPair])
(Maybe [PercentPair])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentilesResponse' {Maybe [PercentPair]
percentiles :: Maybe [PercentPair]
$sel:percentiles:GetPercentilesResponse' :: GetPercentilesResponse -> Maybe [PercentPair]
percentiles} -> Maybe [PercentPair]
percentiles) (\s :: GetPercentilesResponse
s@GetPercentilesResponse' {} Maybe [PercentPair]
a -> GetPercentilesResponse
s {$sel:percentiles:GetPercentilesResponse' :: Maybe [PercentPair]
percentiles = Maybe [PercentPair]
a} :: GetPercentilesResponse) ((Maybe [PercentPair] -> f (Maybe [PercentPair]))
-> GetPercentilesResponse -> f GetPercentilesResponse)
-> ((Maybe [PercentPair] -> f (Maybe [PercentPair]))
-> Maybe [PercentPair] -> f (Maybe [PercentPair]))
-> (Maybe [PercentPair] -> f (Maybe [PercentPair]))
-> GetPercentilesResponse
-> f GetPercentilesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PercentPair] [PercentPair] [PercentPair] [PercentPair]
-> Iso
(Maybe [PercentPair])
(Maybe [PercentPair])
(Maybe [PercentPair])
(Maybe [PercentPair])
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 [PercentPair] [PercentPair] [PercentPair] [PercentPair]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getPercentilesResponse_httpStatus :: Lens.Lens' GetPercentilesResponse Prelude.Int
getPercentilesResponse_httpStatus :: (Int -> f Int)
-> GetPercentilesResponse -> f GetPercentilesResponse
getPercentilesResponse_httpStatus = (GetPercentilesResponse -> Int)
-> (GetPercentilesResponse -> Int -> GetPercentilesResponse)
-> Lens GetPercentilesResponse GetPercentilesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPercentilesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetPercentilesResponse' :: GetPercentilesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetPercentilesResponse
s@GetPercentilesResponse' {} Int
a -> GetPercentilesResponse
s {$sel:httpStatus:GetPercentilesResponse' :: Int
httpStatus = Int
a} :: GetPercentilesResponse)
instance Prelude.NFData GetPercentilesResponse