{-# 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.XRay.CreateSamplingRule
(
CreateSamplingRule (..),
newCreateSamplingRule,
createSamplingRule_tags,
createSamplingRule_samplingRule,
CreateSamplingRuleResponse (..),
newCreateSamplingRuleResponse,
createSamplingRuleResponse_samplingRuleRecord,
createSamplingRuleResponse_httpStatus,
)
where
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
import Amazonka.XRay.Types
data CreateSamplingRule = CreateSamplingRule'
{
CreateSamplingRule -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateSamplingRule -> SamplingRule
samplingRule :: SamplingRule
}
deriving (CreateSamplingRule -> CreateSamplingRule -> Bool
(CreateSamplingRule -> CreateSamplingRule -> Bool)
-> (CreateSamplingRule -> CreateSamplingRule -> Bool)
-> Eq CreateSamplingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSamplingRule -> CreateSamplingRule -> Bool
$c/= :: CreateSamplingRule -> CreateSamplingRule -> Bool
== :: CreateSamplingRule -> CreateSamplingRule -> Bool
$c== :: CreateSamplingRule -> CreateSamplingRule -> Bool
Prelude.Eq, ReadPrec [CreateSamplingRule]
ReadPrec CreateSamplingRule
Int -> ReadS CreateSamplingRule
ReadS [CreateSamplingRule]
(Int -> ReadS CreateSamplingRule)
-> ReadS [CreateSamplingRule]
-> ReadPrec CreateSamplingRule
-> ReadPrec [CreateSamplingRule]
-> Read CreateSamplingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSamplingRule]
$creadListPrec :: ReadPrec [CreateSamplingRule]
readPrec :: ReadPrec CreateSamplingRule
$creadPrec :: ReadPrec CreateSamplingRule
readList :: ReadS [CreateSamplingRule]
$creadList :: ReadS [CreateSamplingRule]
readsPrec :: Int -> ReadS CreateSamplingRule
$creadsPrec :: Int -> ReadS CreateSamplingRule
Prelude.Read, Int -> CreateSamplingRule -> ShowS
[CreateSamplingRule] -> ShowS
CreateSamplingRule -> String
(Int -> CreateSamplingRule -> ShowS)
-> (CreateSamplingRule -> String)
-> ([CreateSamplingRule] -> ShowS)
-> Show CreateSamplingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSamplingRule] -> ShowS
$cshowList :: [CreateSamplingRule] -> ShowS
show :: CreateSamplingRule -> String
$cshow :: CreateSamplingRule -> String
showsPrec :: Int -> CreateSamplingRule -> ShowS
$cshowsPrec :: Int -> CreateSamplingRule -> ShowS
Prelude.Show, (forall x. CreateSamplingRule -> Rep CreateSamplingRule x)
-> (forall x. Rep CreateSamplingRule x -> CreateSamplingRule)
-> Generic CreateSamplingRule
forall x. Rep CreateSamplingRule x -> CreateSamplingRule
forall x. CreateSamplingRule -> Rep CreateSamplingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSamplingRule x -> CreateSamplingRule
$cfrom :: forall x. CreateSamplingRule -> Rep CreateSamplingRule x
Prelude.Generic)
newCreateSamplingRule ::
SamplingRule ->
CreateSamplingRule
newCreateSamplingRule :: SamplingRule -> CreateSamplingRule
newCreateSamplingRule SamplingRule
pSamplingRule_ =
CreateSamplingRule' :: Maybe [Tag] -> SamplingRule -> CreateSamplingRule
CreateSamplingRule'
{ $sel:tags:CreateSamplingRule' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:samplingRule:CreateSamplingRule' :: SamplingRule
samplingRule = SamplingRule
pSamplingRule_
}
createSamplingRule_tags :: Lens.Lens' CreateSamplingRule (Prelude.Maybe [Tag])
createSamplingRule_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSamplingRule -> f CreateSamplingRule
createSamplingRule_tags = (CreateSamplingRule -> Maybe [Tag])
-> (CreateSamplingRule -> Maybe [Tag] -> CreateSamplingRule)
-> Lens
CreateSamplingRule CreateSamplingRule (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSamplingRule' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateSamplingRule' :: CreateSamplingRule -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateSamplingRule
s@CreateSamplingRule' {} Maybe [Tag]
a -> CreateSamplingRule
s {$sel:tags:CreateSamplingRule' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateSamplingRule) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSamplingRule -> f CreateSamplingRule)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateSamplingRule
-> f CreateSamplingRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createSamplingRule_samplingRule :: Lens.Lens' CreateSamplingRule SamplingRule
createSamplingRule_samplingRule :: (SamplingRule -> f SamplingRule)
-> CreateSamplingRule -> f CreateSamplingRule
createSamplingRule_samplingRule = (CreateSamplingRule -> SamplingRule)
-> (CreateSamplingRule -> SamplingRule -> CreateSamplingRule)
-> Lens
CreateSamplingRule CreateSamplingRule SamplingRule SamplingRule
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSamplingRule' {SamplingRule
samplingRule :: SamplingRule
$sel:samplingRule:CreateSamplingRule' :: CreateSamplingRule -> SamplingRule
samplingRule} -> SamplingRule
samplingRule) (\s :: CreateSamplingRule
s@CreateSamplingRule' {} SamplingRule
a -> CreateSamplingRule
s {$sel:samplingRule:CreateSamplingRule' :: SamplingRule
samplingRule = SamplingRule
a} :: CreateSamplingRule)
instance Core.AWSRequest CreateSamplingRule where
type
AWSResponse CreateSamplingRule =
CreateSamplingRuleResponse
request :: CreateSamplingRule -> Request CreateSamplingRule
request = Service -> CreateSamplingRule -> Request CreateSamplingRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSamplingRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateSamplingRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSamplingRule))
-> Logger
-> Service
-> Proxy CreateSamplingRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateSamplingRule)))
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 SamplingRuleRecord -> Int -> CreateSamplingRuleResponse
CreateSamplingRuleResponse'
(Maybe SamplingRuleRecord -> Int -> CreateSamplingRuleResponse)
-> Either String (Maybe SamplingRuleRecord)
-> Either String (Int -> CreateSamplingRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe SamplingRuleRecord)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"SamplingRuleRecord")
Either String (Int -> CreateSamplingRuleResponse)
-> Either String Int -> Either String CreateSamplingRuleResponse
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 CreateSamplingRule
instance Prelude.NFData CreateSamplingRule
instance Core.ToHeaders CreateSamplingRule where
toHeaders :: CreateSamplingRule -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateSamplingRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateSamplingRule where
toJSON :: CreateSamplingRule -> Value
toJSON CreateSamplingRule' {Maybe [Tag]
SamplingRule
samplingRule :: SamplingRule
tags :: Maybe [Tag]
$sel:samplingRule:CreateSamplingRule' :: CreateSamplingRule -> SamplingRule
$sel:tags:CreateSamplingRule' :: CreateSamplingRule -> Maybe [Tag]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Tags" Key -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"SamplingRule" Key -> SamplingRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= SamplingRule
samplingRule)
]
)
instance Core.ToPath CreateSamplingRule where
toPath :: CreateSamplingRule -> ByteString
toPath = ByteString -> CreateSamplingRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/CreateSamplingRule"
instance Core.ToQuery CreateSamplingRule where
toQuery :: CreateSamplingRule -> QueryString
toQuery = QueryString -> CreateSamplingRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSamplingRuleResponse = CreateSamplingRuleResponse'
{
CreateSamplingRuleResponse -> Maybe SamplingRuleRecord
samplingRuleRecord :: Prelude.Maybe SamplingRuleRecord,
CreateSamplingRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool
(CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool)
-> (CreateSamplingRuleResponse
-> CreateSamplingRuleResponse -> Bool)
-> Eq CreateSamplingRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool
$c/= :: CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool
== :: CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool
$c== :: CreateSamplingRuleResponse -> CreateSamplingRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateSamplingRuleResponse]
ReadPrec CreateSamplingRuleResponse
Int -> ReadS CreateSamplingRuleResponse
ReadS [CreateSamplingRuleResponse]
(Int -> ReadS CreateSamplingRuleResponse)
-> ReadS [CreateSamplingRuleResponse]
-> ReadPrec CreateSamplingRuleResponse
-> ReadPrec [CreateSamplingRuleResponse]
-> Read CreateSamplingRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSamplingRuleResponse]
$creadListPrec :: ReadPrec [CreateSamplingRuleResponse]
readPrec :: ReadPrec CreateSamplingRuleResponse
$creadPrec :: ReadPrec CreateSamplingRuleResponse
readList :: ReadS [CreateSamplingRuleResponse]
$creadList :: ReadS [CreateSamplingRuleResponse]
readsPrec :: Int -> ReadS CreateSamplingRuleResponse
$creadsPrec :: Int -> ReadS CreateSamplingRuleResponse
Prelude.Read, Int -> CreateSamplingRuleResponse -> ShowS
[CreateSamplingRuleResponse] -> ShowS
CreateSamplingRuleResponse -> String
(Int -> CreateSamplingRuleResponse -> ShowS)
-> (CreateSamplingRuleResponse -> String)
-> ([CreateSamplingRuleResponse] -> ShowS)
-> Show CreateSamplingRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSamplingRuleResponse] -> ShowS
$cshowList :: [CreateSamplingRuleResponse] -> ShowS
show :: CreateSamplingRuleResponse -> String
$cshow :: CreateSamplingRuleResponse -> String
showsPrec :: Int -> CreateSamplingRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateSamplingRuleResponse -> ShowS
Prelude.Show, (forall x.
CreateSamplingRuleResponse -> Rep CreateSamplingRuleResponse x)
-> (forall x.
Rep CreateSamplingRuleResponse x -> CreateSamplingRuleResponse)
-> Generic CreateSamplingRuleResponse
forall x.
Rep CreateSamplingRuleResponse x -> CreateSamplingRuleResponse
forall x.
CreateSamplingRuleResponse -> Rep CreateSamplingRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateSamplingRuleResponse x -> CreateSamplingRuleResponse
$cfrom :: forall x.
CreateSamplingRuleResponse -> Rep CreateSamplingRuleResponse x
Prelude.Generic)
newCreateSamplingRuleResponse ::
Prelude.Int ->
CreateSamplingRuleResponse
newCreateSamplingRuleResponse :: Int -> CreateSamplingRuleResponse
newCreateSamplingRuleResponse Int
pHttpStatus_ =
CreateSamplingRuleResponse' :: Maybe SamplingRuleRecord -> Int -> CreateSamplingRuleResponse
CreateSamplingRuleResponse'
{ $sel:samplingRuleRecord:CreateSamplingRuleResponse' :: Maybe SamplingRuleRecord
samplingRuleRecord =
Maybe SamplingRuleRecord
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateSamplingRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createSamplingRuleResponse_samplingRuleRecord :: Lens.Lens' CreateSamplingRuleResponse (Prelude.Maybe SamplingRuleRecord)
createSamplingRuleResponse_samplingRuleRecord :: (Maybe SamplingRuleRecord -> f (Maybe SamplingRuleRecord))
-> CreateSamplingRuleResponse -> f CreateSamplingRuleResponse
createSamplingRuleResponse_samplingRuleRecord = (CreateSamplingRuleResponse -> Maybe SamplingRuleRecord)
-> (CreateSamplingRuleResponse
-> Maybe SamplingRuleRecord -> CreateSamplingRuleResponse)
-> Lens
CreateSamplingRuleResponse
CreateSamplingRuleResponse
(Maybe SamplingRuleRecord)
(Maybe SamplingRuleRecord)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSamplingRuleResponse' {Maybe SamplingRuleRecord
samplingRuleRecord :: Maybe SamplingRuleRecord
$sel:samplingRuleRecord:CreateSamplingRuleResponse' :: CreateSamplingRuleResponse -> Maybe SamplingRuleRecord
samplingRuleRecord} -> Maybe SamplingRuleRecord
samplingRuleRecord) (\s :: CreateSamplingRuleResponse
s@CreateSamplingRuleResponse' {} Maybe SamplingRuleRecord
a -> CreateSamplingRuleResponse
s {$sel:samplingRuleRecord:CreateSamplingRuleResponse' :: Maybe SamplingRuleRecord
samplingRuleRecord = Maybe SamplingRuleRecord
a} :: CreateSamplingRuleResponse)
createSamplingRuleResponse_httpStatus :: Lens.Lens' CreateSamplingRuleResponse Prelude.Int
createSamplingRuleResponse_httpStatus :: (Int -> f Int)
-> CreateSamplingRuleResponse -> f CreateSamplingRuleResponse
createSamplingRuleResponse_httpStatus = (CreateSamplingRuleResponse -> Int)
-> (CreateSamplingRuleResponse
-> Int -> CreateSamplingRuleResponse)
-> Lens
CreateSamplingRuleResponse CreateSamplingRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSamplingRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSamplingRuleResponse' :: CreateSamplingRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSamplingRuleResponse
s@CreateSamplingRuleResponse' {} Int
a -> CreateSamplingRuleResponse
s {$sel:httpStatus:CreateSamplingRuleResponse' :: Int
httpStatus = Int
a} :: CreateSamplingRuleResponse)
instance Prelude.NFData CreateSamplingRuleResponse