{-# 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.CloudWatchLogs.StartQuery
(
StartQuery (..),
newStartQuery,
startQuery_logGroupNames,
startQuery_logGroupName,
startQuery_limit,
startQuery_startTime,
startQuery_endTime,
startQuery_queryString,
StartQueryResponse (..),
newStartQueryResponse,
startQueryResponse_queryId,
startQueryResponse_httpStatus,
)
where
import Amazonka.CloudWatchLogs.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 StartQuery = StartQuery'
{
StartQuery -> Maybe [Text]
logGroupNames :: Prelude.Maybe [Prelude.Text],
StartQuery -> Maybe Text
logGroupName :: Prelude.Maybe Prelude.Text,
StartQuery -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
StartQuery -> Natural
startTime :: Prelude.Natural,
StartQuery -> Natural
endTime :: Prelude.Natural,
StartQuery -> Text
queryString :: Prelude.Text
}
deriving (StartQuery -> StartQuery -> Bool
(StartQuery -> StartQuery -> Bool)
-> (StartQuery -> StartQuery -> Bool) -> Eq StartQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartQuery -> StartQuery -> Bool
$c/= :: StartQuery -> StartQuery -> Bool
== :: StartQuery -> StartQuery -> Bool
$c== :: StartQuery -> StartQuery -> Bool
Prelude.Eq, ReadPrec [StartQuery]
ReadPrec StartQuery
Int -> ReadS StartQuery
ReadS [StartQuery]
(Int -> ReadS StartQuery)
-> ReadS [StartQuery]
-> ReadPrec StartQuery
-> ReadPrec [StartQuery]
-> Read StartQuery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartQuery]
$creadListPrec :: ReadPrec [StartQuery]
readPrec :: ReadPrec StartQuery
$creadPrec :: ReadPrec StartQuery
readList :: ReadS [StartQuery]
$creadList :: ReadS [StartQuery]
readsPrec :: Int -> ReadS StartQuery
$creadsPrec :: Int -> ReadS StartQuery
Prelude.Read, Int -> StartQuery -> ShowS
[StartQuery] -> ShowS
StartQuery -> String
(Int -> StartQuery -> ShowS)
-> (StartQuery -> String)
-> ([StartQuery] -> ShowS)
-> Show StartQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartQuery] -> ShowS
$cshowList :: [StartQuery] -> ShowS
show :: StartQuery -> String
$cshow :: StartQuery -> String
showsPrec :: Int -> StartQuery -> ShowS
$cshowsPrec :: Int -> StartQuery -> ShowS
Prelude.Show, (forall x. StartQuery -> Rep StartQuery x)
-> (forall x. Rep StartQuery x -> StartQuery) -> Generic StartQuery
forall x. Rep StartQuery x -> StartQuery
forall x. StartQuery -> Rep StartQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartQuery x -> StartQuery
$cfrom :: forall x. StartQuery -> Rep StartQuery x
Prelude.Generic)
newStartQuery ::
Prelude.Natural ->
Prelude.Natural ->
Prelude.Text ->
StartQuery
newStartQuery :: Natural -> Natural -> Text -> StartQuery
newStartQuery Natural
pStartTime_ Natural
pEndTime_ Text
pQueryString_ =
StartQuery' :: Maybe [Text]
-> Maybe Text
-> Maybe Natural
-> Natural
-> Natural
-> Text
-> StartQuery
StartQuery'
{ $sel:logGroupNames:StartQuery' :: Maybe [Text]
logGroupNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:logGroupName:StartQuery' :: Maybe Text
logGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:limit:StartQuery' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:startTime:StartQuery' :: Natural
startTime = Natural
pStartTime_,
$sel:endTime:StartQuery' :: Natural
endTime = Natural
pEndTime_,
$sel:queryString:StartQuery' :: Text
queryString = Text
pQueryString_
}
startQuery_logGroupNames :: Lens.Lens' StartQuery (Prelude.Maybe [Prelude.Text])
startQuery_logGroupNames :: (Maybe [Text] -> f (Maybe [Text])) -> StartQuery -> f StartQuery
startQuery_logGroupNames = (StartQuery -> Maybe [Text])
-> (StartQuery -> Maybe [Text] -> StartQuery)
-> Lens StartQuery StartQuery (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Maybe [Text]
logGroupNames :: Maybe [Text]
$sel:logGroupNames:StartQuery' :: StartQuery -> Maybe [Text]
logGroupNames} -> Maybe [Text]
logGroupNames) (\s :: StartQuery
s@StartQuery' {} Maybe [Text]
a -> StartQuery
s {$sel:logGroupNames:StartQuery' :: Maybe [Text]
logGroupNames = Maybe [Text]
a} :: StartQuery) ((Maybe [Text] -> f (Maybe [Text])) -> StartQuery -> f StartQuery)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> StartQuery
-> f StartQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
startQuery_logGroupName :: Lens.Lens' StartQuery (Prelude.Maybe Prelude.Text)
startQuery_logGroupName :: (Maybe Text -> f (Maybe Text)) -> StartQuery -> f StartQuery
startQuery_logGroupName = (StartQuery -> Maybe Text)
-> (StartQuery -> Maybe Text -> StartQuery)
-> Lens StartQuery StartQuery (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Maybe Text
logGroupName :: Maybe Text
$sel:logGroupName:StartQuery' :: StartQuery -> Maybe Text
logGroupName} -> Maybe Text
logGroupName) (\s :: StartQuery
s@StartQuery' {} Maybe Text
a -> StartQuery
s {$sel:logGroupName:StartQuery' :: Maybe Text
logGroupName = Maybe Text
a} :: StartQuery)
startQuery_limit :: Lens.Lens' StartQuery (Prelude.Maybe Prelude.Natural)
startQuery_limit :: (Maybe Natural -> f (Maybe Natural)) -> StartQuery -> f StartQuery
startQuery_limit = (StartQuery -> Maybe Natural)
-> (StartQuery -> Maybe Natural -> StartQuery)
-> Lens StartQuery StartQuery (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Maybe Natural
limit :: Maybe Natural
$sel:limit:StartQuery' :: StartQuery -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: StartQuery
s@StartQuery' {} Maybe Natural
a -> StartQuery
s {$sel:limit:StartQuery' :: Maybe Natural
limit = Maybe Natural
a} :: StartQuery)
startQuery_startTime :: Lens.Lens' StartQuery Prelude.Natural
startQuery_startTime :: (Natural -> f Natural) -> StartQuery -> f StartQuery
startQuery_startTime = (StartQuery -> Natural)
-> (StartQuery -> Natural -> StartQuery)
-> Lens StartQuery StartQuery Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Natural
startTime :: Natural
$sel:startTime:StartQuery' :: StartQuery -> Natural
startTime} -> Natural
startTime) (\s :: StartQuery
s@StartQuery' {} Natural
a -> StartQuery
s {$sel:startTime:StartQuery' :: Natural
startTime = Natural
a} :: StartQuery)
startQuery_endTime :: Lens.Lens' StartQuery Prelude.Natural
startQuery_endTime :: (Natural -> f Natural) -> StartQuery -> f StartQuery
startQuery_endTime = (StartQuery -> Natural)
-> (StartQuery -> Natural -> StartQuery)
-> Lens StartQuery StartQuery Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Natural
endTime :: Natural
$sel:endTime:StartQuery' :: StartQuery -> Natural
endTime} -> Natural
endTime) (\s :: StartQuery
s@StartQuery' {} Natural
a -> StartQuery
s {$sel:endTime:StartQuery' :: Natural
endTime = Natural
a} :: StartQuery)
startQuery_queryString :: Lens.Lens' StartQuery Prelude.Text
startQuery_queryString :: (Text -> f Text) -> StartQuery -> f StartQuery
startQuery_queryString = (StartQuery -> Text)
-> (StartQuery -> Text -> StartQuery)
-> Lens StartQuery StartQuery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQuery' {Text
queryString :: Text
$sel:queryString:StartQuery' :: StartQuery -> Text
queryString} -> Text
queryString) (\s :: StartQuery
s@StartQuery' {} Text
a -> StartQuery
s {$sel:queryString:StartQuery' :: Text
queryString = Text
a} :: StartQuery)
instance Core.AWSRequest StartQuery where
type AWSResponse StartQuery = StartQueryResponse
request :: StartQuery -> Request StartQuery
request = Service -> StartQuery -> Request StartQuery
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy StartQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartQuery)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse StartQuery))
-> Logger
-> Service
-> Proxy StartQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartQuery)))
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 -> Int -> StartQueryResponse
StartQueryResponse'
(Maybe Text -> Int -> StartQueryResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StartQueryResponse)
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
"queryId")
Either String (Int -> StartQueryResponse)
-> Either String Int -> Either String StartQueryResponse
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 StartQuery
instance Prelude.NFData StartQuery
instance Core.ToHeaders StartQuery where
toHeaders :: StartQuery -> ResponseHeaders
toHeaders =
ResponseHeaders -> StartQuery -> 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
"Logs_20140328.StartQuery" :: 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 StartQuery where
toJSON :: StartQuery -> Value
toJSON StartQuery' {Natural
Maybe Natural
Maybe [Text]
Maybe Text
Text
queryString :: Text
endTime :: Natural
startTime :: Natural
limit :: Maybe Natural
logGroupName :: Maybe Text
logGroupNames :: Maybe [Text]
$sel:queryString:StartQuery' :: StartQuery -> Text
$sel:endTime:StartQuery' :: StartQuery -> Natural
$sel:startTime:StartQuery' :: StartQuery -> Natural
$sel:limit:StartQuery' :: StartQuery -> Maybe Natural
$sel:logGroupName:StartQuery' :: StartQuery -> Maybe Text
$sel:logGroupNames:StartQuery' :: StartQuery -> Maybe [Text]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"logGroupNames" 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]
logGroupNames,
(Text
"logGroupName" 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
logGroupName,
(Text
"limit" 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
limit,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
startTime),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endTime" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
endTime),
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 StartQuery where
toPath :: StartQuery -> ByteString
toPath = ByteString -> StartQuery -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery StartQuery where
toQuery :: StartQuery -> QueryString
toQuery = QueryString -> StartQuery -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data StartQueryResponse = StartQueryResponse'
{
StartQueryResponse -> Maybe Text
queryId :: Prelude.Maybe Prelude.Text,
StartQueryResponse -> Int
httpStatus :: Prelude.Int
}
deriving (StartQueryResponse -> StartQueryResponse -> Bool
(StartQueryResponse -> StartQueryResponse -> Bool)
-> (StartQueryResponse -> StartQueryResponse -> Bool)
-> Eq StartQueryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartQueryResponse -> StartQueryResponse -> Bool
$c/= :: StartQueryResponse -> StartQueryResponse -> Bool
== :: StartQueryResponse -> StartQueryResponse -> Bool
$c== :: StartQueryResponse -> StartQueryResponse -> Bool
Prelude.Eq, ReadPrec [StartQueryResponse]
ReadPrec StartQueryResponse
Int -> ReadS StartQueryResponse
ReadS [StartQueryResponse]
(Int -> ReadS StartQueryResponse)
-> ReadS [StartQueryResponse]
-> ReadPrec StartQueryResponse
-> ReadPrec [StartQueryResponse]
-> Read StartQueryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartQueryResponse]
$creadListPrec :: ReadPrec [StartQueryResponse]
readPrec :: ReadPrec StartQueryResponse
$creadPrec :: ReadPrec StartQueryResponse
readList :: ReadS [StartQueryResponse]
$creadList :: ReadS [StartQueryResponse]
readsPrec :: Int -> ReadS StartQueryResponse
$creadsPrec :: Int -> ReadS StartQueryResponse
Prelude.Read, Int -> StartQueryResponse -> ShowS
[StartQueryResponse] -> ShowS
StartQueryResponse -> String
(Int -> StartQueryResponse -> ShowS)
-> (StartQueryResponse -> String)
-> ([StartQueryResponse] -> ShowS)
-> Show StartQueryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartQueryResponse] -> ShowS
$cshowList :: [StartQueryResponse] -> ShowS
show :: StartQueryResponse -> String
$cshow :: StartQueryResponse -> String
showsPrec :: Int -> StartQueryResponse -> ShowS
$cshowsPrec :: Int -> StartQueryResponse -> ShowS
Prelude.Show, (forall x. StartQueryResponse -> Rep StartQueryResponse x)
-> (forall x. Rep StartQueryResponse x -> StartQueryResponse)
-> Generic StartQueryResponse
forall x. Rep StartQueryResponse x -> StartQueryResponse
forall x. StartQueryResponse -> Rep StartQueryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartQueryResponse x -> StartQueryResponse
$cfrom :: forall x. StartQueryResponse -> Rep StartQueryResponse x
Prelude.Generic)
newStartQueryResponse ::
Prelude.Int ->
StartQueryResponse
newStartQueryResponse :: Int -> StartQueryResponse
newStartQueryResponse Int
pHttpStatus_ =
StartQueryResponse' :: Maybe Text -> Int -> StartQueryResponse
StartQueryResponse'
{ $sel:queryId:StartQueryResponse' :: Maybe Text
queryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:StartQueryResponse' :: Int
httpStatus = Int
pHttpStatus_
}
startQueryResponse_queryId :: Lens.Lens' StartQueryResponse (Prelude.Maybe Prelude.Text)
startQueryResponse_queryId :: (Maybe Text -> f (Maybe Text))
-> StartQueryResponse -> f StartQueryResponse
startQueryResponse_queryId = (StartQueryResponse -> Maybe Text)
-> (StartQueryResponse -> Maybe Text -> StartQueryResponse)
-> Lens
StartQueryResponse StartQueryResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryResponse' {Maybe Text
queryId :: Maybe Text
$sel:queryId:StartQueryResponse' :: StartQueryResponse -> Maybe Text
queryId} -> Maybe Text
queryId) (\s :: StartQueryResponse
s@StartQueryResponse' {} Maybe Text
a -> StartQueryResponse
s {$sel:queryId:StartQueryResponse' :: Maybe Text
queryId = Maybe Text
a} :: StartQueryResponse)
startQueryResponse_httpStatus :: Lens.Lens' StartQueryResponse Prelude.Int
startQueryResponse_httpStatus :: (Int -> f Int) -> StartQueryResponse -> f StartQueryResponse
startQueryResponse_httpStatus = (StartQueryResponse -> Int)
-> (StartQueryResponse -> Int -> StartQueryResponse)
-> Lens StartQueryResponse StartQueryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartQueryResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartQueryResponse' :: StartQueryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StartQueryResponse
s@StartQueryResponse' {} Int
a -> StartQueryResponse
s {$sel:httpStatus:StartQueryResponse' :: Int
httpStatus = Int
a} :: StartQueryResponse)
instance Prelude.NFData StartQueryResponse