{-# 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.Route53RecoveryControlConfig.CreateSafetyRule
(
CreateSafetyRule (..),
newCreateSafetyRule,
createSafetyRule_assertionRule,
createSafetyRule_clientToken,
createSafetyRule_gatingRule,
CreateSafetyRuleResponse (..),
newCreateSafetyRuleResponse,
createSafetyRuleResponse_assertionRule,
createSafetyRuleResponse_gatingRule,
createSafetyRuleResponse_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.Route53RecoveryControlConfig.Types
data CreateSafetyRule = CreateSafetyRule'
{ CreateSafetyRule -> Maybe NewAssertionRule
assertionRule :: Prelude.Maybe NewAssertionRule,
CreateSafetyRule -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
CreateSafetyRule -> Maybe NewGatingRule
gatingRule :: Prelude.Maybe NewGatingRule
}
deriving (CreateSafetyRule -> CreateSafetyRule -> Bool
(CreateSafetyRule -> CreateSafetyRule -> Bool)
-> (CreateSafetyRule -> CreateSafetyRule -> Bool)
-> Eq CreateSafetyRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSafetyRule -> CreateSafetyRule -> Bool
$c/= :: CreateSafetyRule -> CreateSafetyRule -> Bool
== :: CreateSafetyRule -> CreateSafetyRule -> Bool
$c== :: CreateSafetyRule -> CreateSafetyRule -> Bool
Prelude.Eq, ReadPrec [CreateSafetyRule]
ReadPrec CreateSafetyRule
Int -> ReadS CreateSafetyRule
ReadS [CreateSafetyRule]
(Int -> ReadS CreateSafetyRule)
-> ReadS [CreateSafetyRule]
-> ReadPrec CreateSafetyRule
-> ReadPrec [CreateSafetyRule]
-> Read CreateSafetyRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSafetyRule]
$creadListPrec :: ReadPrec [CreateSafetyRule]
readPrec :: ReadPrec CreateSafetyRule
$creadPrec :: ReadPrec CreateSafetyRule
readList :: ReadS [CreateSafetyRule]
$creadList :: ReadS [CreateSafetyRule]
readsPrec :: Int -> ReadS CreateSafetyRule
$creadsPrec :: Int -> ReadS CreateSafetyRule
Prelude.Read, Int -> CreateSafetyRule -> ShowS
[CreateSafetyRule] -> ShowS
CreateSafetyRule -> String
(Int -> CreateSafetyRule -> ShowS)
-> (CreateSafetyRule -> String)
-> ([CreateSafetyRule] -> ShowS)
-> Show CreateSafetyRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSafetyRule] -> ShowS
$cshowList :: [CreateSafetyRule] -> ShowS
show :: CreateSafetyRule -> String
$cshow :: CreateSafetyRule -> String
showsPrec :: Int -> CreateSafetyRule -> ShowS
$cshowsPrec :: Int -> CreateSafetyRule -> ShowS
Prelude.Show, (forall x. CreateSafetyRule -> Rep CreateSafetyRule x)
-> (forall x. Rep CreateSafetyRule x -> CreateSafetyRule)
-> Generic CreateSafetyRule
forall x. Rep CreateSafetyRule x -> CreateSafetyRule
forall x. CreateSafetyRule -> Rep CreateSafetyRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSafetyRule x -> CreateSafetyRule
$cfrom :: forall x. CreateSafetyRule -> Rep CreateSafetyRule x
Prelude.Generic)
newCreateSafetyRule ::
CreateSafetyRule
newCreateSafetyRule :: CreateSafetyRule
newCreateSafetyRule =
CreateSafetyRule' :: Maybe NewAssertionRule
-> Maybe Text -> Maybe NewGatingRule -> CreateSafetyRule
CreateSafetyRule'
{ $sel:assertionRule:CreateSafetyRule' :: Maybe NewAssertionRule
assertionRule = Maybe NewAssertionRule
forall a. Maybe a
Prelude.Nothing,
$sel:clientToken:CreateSafetyRule' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:gatingRule:CreateSafetyRule' :: Maybe NewGatingRule
gatingRule = Maybe NewGatingRule
forall a. Maybe a
Prelude.Nothing
}
createSafetyRule_assertionRule :: Lens.Lens' CreateSafetyRule (Prelude.Maybe NewAssertionRule)
createSafetyRule_assertionRule :: (Maybe NewAssertionRule -> f (Maybe NewAssertionRule))
-> CreateSafetyRule -> f CreateSafetyRule
createSafetyRule_assertionRule = (CreateSafetyRule -> Maybe NewAssertionRule)
-> (CreateSafetyRule -> Maybe NewAssertionRule -> CreateSafetyRule)
-> Lens
CreateSafetyRule
CreateSafetyRule
(Maybe NewAssertionRule)
(Maybe NewAssertionRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRule' {Maybe NewAssertionRule
assertionRule :: Maybe NewAssertionRule
$sel:assertionRule:CreateSafetyRule' :: CreateSafetyRule -> Maybe NewAssertionRule
assertionRule} -> Maybe NewAssertionRule
assertionRule) (\s :: CreateSafetyRule
s@CreateSafetyRule' {} Maybe NewAssertionRule
a -> CreateSafetyRule
s {$sel:assertionRule:CreateSafetyRule' :: Maybe NewAssertionRule
assertionRule = Maybe NewAssertionRule
a} :: CreateSafetyRule)
createSafetyRule_clientToken :: Lens.Lens' CreateSafetyRule (Prelude.Maybe Prelude.Text)
createSafetyRule_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateSafetyRule -> f CreateSafetyRule
createSafetyRule_clientToken = (CreateSafetyRule -> Maybe Text)
-> (CreateSafetyRule -> Maybe Text -> CreateSafetyRule)
-> Lens CreateSafetyRule CreateSafetyRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRule' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateSafetyRule' :: CreateSafetyRule -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateSafetyRule
s@CreateSafetyRule' {} Maybe Text
a -> CreateSafetyRule
s {$sel:clientToken:CreateSafetyRule' :: Maybe Text
clientToken = Maybe Text
a} :: CreateSafetyRule)
createSafetyRule_gatingRule :: Lens.Lens' CreateSafetyRule (Prelude.Maybe NewGatingRule)
createSafetyRule_gatingRule :: (Maybe NewGatingRule -> f (Maybe NewGatingRule))
-> CreateSafetyRule -> f CreateSafetyRule
createSafetyRule_gatingRule = (CreateSafetyRule -> Maybe NewGatingRule)
-> (CreateSafetyRule -> Maybe NewGatingRule -> CreateSafetyRule)
-> Lens
CreateSafetyRule
CreateSafetyRule
(Maybe NewGatingRule)
(Maybe NewGatingRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRule' {Maybe NewGatingRule
gatingRule :: Maybe NewGatingRule
$sel:gatingRule:CreateSafetyRule' :: CreateSafetyRule -> Maybe NewGatingRule
gatingRule} -> Maybe NewGatingRule
gatingRule) (\s :: CreateSafetyRule
s@CreateSafetyRule' {} Maybe NewGatingRule
a -> CreateSafetyRule
s {$sel:gatingRule:CreateSafetyRule' :: Maybe NewGatingRule
gatingRule = Maybe NewGatingRule
a} :: CreateSafetyRule)
instance Core.AWSRequest CreateSafetyRule where
type
AWSResponse CreateSafetyRule =
CreateSafetyRuleResponse
request :: CreateSafetyRule -> Request CreateSafetyRule
request = Service -> CreateSafetyRule -> Request CreateSafetyRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSafetyRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSafetyRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSafetyRule))
-> Logger
-> Service
-> Proxy CreateSafetyRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSafetyRule)))
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 AssertionRule
-> Maybe GatingRule -> Int -> CreateSafetyRuleResponse
CreateSafetyRuleResponse'
(Maybe AssertionRule
-> Maybe GatingRule -> Int -> CreateSafetyRuleResponse)
-> Either String (Maybe AssertionRule)
-> Either
String (Maybe GatingRule -> Int -> CreateSafetyRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AssertionRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AssertionRule")
Either String (Maybe GatingRule -> Int -> CreateSafetyRuleResponse)
-> Either String (Maybe GatingRule)
-> Either String (Int -> CreateSafetyRuleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe GatingRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GatingRule")
Either String (Int -> CreateSafetyRuleResponse)
-> Either String Int -> Either String CreateSafetyRuleResponse
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 CreateSafetyRule
instance Prelude.NFData CreateSafetyRule
instance Core.ToHeaders CreateSafetyRule where
toHeaders :: CreateSafetyRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateSafetyRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 CreateSafetyRule where
toJSON :: CreateSafetyRule -> Value
toJSON CreateSafetyRule' {Maybe Text
Maybe NewGatingRule
Maybe NewAssertionRule
gatingRule :: Maybe NewGatingRule
clientToken :: Maybe Text
assertionRule :: Maybe NewAssertionRule
$sel:gatingRule:CreateSafetyRule' :: CreateSafetyRule -> Maybe NewGatingRule
$sel:clientToken:CreateSafetyRule' :: CreateSafetyRule -> Maybe Text
$sel:assertionRule:CreateSafetyRule' :: CreateSafetyRule -> Maybe NewAssertionRule
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AssertionRule" Text -> NewAssertionRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NewAssertionRule -> Pair) -> Maybe NewAssertionRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NewAssertionRule
assertionRule,
(Text
"ClientToken" 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
clientToken,
(Text
"GatingRule" Text -> NewGatingRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NewGatingRule -> Pair) -> Maybe NewGatingRule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NewGatingRule
gatingRule
]
)
instance Core.ToPath CreateSafetyRule where
toPath :: CreateSafetyRule -> ByteString
toPath = ByteString -> CreateSafetyRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/safetyrule"
instance Core.ToQuery CreateSafetyRule where
toQuery :: CreateSafetyRule -> QueryString
toQuery = QueryString -> CreateSafetyRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSafetyRuleResponse = CreateSafetyRuleResponse'
{ CreateSafetyRuleResponse -> Maybe AssertionRule
assertionRule :: Prelude.Maybe AssertionRule,
CreateSafetyRuleResponse -> Maybe GatingRule
gatingRule :: Prelude.Maybe GatingRule,
CreateSafetyRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool
(CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool)
-> (CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool)
-> Eq CreateSafetyRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool
$c/= :: CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool
== :: CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool
$c== :: CreateSafetyRuleResponse -> CreateSafetyRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateSafetyRuleResponse]
ReadPrec CreateSafetyRuleResponse
Int -> ReadS CreateSafetyRuleResponse
ReadS [CreateSafetyRuleResponse]
(Int -> ReadS CreateSafetyRuleResponse)
-> ReadS [CreateSafetyRuleResponse]
-> ReadPrec CreateSafetyRuleResponse
-> ReadPrec [CreateSafetyRuleResponse]
-> Read CreateSafetyRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSafetyRuleResponse]
$creadListPrec :: ReadPrec [CreateSafetyRuleResponse]
readPrec :: ReadPrec CreateSafetyRuleResponse
$creadPrec :: ReadPrec CreateSafetyRuleResponse
readList :: ReadS [CreateSafetyRuleResponse]
$creadList :: ReadS [CreateSafetyRuleResponse]
readsPrec :: Int -> ReadS CreateSafetyRuleResponse
$creadsPrec :: Int -> ReadS CreateSafetyRuleResponse
Prelude.Read, Int -> CreateSafetyRuleResponse -> ShowS
[CreateSafetyRuleResponse] -> ShowS
CreateSafetyRuleResponse -> String
(Int -> CreateSafetyRuleResponse -> ShowS)
-> (CreateSafetyRuleResponse -> String)
-> ([CreateSafetyRuleResponse] -> ShowS)
-> Show CreateSafetyRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSafetyRuleResponse] -> ShowS
$cshowList :: [CreateSafetyRuleResponse] -> ShowS
show :: CreateSafetyRuleResponse -> String
$cshow :: CreateSafetyRuleResponse -> String
showsPrec :: Int -> CreateSafetyRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateSafetyRuleResponse -> ShowS
Prelude.Show, (forall x.
CreateSafetyRuleResponse -> Rep CreateSafetyRuleResponse x)
-> (forall x.
Rep CreateSafetyRuleResponse x -> CreateSafetyRuleResponse)
-> Generic CreateSafetyRuleResponse
forall x.
Rep CreateSafetyRuleResponse x -> CreateSafetyRuleResponse
forall x.
CreateSafetyRuleResponse -> Rep CreateSafetyRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateSafetyRuleResponse x -> CreateSafetyRuleResponse
$cfrom :: forall x.
CreateSafetyRuleResponse -> Rep CreateSafetyRuleResponse x
Prelude.Generic)
newCreateSafetyRuleResponse ::
Prelude.Int ->
CreateSafetyRuleResponse
newCreateSafetyRuleResponse :: Int -> CreateSafetyRuleResponse
newCreateSafetyRuleResponse Int
pHttpStatus_ =
CreateSafetyRuleResponse' :: Maybe AssertionRule
-> Maybe GatingRule -> Int -> CreateSafetyRuleResponse
CreateSafetyRuleResponse'
{ $sel:assertionRule:CreateSafetyRuleResponse' :: Maybe AssertionRule
assertionRule =
Maybe AssertionRule
forall a. Maybe a
Prelude.Nothing,
$sel:gatingRule:CreateSafetyRuleResponse' :: Maybe GatingRule
gatingRule = Maybe GatingRule
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateSafetyRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createSafetyRuleResponse_assertionRule :: Lens.Lens' CreateSafetyRuleResponse (Prelude.Maybe AssertionRule)
createSafetyRuleResponse_assertionRule :: (Maybe AssertionRule -> f (Maybe AssertionRule))
-> CreateSafetyRuleResponse -> f CreateSafetyRuleResponse
createSafetyRuleResponse_assertionRule = (CreateSafetyRuleResponse -> Maybe AssertionRule)
-> (CreateSafetyRuleResponse
-> Maybe AssertionRule -> CreateSafetyRuleResponse)
-> Lens
CreateSafetyRuleResponse
CreateSafetyRuleResponse
(Maybe AssertionRule)
(Maybe AssertionRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRuleResponse' {Maybe AssertionRule
assertionRule :: Maybe AssertionRule
$sel:assertionRule:CreateSafetyRuleResponse' :: CreateSafetyRuleResponse -> Maybe AssertionRule
assertionRule} -> Maybe AssertionRule
assertionRule) (\s :: CreateSafetyRuleResponse
s@CreateSafetyRuleResponse' {} Maybe AssertionRule
a -> CreateSafetyRuleResponse
s {$sel:assertionRule:CreateSafetyRuleResponse' :: Maybe AssertionRule
assertionRule = Maybe AssertionRule
a} :: CreateSafetyRuleResponse)
createSafetyRuleResponse_gatingRule :: Lens.Lens' CreateSafetyRuleResponse (Prelude.Maybe GatingRule)
createSafetyRuleResponse_gatingRule :: (Maybe GatingRule -> f (Maybe GatingRule))
-> CreateSafetyRuleResponse -> f CreateSafetyRuleResponse
createSafetyRuleResponse_gatingRule = (CreateSafetyRuleResponse -> Maybe GatingRule)
-> (CreateSafetyRuleResponse
-> Maybe GatingRule -> CreateSafetyRuleResponse)
-> Lens
CreateSafetyRuleResponse
CreateSafetyRuleResponse
(Maybe GatingRule)
(Maybe GatingRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRuleResponse' {Maybe GatingRule
gatingRule :: Maybe GatingRule
$sel:gatingRule:CreateSafetyRuleResponse' :: CreateSafetyRuleResponse -> Maybe GatingRule
gatingRule} -> Maybe GatingRule
gatingRule) (\s :: CreateSafetyRuleResponse
s@CreateSafetyRuleResponse' {} Maybe GatingRule
a -> CreateSafetyRuleResponse
s {$sel:gatingRule:CreateSafetyRuleResponse' :: Maybe GatingRule
gatingRule = Maybe GatingRule
a} :: CreateSafetyRuleResponse)
createSafetyRuleResponse_httpStatus :: Lens.Lens' CreateSafetyRuleResponse Prelude.Int
createSafetyRuleResponse_httpStatus :: (Int -> f Int)
-> CreateSafetyRuleResponse -> f CreateSafetyRuleResponse
createSafetyRuleResponse_httpStatus = (CreateSafetyRuleResponse -> Int)
-> (CreateSafetyRuleResponse -> Int -> CreateSafetyRuleResponse)
-> Lens CreateSafetyRuleResponse CreateSafetyRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSafetyRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSafetyRuleResponse' :: CreateSafetyRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSafetyRuleResponse
s@CreateSafetyRuleResponse' {} Int
a -> CreateSafetyRuleResponse
s {$sel:httpStatus:CreateSafetyRuleResponse' :: Int
httpStatus = Int
a} :: CreateSafetyRuleResponse)
instance Prelude.NFData CreateSafetyRuleResponse