{-# 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.CloudControl.CreateResource
(
CreateResource (..),
newCreateResource,
createResource_clientToken,
createResource_typeVersionId,
createResource_roleArn,
createResource_typeName,
createResource_desiredState,
CreateResourceResponse (..),
newCreateResourceResponse,
createResourceResponse_progressEvent,
createResourceResponse_httpStatus,
)
where
import Amazonka.CloudControl.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 CreateResource = CreateResource'
{
CreateResource -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
CreateResource -> Maybe Text
typeVersionId :: Prelude.Maybe Prelude.Text,
CreateResource -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
CreateResource -> Text
typeName :: Prelude.Text,
CreateResource -> Sensitive Text
desiredState :: Core.Sensitive Prelude.Text
}
deriving (CreateResource -> CreateResource -> Bool
(CreateResource -> CreateResource -> Bool)
-> (CreateResource -> CreateResource -> Bool) -> Eq CreateResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResource -> CreateResource -> Bool
$c/= :: CreateResource -> CreateResource -> Bool
== :: CreateResource -> CreateResource -> Bool
$c== :: CreateResource -> CreateResource -> Bool
Prelude.Eq, Int -> CreateResource -> ShowS
[CreateResource] -> ShowS
CreateResource -> String
(Int -> CreateResource -> ShowS)
-> (CreateResource -> String)
-> ([CreateResource] -> ShowS)
-> Show CreateResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResource] -> ShowS
$cshowList :: [CreateResource] -> ShowS
show :: CreateResource -> String
$cshow :: CreateResource -> String
showsPrec :: Int -> CreateResource -> ShowS
$cshowsPrec :: Int -> CreateResource -> ShowS
Prelude.Show, (forall x. CreateResource -> Rep CreateResource x)
-> (forall x. Rep CreateResource x -> CreateResource)
-> Generic CreateResource
forall x. Rep CreateResource x -> CreateResource
forall x. CreateResource -> Rep CreateResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResource x -> CreateResource
$cfrom :: forall x. CreateResource -> Rep CreateResource x
Prelude.Generic)
newCreateResource ::
Prelude.Text ->
Prelude.Text ->
CreateResource
newCreateResource :: Text -> Text -> CreateResource
newCreateResource Text
pTypeName_ Text
pDesiredState_ =
CreateResource' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Sensitive Text
-> CreateResource
CreateResource'
{ $sel:clientToken:CreateResource' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:typeVersionId:CreateResource' :: Maybe Text
typeVersionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:roleArn:CreateResource' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:typeName:CreateResource' :: Text
typeName = Text
pTypeName_,
$sel:desiredState:CreateResource' :: Sensitive Text
desiredState = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pDesiredState_
}
createResource_clientToken :: Lens.Lens' CreateResource (Prelude.Maybe Prelude.Text)
createResource_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateResource -> f CreateResource
createResource_clientToken = (CreateResource -> Maybe Text)
-> (CreateResource -> Maybe Text -> CreateResource)
-> Lens CreateResource CreateResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateResource' :: CreateResource -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateResource
s@CreateResource' {} Maybe Text
a -> CreateResource
s {$sel:clientToken:CreateResource' :: Maybe Text
clientToken = Maybe Text
a} :: CreateResource)
createResource_typeVersionId :: Lens.Lens' CreateResource (Prelude.Maybe Prelude.Text)
createResource_typeVersionId :: (Maybe Text -> f (Maybe Text))
-> CreateResource -> f CreateResource
createResource_typeVersionId = (CreateResource -> Maybe Text)
-> (CreateResource -> Maybe Text -> CreateResource)
-> Lens CreateResource CreateResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Maybe Text
typeVersionId :: Maybe Text
$sel:typeVersionId:CreateResource' :: CreateResource -> Maybe Text
typeVersionId} -> Maybe Text
typeVersionId) (\s :: CreateResource
s@CreateResource' {} Maybe Text
a -> CreateResource
s {$sel:typeVersionId:CreateResource' :: Maybe Text
typeVersionId = Maybe Text
a} :: CreateResource)
createResource_roleArn :: Lens.Lens' CreateResource (Prelude.Maybe Prelude.Text)
createResource_roleArn :: (Maybe Text -> f (Maybe Text))
-> CreateResource -> f CreateResource
createResource_roleArn = (CreateResource -> Maybe Text)
-> (CreateResource -> Maybe Text -> CreateResource)
-> Lens CreateResource CreateResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:CreateResource' :: CreateResource -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: CreateResource
s@CreateResource' {} Maybe Text
a -> CreateResource
s {$sel:roleArn:CreateResource' :: Maybe Text
roleArn = Maybe Text
a} :: CreateResource)
createResource_typeName :: Lens.Lens' CreateResource Prelude.Text
createResource_typeName :: (Text -> f Text) -> CreateResource -> f CreateResource
createResource_typeName = (CreateResource -> Text)
-> (CreateResource -> Text -> CreateResource)
-> Lens CreateResource CreateResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Text
typeName :: Text
$sel:typeName:CreateResource' :: CreateResource -> Text
typeName} -> Text
typeName) (\s :: CreateResource
s@CreateResource' {} Text
a -> CreateResource
s {$sel:typeName:CreateResource' :: Text
typeName = Text
a} :: CreateResource)
createResource_desiredState :: Lens.Lens' CreateResource Prelude.Text
createResource_desiredState :: (Text -> f Text) -> CreateResource -> f CreateResource
createResource_desiredState = (CreateResource -> Sensitive Text)
-> (CreateResource -> Sensitive Text -> CreateResource)
-> Lens
CreateResource CreateResource (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResource' {Sensitive Text
desiredState :: Sensitive Text
$sel:desiredState:CreateResource' :: CreateResource -> Sensitive Text
desiredState} -> Sensitive Text
desiredState) (\s :: CreateResource
s@CreateResource' {} Sensitive Text
a -> CreateResource
s {$sel:desiredState:CreateResource' :: Sensitive Text
desiredState = Sensitive Text
a} :: CreateResource) ((Sensitive Text -> f (Sensitive Text))
-> CreateResource -> f CreateResource)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateResource
-> f CreateResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest CreateResource where
type
AWSResponse CreateResource =
CreateResourceResponse
request :: CreateResource -> Request CreateResource
request = Service -> CreateResource -> Request CreateResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateResource)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateResource))
-> Logger
-> Service
-> Proxy CreateResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateResource)))
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 ProgressEvent -> Int -> CreateResourceResponse
CreateResourceResponse'
(Maybe ProgressEvent -> Int -> CreateResourceResponse)
-> Either String (Maybe ProgressEvent)
-> Either String (Int -> CreateResourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ProgressEvent)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProgressEvent")
Either String (Int -> CreateResourceResponse)
-> Either String Int -> Either String CreateResourceResponse
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 CreateResource
instance Prelude.NFData CreateResource
instance Core.ToHeaders CreateResource where
toHeaders :: CreateResource -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateResource -> 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
"CloudApiService.CreateResource" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateResource where
toJSON :: CreateResource -> Value
toJSON CreateResource' {Maybe Text
Text
Sensitive Text
desiredState :: Sensitive Text
typeName :: Text
roleArn :: Maybe Text
typeVersionId :: Maybe Text
clientToken :: Maybe Text
$sel:desiredState:CreateResource' :: CreateResource -> Sensitive Text
$sel:typeName:CreateResource' :: CreateResource -> Text
$sel:roleArn:CreateResource' :: CreateResource -> Maybe Text
$sel:typeVersionId:CreateResource' :: CreateResource -> Maybe Text
$sel:clientToken:CreateResource' :: CreateResource -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"TypeVersionId" 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
typeVersionId,
(Text
"RoleArn" 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
roleArn,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TypeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
typeName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DesiredState" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
desiredState)
]
)
instance Core.ToPath CreateResource where
toPath :: CreateResource -> ByteString
toPath = ByteString -> CreateResource -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateResource where
toQuery :: CreateResource -> QueryString
toQuery = QueryString -> CreateResource -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateResourceResponse = CreateResourceResponse'
{
CreateResourceResponse -> Maybe ProgressEvent
progressEvent :: Prelude.Maybe ProgressEvent,
CreateResourceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateResourceResponse -> CreateResourceResponse -> Bool
(CreateResourceResponse -> CreateResourceResponse -> Bool)
-> (CreateResourceResponse -> CreateResourceResponse -> Bool)
-> Eq CreateResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateResourceResponse -> CreateResourceResponse -> Bool
$c/= :: CreateResourceResponse -> CreateResourceResponse -> Bool
== :: CreateResourceResponse -> CreateResourceResponse -> Bool
$c== :: CreateResourceResponse -> CreateResourceResponse -> Bool
Prelude.Eq, Int -> CreateResourceResponse -> ShowS
[CreateResourceResponse] -> ShowS
CreateResourceResponse -> String
(Int -> CreateResourceResponse -> ShowS)
-> (CreateResourceResponse -> String)
-> ([CreateResourceResponse] -> ShowS)
-> Show CreateResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateResourceResponse] -> ShowS
$cshowList :: [CreateResourceResponse] -> ShowS
show :: CreateResourceResponse -> String
$cshow :: CreateResourceResponse -> String
showsPrec :: Int -> CreateResourceResponse -> ShowS
$cshowsPrec :: Int -> CreateResourceResponse -> ShowS
Prelude.Show, (forall x. CreateResourceResponse -> Rep CreateResourceResponse x)
-> (forall x.
Rep CreateResourceResponse x -> CreateResourceResponse)
-> Generic CreateResourceResponse
forall x. Rep CreateResourceResponse x -> CreateResourceResponse
forall x. CreateResourceResponse -> Rep CreateResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateResourceResponse x -> CreateResourceResponse
$cfrom :: forall x. CreateResourceResponse -> Rep CreateResourceResponse x
Prelude.Generic)
newCreateResourceResponse ::
Prelude.Int ->
CreateResourceResponse
newCreateResourceResponse :: Int -> CreateResourceResponse
newCreateResourceResponse Int
pHttpStatus_ =
CreateResourceResponse' :: Maybe ProgressEvent -> Int -> CreateResourceResponse
CreateResourceResponse'
{ $sel:progressEvent:CreateResourceResponse' :: Maybe ProgressEvent
progressEvent =
Maybe ProgressEvent
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createResourceResponse_progressEvent :: Lens.Lens' CreateResourceResponse (Prelude.Maybe ProgressEvent)
createResourceResponse_progressEvent :: (Maybe ProgressEvent -> f (Maybe ProgressEvent))
-> CreateResourceResponse -> f CreateResourceResponse
createResourceResponse_progressEvent = (CreateResourceResponse -> Maybe ProgressEvent)
-> (CreateResourceResponse
-> Maybe ProgressEvent -> CreateResourceResponse)
-> Lens
CreateResourceResponse
CreateResourceResponse
(Maybe ProgressEvent)
(Maybe ProgressEvent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceResponse' {Maybe ProgressEvent
progressEvent :: Maybe ProgressEvent
$sel:progressEvent:CreateResourceResponse' :: CreateResourceResponse -> Maybe ProgressEvent
progressEvent} -> Maybe ProgressEvent
progressEvent) (\s :: CreateResourceResponse
s@CreateResourceResponse' {} Maybe ProgressEvent
a -> CreateResourceResponse
s {$sel:progressEvent:CreateResourceResponse' :: Maybe ProgressEvent
progressEvent = Maybe ProgressEvent
a} :: CreateResourceResponse)
createResourceResponse_httpStatus :: Lens.Lens' CreateResourceResponse Prelude.Int
createResourceResponse_httpStatus :: (Int -> f Int)
-> CreateResourceResponse -> f CreateResourceResponse
createResourceResponse_httpStatus = (CreateResourceResponse -> Int)
-> (CreateResourceResponse -> Int -> CreateResourceResponse)
-> Lens CreateResourceResponse CreateResourceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateResourceResponse' :: CreateResourceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateResourceResponse
s@CreateResourceResponse' {} Int
a -> CreateResourceResponse
s {$sel:httpStatus:CreateResourceResponse' :: Int
httpStatus = Int
a} :: CreateResourceResponse)
instance Prelude.NFData CreateResourceResponse