{-# 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.Shield.CreateProtection
(
CreateProtection (..),
newCreateProtection,
createProtection_tags,
createProtection_name,
createProtection_resourceArn,
CreateProtectionResponse (..),
newCreateProtectionResponse,
createProtectionResponse_protectionId,
createProtectionResponse_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.Shield.Types
data CreateProtection = CreateProtection'
{
CreateProtection -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateProtection -> Text
name :: Prelude.Text,
CreateProtection -> Text
resourceArn :: Prelude.Text
}
deriving (CreateProtection -> CreateProtection -> Bool
(CreateProtection -> CreateProtection -> Bool)
-> (CreateProtection -> CreateProtection -> Bool)
-> Eq CreateProtection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProtection -> CreateProtection -> Bool
$c/= :: CreateProtection -> CreateProtection -> Bool
== :: CreateProtection -> CreateProtection -> Bool
$c== :: CreateProtection -> CreateProtection -> Bool
Prelude.Eq, ReadPrec [CreateProtection]
ReadPrec CreateProtection
Int -> ReadS CreateProtection
ReadS [CreateProtection]
(Int -> ReadS CreateProtection)
-> ReadS [CreateProtection]
-> ReadPrec CreateProtection
-> ReadPrec [CreateProtection]
-> Read CreateProtection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProtection]
$creadListPrec :: ReadPrec [CreateProtection]
readPrec :: ReadPrec CreateProtection
$creadPrec :: ReadPrec CreateProtection
readList :: ReadS [CreateProtection]
$creadList :: ReadS [CreateProtection]
readsPrec :: Int -> ReadS CreateProtection
$creadsPrec :: Int -> ReadS CreateProtection
Prelude.Read, Int -> CreateProtection -> ShowS
[CreateProtection] -> ShowS
CreateProtection -> String
(Int -> CreateProtection -> ShowS)
-> (CreateProtection -> String)
-> ([CreateProtection] -> ShowS)
-> Show CreateProtection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProtection] -> ShowS
$cshowList :: [CreateProtection] -> ShowS
show :: CreateProtection -> String
$cshow :: CreateProtection -> String
showsPrec :: Int -> CreateProtection -> ShowS
$cshowsPrec :: Int -> CreateProtection -> ShowS
Prelude.Show, (forall x. CreateProtection -> Rep CreateProtection x)
-> (forall x. Rep CreateProtection x -> CreateProtection)
-> Generic CreateProtection
forall x. Rep CreateProtection x -> CreateProtection
forall x. CreateProtection -> Rep CreateProtection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateProtection x -> CreateProtection
$cfrom :: forall x. CreateProtection -> Rep CreateProtection x
Prelude.Generic)
newCreateProtection ::
Prelude.Text ->
Prelude.Text ->
CreateProtection
newCreateProtection :: Text -> Text -> CreateProtection
newCreateProtection Text
pName_ Text
pResourceArn_ =
CreateProtection' :: Maybe [Tag] -> Text -> Text -> CreateProtection
CreateProtection'
{ $sel:tags:CreateProtection' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateProtection' :: Text
name = Text
pName_,
$sel:resourceArn:CreateProtection' :: Text
resourceArn = Text
pResourceArn_
}
createProtection_tags :: Lens.Lens' CreateProtection (Prelude.Maybe [Tag])
createProtection_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateProtection -> f CreateProtection
createProtection_tags = (CreateProtection -> Maybe [Tag])
-> (CreateProtection -> Maybe [Tag] -> CreateProtection)
-> Lens
CreateProtection CreateProtection (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProtection' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateProtection' :: CreateProtection -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateProtection
s@CreateProtection' {} Maybe [Tag]
a -> CreateProtection
s {$sel:tags:CreateProtection' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateProtection) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateProtection -> f CreateProtection)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateProtection
-> f CreateProtection
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
createProtection_name :: Lens.Lens' CreateProtection Prelude.Text
createProtection_name :: (Text -> f Text) -> CreateProtection -> f CreateProtection
createProtection_name = (CreateProtection -> Text)
-> (CreateProtection -> Text -> CreateProtection)
-> Lens CreateProtection CreateProtection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProtection' {Text
name :: Text
$sel:name:CreateProtection' :: CreateProtection -> Text
name} -> Text
name) (\s :: CreateProtection
s@CreateProtection' {} Text
a -> CreateProtection
s {$sel:name:CreateProtection' :: Text
name = Text
a} :: CreateProtection)
createProtection_resourceArn :: Lens.Lens' CreateProtection Prelude.Text
createProtection_resourceArn :: (Text -> f Text) -> CreateProtection -> f CreateProtection
createProtection_resourceArn = (CreateProtection -> Text)
-> (CreateProtection -> Text -> CreateProtection)
-> Lens CreateProtection CreateProtection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProtection' {Text
resourceArn :: Text
$sel:resourceArn:CreateProtection' :: CreateProtection -> Text
resourceArn} -> Text
resourceArn) (\s :: CreateProtection
s@CreateProtection' {} Text
a -> CreateProtection
s {$sel:resourceArn:CreateProtection' :: Text
resourceArn = Text
a} :: CreateProtection)
instance Core.AWSRequest CreateProtection where
type
AWSResponse CreateProtection =
CreateProtectionResponse
request :: CreateProtection -> Request CreateProtection
request = Service -> CreateProtection -> Request CreateProtection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateProtection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProtection)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateProtection))
-> Logger
-> Service
-> Proxy CreateProtection
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProtection)))
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 -> CreateProtectionResponse
CreateProtectionResponse'
(Maybe Text -> Int -> CreateProtectionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateProtectionResponse)
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
"ProtectionId")
Either String (Int -> CreateProtectionResponse)
-> Either String Int -> Either String CreateProtectionResponse
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 CreateProtection
instance Prelude.NFData CreateProtection
instance Core.ToHeaders CreateProtection where
toHeaders :: CreateProtection -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateProtection -> 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
"AWSShield_20160616.CreateProtection" ::
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 CreateProtection where
toJSON :: CreateProtection -> Value
toJSON CreateProtection' {Maybe [Tag]
Text
resourceArn :: Text
name :: Text
tags :: Maybe [Tag]
$sel:resourceArn:CreateProtection' :: CreateProtection -> Text
$sel:name:CreateProtection' :: CreateProtection -> Text
$sel:tags:CreateProtection' :: CreateProtection -> Maybe [Tag]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> 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 (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
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn)
]
)
instance Core.ToPath CreateProtection where
toPath :: CreateProtection -> ByteString
toPath = ByteString -> CreateProtection -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateProtection where
toQuery :: CreateProtection -> QueryString
toQuery = QueryString -> CreateProtection -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateProtectionResponse = CreateProtectionResponse'
{
CreateProtectionResponse -> Maybe Text
protectionId :: Prelude.Maybe Prelude.Text,
CreateProtectionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateProtectionResponse -> CreateProtectionResponse -> Bool
(CreateProtectionResponse -> CreateProtectionResponse -> Bool)
-> (CreateProtectionResponse -> CreateProtectionResponse -> Bool)
-> Eq CreateProtectionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProtectionResponse -> CreateProtectionResponse -> Bool
$c/= :: CreateProtectionResponse -> CreateProtectionResponse -> Bool
== :: CreateProtectionResponse -> CreateProtectionResponse -> Bool
$c== :: CreateProtectionResponse -> CreateProtectionResponse -> Bool
Prelude.Eq, ReadPrec [CreateProtectionResponse]
ReadPrec CreateProtectionResponse
Int -> ReadS CreateProtectionResponse
ReadS [CreateProtectionResponse]
(Int -> ReadS CreateProtectionResponse)
-> ReadS [CreateProtectionResponse]
-> ReadPrec CreateProtectionResponse
-> ReadPrec [CreateProtectionResponse]
-> Read CreateProtectionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProtectionResponse]
$creadListPrec :: ReadPrec [CreateProtectionResponse]
readPrec :: ReadPrec CreateProtectionResponse
$creadPrec :: ReadPrec CreateProtectionResponse
readList :: ReadS [CreateProtectionResponse]
$creadList :: ReadS [CreateProtectionResponse]
readsPrec :: Int -> ReadS CreateProtectionResponse
$creadsPrec :: Int -> ReadS CreateProtectionResponse
Prelude.Read, Int -> CreateProtectionResponse -> ShowS
[CreateProtectionResponse] -> ShowS
CreateProtectionResponse -> String
(Int -> CreateProtectionResponse -> ShowS)
-> (CreateProtectionResponse -> String)
-> ([CreateProtectionResponse] -> ShowS)
-> Show CreateProtectionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProtectionResponse] -> ShowS
$cshowList :: [CreateProtectionResponse] -> ShowS
show :: CreateProtectionResponse -> String
$cshow :: CreateProtectionResponse -> String
showsPrec :: Int -> CreateProtectionResponse -> ShowS
$cshowsPrec :: Int -> CreateProtectionResponse -> ShowS
Prelude.Show, (forall x.
CreateProtectionResponse -> Rep CreateProtectionResponse x)
-> (forall x.
Rep CreateProtectionResponse x -> CreateProtectionResponse)
-> Generic CreateProtectionResponse
forall x.
Rep CreateProtectionResponse x -> CreateProtectionResponse
forall x.
CreateProtectionResponse -> Rep CreateProtectionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateProtectionResponse x -> CreateProtectionResponse
$cfrom :: forall x.
CreateProtectionResponse -> Rep CreateProtectionResponse x
Prelude.Generic)
newCreateProtectionResponse ::
Prelude.Int ->
CreateProtectionResponse
newCreateProtectionResponse :: Int -> CreateProtectionResponse
newCreateProtectionResponse Int
pHttpStatus_ =
CreateProtectionResponse' :: Maybe Text -> Int -> CreateProtectionResponse
CreateProtectionResponse'
{ $sel:protectionId:CreateProtectionResponse' :: Maybe Text
protectionId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateProtectionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createProtectionResponse_protectionId :: Lens.Lens' CreateProtectionResponse (Prelude.Maybe Prelude.Text)
createProtectionResponse_protectionId :: (Maybe Text -> f (Maybe Text))
-> CreateProtectionResponse -> f CreateProtectionResponse
createProtectionResponse_protectionId = (CreateProtectionResponse -> Maybe Text)
-> (CreateProtectionResponse
-> Maybe Text -> CreateProtectionResponse)
-> Lens
CreateProtectionResponse
CreateProtectionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProtectionResponse' {Maybe Text
protectionId :: Maybe Text
$sel:protectionId:CreateProtectionResponse' :: CreateProtectionResponse -> Maybe Text
protectionId} -> Maybe Text
protectionId) (\s :: CreateProtectionResponse
s@CreateProtectionResponse' {} Maybe Text
a -> CreateProtectionResponse
s {$sel:protectionId:CreateProtectionResponse' :: Maybe Text
protectionId = Maybe Text
a} :: CreateProtectionResponse)
createProtectionResponse_httpStatus :: Lens.Lens' CreateProtectionResponse Prelude.Int
createProtectionResponse_httpStatus :: (Int -> f Int)
-> CreateProtectionResponse -> f CreateProtectionResponse
createProtectionResponse_httpStatus = (CreateProtectionResponse -> Int)
-> (CreateProtectionResponse -> Int -> CreateProtectionResponse)
-> Lens CreateProtectionResponse CreateProtectionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProtectionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateProtectionResponse' :: CreateProtectionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateProtectionResponse
s@CreateProtectionResponse' {} Int
a -> CreateProtectionResponse
s {$sel:httpStatus:CreateProtectionResponse' :: Int
httpStatus = Int
a} :: CreateProtectionResponse)
instance Prelude.NFData CreateProtectionResponse