{-# 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.PutDestination
(
PutDestination (..),
newPutDestination,
putDestination_destinationName,
putDestination_targetArn,
putDestination_roleArn,
PutDestinationResponse (..),
newPutDestinationResponse,
putDestinationResponse_destination,
putDestinationResponse_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 PutDestination = PutDestination'
{
PutDestination -> Text
destinationName :: Prelude.Text,
PutDestination -> Text
targetArn :: Prelude.Text,
PutDestination -> Text
roleArn :: Prelude.Text
}
deriving (PutDestination -> PutDestination -> Bool
(PutDestination -> PutDestination -> Bool)
-> (PutDestination -> PutDestination -> Bool) -> Eq PutDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDestination -> PutDestination -> Bool
$c/= :: PutDestination -> PutDestination -> Bool
== :: PutDestination -> PutDestination -> Bool
$c== :: PutDestination -> PutDestination -> Bool
Prelude.Eq, ReadPrec [PutDestination]
ReadPrec PutDestination
Int -> ReadS PutDestination
ReadS [PutDestination]
(Int -> ReadS PutDestination)
-> ReadS [PutDestination]
-> ReadPrec PutDestination
-> ReadPrec [PutDestination]
-> Read PutDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDestination]
$creadListPrec :: ReadPrec [PutDestination]
readPrec :: ReadPrec PutDestination
$creadPrec :: ReadPrec PutDestination
readList :: ReadS [PutDestination]
$creadList :: ReadS [PutDestination]
readsPrec :: Int -> ReadS PutDestination
$creadsPrec :: Int -> ReadS PutDestination
Prelude.Read, Int -> PutDestination -> ShowS
[PutDestination] -> ShowS
PutDestination -> String
(Int -> PutDestination -> ShowS)
-> (PutDestination -> String)
-> ([PutDestination] -> ShowS)
-> Show PutDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDestination] -> ShowS
$cshowList :: [PutDestination] -> ShowS
show :: PutDestination -> String
$cshow :: PutDestination -> String
showsPrec :: Int -> PutDestination -> ShowS
$cshowsPrec :: Int -> PutDestination -> ShowS
Prelude.Show, (forall x. PutDestination -> Rep PutDestination x)
-> (forall x. Rep PutDestination x -> PutDestination)
-> Generic PutDestination
forall x. Rep PutDestination x -> PutDestination
forall x. PutDestination -> Rep PutDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutDestination x -> PutDestination
$cfrom :: forall x. PutDestination -> Rep PutDestination x
Prelude.Generic)
newPutDestination ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
PutDestination
newPutDestination :: Text -> Text -> Text -> PutDestination
newPutDestination
Text
pDestinationName_
Text
pTargetArn_
Text
pRoleArn_ =
PutDestination' :: Text -> Text -> Text -> PutDestination
PutDestination'
{ $sel:destinationName:PutDestination' :: Text
destinationName =
Text
pDestinationName_,
$sel:targetArn:PutDestination' :: Text
targetArn = Text
pTargetArn_,
$sel:roleArn:PutDestination' :: Text
roleArn = Text
pRoleArn_
}
putDestination_destinationName :: Lens.Lens' PutDestination Prelude.Text
putDestination_destinationName :: (Text -> f Text) -> PutDestination -> f PutDestination
putDestination_destinationName = (PutDestination -> Text)
-> (PutDestination -> Text -> PutDestination)
-> Lens PutDestination PutDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDestination' {Text
destinationName :: Text
$sel:destinationName:PutDestination' :: PutDestination -> Text
destinationName} -> Text
destinationName) (\s :: PutDestination
s@PutDestination' {} Text
a -> PutDestination
s {$sel:destinationName:PutDestination' :: Text
destinationName = Text
a} :: PutDestination)
putDestination_targetArn :: Lens.Lens' PutDestination Prelude.Text
putDestination_targetArn :: (Text -> f Text) -> PutDestination -> f PutDestination
putDestination_targetArn = (PutDestination -> Text)
-> (PutDestination -> Text -> PutDestination)
-> Lens PutDestination PutDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDestination' {Text
targetArn :: Text
$sel:targetArn:PutDestination' :: PutDestination -> Text
targetArn} -> Text
targetArn) (\s :: PutDestination
s@PutDestination' {} Text
a -> PutDestination
s {$sel:targetArn:PutDestination' :: Text
targetArn = Text
a} :: PutDestination)
putDestination_roleArn :: Lens.Lens' PutDestination Prelude.Text
putDestination_roleArn :: (Text -> f Text) -> PutDestination -> f PutDestination
putDestination_roleArn = (PutDestination -> Text)
-> (PutDestination -> Text -> PutDestination)
-> Lens PutDestination PutDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDestination' {Text
roleArn :: Text
$sel:roleArn:PutDestination' :: PutDestination -> Text
roleArn} -> Text
roleArn) (\s :: PutDestination
s@PutDestination' {} Text
a -> PutDestination
s {$sel:roleArn:PutDestination' :: Text
roleArn = Text
a} :: PutDestination)
instance Core.AWSRequest PutDestination where
type
AWSResponse PutDestination =
PutDestinationResponse
request :: PutDestination -> Request PutDestination
request = Service -> PutDestination -> Request PutDestination
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutDestination
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutDestination)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutDestination))
-> Logger
-> Service
-> Proxy PutDestination
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutDestination)))
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 Destination -> Int -> PutDestinationResponse
PutDestinationResponse'
(Maybe Destination -> Int -> PutDestinationResponse)
-> Either String (Maybe Destination)
-> Either String (Int -> PutDestinationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Destination)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"destination")
Either String (Int -> PutDestinationResponse)
-> Either String Int -> Either String PutDestinationResponse
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 PutDestination
instance Prelude.NFData PutDestination
instance Core.ToHeaders PutDestination where
toHeaders :: PutDestination -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutDestination -> 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.PutDestination" ::
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 PutDestination where
toJSON :: PutDestination -> Value
toJSON PutDestination' {Text
roleArn :: Text
targetArn :: Text
destinationName :: Text
$sel:roleArn:PutDestination' :: PutDestination -> Text
$sel:targetArn:PutDestination' :: PutDestination -> Text
$sel:destinationName:PutDestination' :: PutDestination -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"destinationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
]
)
instance Core.ToPath PutDestination where
toPath :: PutDestination -> ByteString
toPath = ByteString -> PutDestination -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutDestination where
toQuery :: PutDestination -> QueryString
toQuery = QueryString -> PutDestination -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutDestinationResponse = PutDestinationResponse'
{
PutDestinationResponse -> Maybe Destination
destination :: Prelude.Maybe Destination,
PutDestinationResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutDestinationResponse -> PutDestinationResponse -> Bool
(PutDestinationResponse -> PutDestinationResponse -> Bool)
-> (PutDestinationResponse -> PutDestinationResponse -> Bool)
-> Eq PutDestinationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutDestinationResponse -> PutDestinationResponse -> Bool
$c/= :: PutDestinationResponse -> PutDestinationResponse -> Bool
== :: PutDestinationResponse -> PutDestinationResponse -> Bool
$c== :: PutDestinationResponse -> PutDestinationResponse -> Bool
Prelude.Eq, ReadPrec [PutDestinationResponse]
ReadPrec PutDestinationResponse
Int -> ReadS PutDestinationResponse
ReadS [PutDestinationResponse]
(Int -> ReadS PutDestinationResponse)
-> ReadS [PutDestinationResponse]
-> ReadPrec PutDestinationResponse
-> ReadPrec [PutDestinationResponse]
-> Read PutDestinationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutDestinationResponse]
$creadListPrec :: ReadPrec [PutDestinationResponse]
readPrec :: ReadPrec PutDestinationResponse
$creadPrec :: ReadPrec PutDestinationResponse
readList :: ReadS [PutDestinationResponse]
$creadList :: ReadS [PutDestinationResponse]
readsPrec :: Int -> ReadS PutDestinationResponse
$creadsPrec :: Int -> ReadS PutDestinationResponse
Prelude.Read, Int -> PutDestinationResponse -> ShowS
[PutDestinationResponse] -> ShowS
PutDestinationResponse -> String
(Int -> PutDestinationResponse -> ShowS)
-> (PutDestinationResponse -> String)
-> ([PutDestinationResponse] -> ShowS)
-> Show PutDestinationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutDestinationResponse] -> ShowS
$cshowList :: [PutDestinationResponse] -> ShowS
show :: PutDestinationResponse -> String
$cshow :: PutDestinationResponse -> String
showsPrec :: Int -> PutDestinationResponse -> ShowS
$cshowsPrec :: Int -> PutDestinationResponse -> ShowS
Prelude.Show, (forall x. PutDestinationResponse -> Rep PutDestinationResponse x)
-> (forall x.
Rep PutDestinationResponse x -> PutDestinationResponse)
-> Generic PutDestinationResponse
forall x. Rep PutDestinationResponse x -> PutDestinationResponse
forall x. PutDestinationResponse -> Rep PutDestinationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutDestinationResponse x -> PutDestinationResponse
$cfrom :: forall x. PutDestinationResponse -> Rep PutDestinationResponse x
Prelude.Generic)
newPutDestinationResponse ::
Prelude.Int ->
PutDestinationResponse
newPutDestinationResponse :: Int -> PutDestinationResponse
newPutDestinationResponse Int
pHttpStatus_ =
PutDestinationResponse' :: Maybe Destination -> Int -> PutDestinationResponse
PutDestinationResponse'
{ $sel:destination:PutDestinationResponse' :: Maybe Destination
destination =
Maybe Destination
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutDestinationResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putDestinationResponse_destination :: Lens.Lens' PutDestinationResponse (Prelude.Maybe Destination)
putDestinationResponse_destination :: (Maybe Destination -> f (Maybe Destination))
-> PutDestinationResponse -> f PutDestinationResponse
putDestinationResponse_destination = (PutDestinationResponse -> Maybe Destination)
-> (PutDestinationResponse
-> Maybe Destination -> PutDestinationResponse)
-> Lens
PutDestinationResponse
PutDestinationResponse
(Maybe Destination)
(Maybe Destination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDestinationResponse' {Maybe Destination
destination :: Maybe Destination
$sel:destination:PutDestinationResponse' :: PutDestinationResponse -> Maybe Destination
destination} -> Maybe Destination
destination) (\s :: PutDestinationResponse
s@PutDestinationResponse' {} Maybe Destination
a -> PutDestinationResponse
s {$sel:destination:PutDestinationResponse' :: Maybe Destination
destination = Maybe Destination
a} :: PutDestinationResponse)
putDestinationResponse_httpStatus :: Lens.Lens' PutDestinationResponse Prelude.Int
putDestinationResponse_httpStatus :: (Int -> f Int)
-> PutDestinationResponse -> f PutDestinationResponse
putDestinationResponse_httpStatus = (PutDestinationResponse -> Int)
-> (PutDestinationResponse -> Int -> PutDestinationResponse)
-> Lens PutDestinationResponse PutDestinationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDestinationResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutDestinationResponse' :: PutDestinationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutDestinationResponse
s@PutDestinationResponse' {} Int
a -> PutDestinationResponse
s {$sel:httpStatus:PutDestinationResponse' :: Int
httpStatus = Int
a} :: PutDestinationResponse)
instance Prelude.NFData PutDestinationResponse