{-# 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.PutQueryDefinition
(
PutQueryDefinition (..),
newPutQueryDefinition,
putQueryDefinition_logGroupNames,
putQueryDefinition_queryDefinitionId,
putQueryDefinition_name,
putQueryDefinition_queryString,
PutQueryDefinitionResponse (..),
newPutQueryDefinitionResponse,
putQueryDefinitionResponse_queryDefinitionId,
putQueryDefinitionResponse_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 PutQueryDefinition = PutQueryDefinition'
{
PutQueryDefinition -> Maybe [Text]
logGroupNames :: Prelude.Maybe [Prelude.Text],
PutQueryDefinition -> Maybe Text
queryDefinitionId :: Prelude.Maybe Prelude.Text,
PutQueryDefinition -> Text
name :: Prelude.Text,
PutQueryDefinition -> Text
queryString :: Prelude.Text
}
deriving (PutQueryDefinition -> PutQueryDefinition -> Bool
(PutQueryDefinition -> PutQueryDefinition -> Bool)
-> (PutQueryDefinition -> PutQueryDefinition -> Bool)
-> Eq PutQueryDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutQueryDefinition -> PutQueryDefinition -> Bool
$c/= :: PutQueryDefinition -> PutQueryDefinition -> Bool
== :: PutQueryDefinition -> PutQueryDefinition -> Bool
$c== :: PutQueryDefinition -> PutQueryDefinition -> Bool
Prelude.Eq, ReadPrec [PutQueryDefinition]
ReadPrec PutQueryDefinition
Int -> ReadS PutQueryDefinition
ReadS [PutQueryDefinition]
(Int -> ReadS PutQueryDefinition)
-> ReadS [PutQueryDefinition]
-> ReadPrec PutQueryDefinition
-> ReadPrec [PutQueryDefinition]
-> Read PutQueryDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutQueryDefinition]
$creadListPrec :: ReadPrec [PutQueryDefinition]
readPrec :: ReadPrec PutQueryDefinition
$creadPrec :: ReadPrec PutQueryDefinition
readList :: ReadS [PutQueryDefinition]
$creadList :: ReadS [PutQueryDefinition]
readsPrec :: Int -> ReadS PutQueryDefinition
$creadsPrec :: Int -> ReadS PutQueryDefinition
Prelude.Read, Int -> PutQueryDefinition -> ShowS
[PutQueryDefinition] -> ShowS
PutQueryDefinition -> String
(Int -> PutQueryDefinition -> ShowS)
-> (PutQueryDefinition -> String)
-> ([PutQueryDefinition] -> ShowS)
-> Show PutQueryDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutQueryDefinition] -> ShowS
$cshowList :: [PutQueryDefinition] -> ShowS
show :: PutQueryDefinition -> String
$cshow :: PutQueryDefinition -> String
showsPrec :: Int -> PutQueryDefinition -> ShowS
$cshowsPrec :: Int -> PutQueryDefinition -> ShowS
Prelude.Show, (forall x. PutQueryDefinition -> Rep PutQueryDefinition x)
-> (forall x. Rep PutQueryDefinition x -> PutQueryDefinition)
-> Generic PutQueryDefinition
forall x. Rep PutQueryDefinition x -> PutQueryDefinition
forall x. PutQueryDefinition -> Rep PutQueryDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutQueryDefinition x -> PutQueryDefinition
$cfrom :: forall x. PutQueryDefinition -> Rep PutQueryDefinition x
Prelude.Generic)
newPutQueryDefinition ::
Prelude.Text ->
Prelude.Text ->
PutQueryDefinition
newPutQueryDefinition :: Text -> Text -> PutQueryDefinition
newPutQueryDefinition Text
pName_ Text
pQueryString_ =
PutQueryDefinition' :: Maybe [Text] -> Maybe Text -> Text -> Text -> PutQueryDefinition
PutQueryDefinition'
{ $sel:logGroupNames:PutQueryDefinition' :: Maybe [Text]
logGroupNames =
Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:queryDefinitionId:PutQueryDefinition' :: Maybe Text
queryDefinitionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:PutQueryDefinition' :: Text
name = Text
pName_,
$sel:queryString:PutQueryDefinition' :: Text
queryString = Text
pQueryString_
}
putQueryDefinition_logGroupNames :: Lens.Lens' PutQueryDefinition (Prelude.Maybe [Prelude.Text])
putQueryDefinition_logGroupNames :: (Maybe [Text] -> f (Maybe [Text]))
-> PutQueryDefinition -> f PutQueryDefinition
putQueryDefinition_logGroupNames = (PutQueryDefinition -> Maybe [Text])
-> (PutQueryDefinition -> Maybe [Text] -> PutQueryDefinition)
-> Lens
PutQueryDefinition PutQueryDefinition (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinition' {Maybe [Text]
logGroupNames :: Maybe [Text]
$sel:logGroupNames:PutQueryDefinition' :: PutQueryDefinition -> Maybe [Text]
logGroupNames} -> Maybe [Text]
logGroupNames) (\s :: PutQueryDefinition
s@PutQueryDefinition' {} Maybe [Text]
a -> PutQueryDefinition
s {$sel:logGroupNames:PutQueryDefinition' :: Maybe [Text]
logGroupNames = Maybe [Text]
a} :: PutQueryDefinition) ((Maybe [Text] -> f (Maybe [Text]))
-> PutQueryDefinition -> f PutQueryDefinition)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutQueryDefinition
-> f PutQueryDefinition
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
putQueryDefinition_queryDefinitionId :: Lens.Lens' PutQueryDefinition (Prelude.Maybe Prelude.Text)
putQueryDefinition_queryDefinitionId :: (Maybe Text -> f (Maybe Text))
-> PutQueryDefinition -> f PutQueryDefinition
putQueryDefinition_queryDefinitionId = (PutQueryDefinition -> Maybe Text)
-> (PutQueryDefinition -> Maybe Text -> PutQueryDefinition)
-> Lens
PutQueryDefinition PutQueryDefinition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinition' {Maybe Text
queryDefinitionId :: Maybe Text
$sel:queryDefinitionId:PutQueryDefinition' :: PutQueryDefinition -> Maybe Text
queryDefinitionId} -> Maybe Text
queryDefinitionId) (\s :: PutQueryDefinition
s@PutQueryDefinition' {} Maybe Text
a -> PutQueryDefinition
s {$sel:queryDefinitionId:PutQueryDefinition' :: Maybe Text
queryDefinitionId = Maybe Text
a} :: PutQueryDefinition)
putQueryDefinition_name :: Lens.Lens' PutQueryDefinition Prelude.Text
putQueryDefinition_name :: (Text -> f Text) -> PutQueryDefinition -> f PutQueryDefinition
putQueryDefinition_name = (PutQueryDefinition -> Text)
-> (PutQueryDefinition -> Text -> PutQueryDefinition)
-> Lens PutQueryDefinition PutQueryDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinition' {Text
name :: Text
$sel:name:PutQueryDefinition' :: PutQueryDefinition -> Text
name} -> Text
name) (\s :: PutQueryDefinition
s@PutQueryDefinition' {} Text
a -> PutQueryDefinition
s {$sel:name:PutQueryDefinition' :: Text
name = Text
a} :: PutQueryDefinition)
putQueryDefinition_queryString :: Lens.Lens' PutQueryDefinition Prelude.Text
putQueryDefinition_queryString :: (Text -> f Text) -> PutQueryDefinition -> f PutQueryDefinition
putQueryDefinition_queryString = (PutQueryDefinition -> Text)
-> (PutQueryDefinition -> Text -> PutQueryDefinition)
-> Lens PutQueryDefinition PutQueryDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinition' {Text
queryString :: Text
$sel:queryString:PutQueryDefinition' :: PutQueryDefinition -> Text
queryString} -> Text
queryString) (\s :: PutQueryDefinition
s@PutQueryDefinition' {} Text
a -> PutQueryDefinition
s {$sel:queryString:PutQueryDefinition' :: Text
queryString = Text
a} :: PutQueryDefinition)
instance Core.AWSRequest PutQueryDefinition where
type
AWSResponse PutQueryDefinition =
PutQueryDefinitionResponse
request :: PutQueryDefinition -> Request PutQueryDefinition
request = Service -> PutQueryDefinition -> Request PutQueryDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutQueryDefinition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutQueryDefinition)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutQueryDefinition))
-> Logger
-> Service
-> Proxy PutQueryDefinition
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutQueryDefinition)))
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 -> PutQueryDefinitionResponse
PutQueryDefinitionResponse'
(Maybe Text -> Int -> PutQueryDefinitionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutQueryDefinitionResponse)
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
"queryDefinitionId")
Either String (Int -> PutQueryDefinitionResponse)
-> Either String Int -> Either String PutQueryDefinitionResponse
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 PutQueryDefinition
instance Prelude.NFData PutQueryDefinition
instance Core.ToHeaders PutQueryDefinition where
toHeaders :: PutQueryDefinition -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutQueryDefinition -> 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.PutQueryDefinition" ::
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 PutQueryDefinition where
toJSON :: PutQueryDefinition -> Value
toJSON PutQueryDefinition' {Maybe [Text]
Maybe Text
Text
queryString :: Text
name :: Text
queryDefinitionId :: Maybe Text
logGroupNames :: Maybe [Text]
$sel:queryString:PutQueryDefinition' :: PutQueryDefinition -> Text
$sel:name:PutQueryDefinition' :: PutQueryDefinition -> Text
$sel:queryDefinitionId:PutQueryDefinition' :: PutQueryDefinition -> Maybe Text
$sel:logGroupNames:PutQueryDefinition' :: PutQueryDefinition -> 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
"queryDefinitionId" 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
queryDefinitionId,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
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 PutQueryDefinition where
toPath :: PutQueryDefinition -> ByteString
toPath = ByteString -> PutQueryDefinition -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutQueryDefinition where
toQuery :: PutQueryDefinition -> QueryString
toQuery = QueryString -> PutQueryDefinition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutQueryDefinitionResponse = PutQueryDefinitionResponse'
{
PutQueryDefinitionResponse -> Maybe Text
queryDefinitionId :: Prelude.Maybe Prelude.Text,
PutQueryDefinitionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool
(PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool)
-> (PutQueryDefinitionResponse
-> PutQueryDefinitionResponse -> Bool)
-> Eq PutQueryDefinitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool
$c/= :: PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool
== :: PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool
$c== :: PutQueryDefinitionResponse -> PutQueryDefinitionResponse -> Bool
Prelude.Eq, ReadPrec [PutQueryDefinitionResponse]
ReadPrec PutQueryDefinitionResponse
Int -> ReadS PutQueryDefinitionResponse
ReadS [PutQueryDefinitionResponse]
(Int -> ReadS PutQueryDefinitionResponse)
-> ReadS [PutQueryDefinitionResponse]
-> ReadPrec PutQueryDefinitionResponse
-> ReadPrec [PutQueryDefinitionResponse]
-> Read PutQueryDefinitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutQueryDefinitionResponse]
$creadListPrec :: ReadPrec [PutQueryDefinitionResponse]
readPrec :: ReadPrec PutQueryDefinitionResponse
$creadPrec :: ReadPrec PutQueryDefinitionResponse
readList :: ReadS [PutQueryDefinitionResponse]
$creadList :: ReadS [PutQueryDefinitionResponse]
readsPrec :: Int -> ReadS PutQueryDefinitionResponse
$creadsPrec :: Int -> ReadS PutQueryDefinitionResponse
Prelude.Read, Int -> PutQueryDefinitionResponse -> ShowS
[PutQueryDefinitionResponse] -> ShowS
PutQueryDefinitionResponse -> String
(Int -> PutQueryDefinitionResponse -> ShowS)
-> (PutQueryDefinitionResponse -> String)
-> ([PutQueryDefinitionResponse] -> ShowS)
-> Show PutQueryDefinitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutQueryDefinitionResponse] -> ShowS
$cshowList :: [PutQueryDefinitionResponse] -> ShowS
show :: PutQueryDefinitionResponse -> String
$cshow :: PutQueryDefinitionResponse -> String
showsPrec :: Int -> PutQueryDefinitionResponse -> ShowS
$cshowsPrec :: Int -> PutQueryDefinitionResponse -> ShowS
Prelude.Show, (forall x.
PutQueryDefinitionResponse -> Rep PutQueryDefinitionResponse x)
-> (forall x.
Rep PutQueryDefinitionResponse x -> PutQueryDefinitionResponse)
-> Generic PutQueryDefinitionResponse
forall x.
Rep PutQueryDefinitionResponse x -> PutQueryDefinitionResponse
forall x.
PutQueryDefinitionResponse -> Rep PutQueryDefinitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutQueryDefinitionResponse x -> PutQueryDefinitionResponse
$cfrom :: forall x.
PutQueryDefinitionResponse -> Rep PutQueryDefinitionResponse x
Prelude.Generic)
newPutQueryDefinitionResponse ::
Prelude.Int ->
PutQueryDefinitionResponse
newPutQueryDefinitionResponse :: Int -> PutQueryDefinitionResponse
newPutQueryDefinitionResponse Int
pHttpStatus_ =
PutQueryDefinitionResponse' :: Maybe Text -> Int -> PutQueryDefinitionResponse
PutQueryDefinitionResponse'
{ $sel:queryDefinitionId:PutQueryDefinitionResponse' :: Maybe Text
queryDefinitionId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutQueryDefinitionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putQueryDefinitionResponse_queryDefinitionId :: Lens.Lens' PutQueryDefinitionResponse (Prelude.Maybe Prelude.Text)
putQueryDefinitionResponse_queryDefinitionId :: (Maybe Text -> f (Maybe Text))
-> PutQueryDefinitionResponse -> f PutQueryDefinitionResponse
putQueryDefinitionResponse_queryDefinitionId = (PutQueryDefinitionResponse -> Maybe Text)
-> (PutQueryDefinitionResponse
-> Maybe Text -> PutQueryDefinitionResponse)
-> Lens
PutQueryDefinitionResponse
PutQueryDefinitionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinitionResponse' {Maybe Text
queryDefinitionId :: Maybe Text
$sel:queryDefinitionId:PutQueryDefinitionResponse' :: PutQueryDefinitionResponse -> Maybe Text
queryDefinitionId} -> Maybe Text
queryDefinitionId) (\s :: PutQueryDefinitionResponse
s@PutQueryDefinitionResponse' {} Maybe Text
a -> PutQueryDefinitionResponse
s {$sel:queryDefinitionId:PutQueryDefinitionResponse' :: Maybe Text
queryDefinitionId = Maybe Text
a} :: PutQueryDefinitionResponse)
putQueryDefinitionResponse_httpStatus :: Lens.Lens' PutQueryDefinitionResponse Prelude.Int
putQueryDefinitionResponse_httpStatus :: (Int -> f Int)
-> PutQueryDefinitionResponse -> f PutQueryDefinitionResponse
putQueryDefinitionResponse_httpStatus = (PutQueryDefinitionResponse -> Int)
-> (PutQueryDefinitionResponse
-> Int -> PutQueryDefinitionResponse)
-> Lens
PutQueryDefinitionResponse PutQueryDefinitionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutQueryDefinitionResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutQueryDefinitionResponse' :: PutQueryDefinitionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutQueryDefinitionResponse
s@PutQueryDefinitionResponse' {} Int
a -> PutQueryDefinitionResponse
s {$sel:httpStatus:PutQueryDefinitionResponse' :: Int
httpStatus = Int
a} :: PutQueryDefinitionResponse)
instance Prelude.NFData PutQueryDefinitionResponse