{-# 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.GetResource
(
GetResource (..),
newGetResource,
getResource_typeVersionId,
getResource_roleArn,
getResource_typeName,
getResource_identifier,
GetResourceResponse (..),
newGetResourceResponse,
getResourceResponse_typeName,
getResourceResponse_resourceDescription,
getResourceResponse_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 GetResource = GetResource'
{
GetResource -> Maybe Text
typeVersionId :: Prelude.Maybe Prelude.Text,
GetResource -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
GetResource -> Text
typeName :: Prelude.Text,
GetResource -> Text
identifier :: Prelude.Text
}
deriving (GetResource -> GetResource -> Bool
(GetResource -> GetResource -> Bool)
-> (GetResource -> GetResource -> Bool) -> Eq GetResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResource -> GetResource -> Bool
$c/= :: GetResource -> GetResource -> Bool
== :: GetResource -> GetResource -> Bool
$c== :: GetResource -> GetResource -> Bool
Prelude.Eq, ReadPrec [GetResource]
ReadPrec GetResource
Int -> ReadS GetResource
ReadS [GetResource]
(Int -> ReadS GetResource)
-> ReadS [GetResource]
-> ReadPrec GetResource
-> ReadPrec [GetResource]
-> Read GetResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResource]
$creadListPrec :: ReadPrec [GetResource]
readPrec :: ReadPrec GetResource
$creadPrec :: ReadPrec GetResource
readList :: ReadS [GetResource]
$creadList :: ReadS [GetResource]
readsPrec :: Int -> ReadS GetResource
$creadsPrec :: Int -> ReadS GetResource
Prelude.Read, Int -> GetResource -> ShowS
[GetResource] -> ShowS
GetResource -> String
(Int -> GetResource -> ShowS)
-> (GetResource -> String)
-> ([GetResource] -> ShowS)
-> Show GetResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResource] -> ShowS
$cshowList :: [GetResource] -> ShowS
show :: GetResource -> String
$cshow :: GetResource -> String
showsPrec :: Int -> GetResource -> ShowS
$cshowsPrec :: Int -> GetResource -> ShowS
Prelude.Show, (forall x. GetResource -> Rep GetResource x)
-> (forall x. Rep GetResource x -> GetResource)
-> Generic GetResource
forall x. Rep GetResource x -> GetResource
forall x. GetResource -> Rep GetResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResource x -> GetResource
$cfrom :: forall x. GetResource -> Rep GetResource x
Prelude.Generic)
newGetResource ::
Prelude.Text ->
Prelude.Text ->
GetResource
newGetResource :: Text -> Text -> GetResource
newGetResource Text
pTypeName_ Text
pIdentifier_ =
GetResource' :: Maybe Text -> Maybe Text -> Text -> Text -> GetResource
GetResource'
{ $sel:typeVersionId:GetResource' :: Maybe Text
typeVersionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:roleArn:GetResource' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:typeName:GetResource' :: Text
typeName = Text
pTypeName_,
$sel:identifier:GetResource' :: Text
identifier = Text
pIdentifier_
}
getResource_typeVersionId :: Lens.Lens' GetResource (Prelude.Maybe Prelude.Text)
getResource_typeVersionId :: (Maybe Text -> f (Maybe Text)) -> GetResource -> f GetResource
getResource_typeVersionId = (GetResource -> Maybe Text)
-> (GetResource -> Maybe Text -> GetResource)
-> Lens GetResource GetResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Maybe Text
typeVersionId :: Maybe Text
$sel:typeVersionId:GetResource' :: GetResource -> Maybe Text
typeVersionId} -> Maybe Text
typeVersionId) (\s :: GetResource
s@GetResource' {} Maybe Text
a -> GetResource
s {$sel:typeVersionId:GetResource' :: Maybe Text
typeVersionId = Maybe Text
a} :: GetResource)
getResource_roleArn :: Lens.Lens' GetResource (Prelude.Maybe Prelude.Text)
getResource_roleArn :: (Maybe Text -> f (Maybe Text)) -> GetResource -> f GetResource
getResource_roleArn = (GetResource -> Maybe Text)
-> (GetResource -> Maybe Text -> GetResource)
-> Lens GetResource GetResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:GetResource' :: GetResource -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: GetResource
s@GetResource' {} Maybe Text
a -> GetResource
s {$sel:roleArn:GetResource' :: Maybe Text
roleArn = Maybe Text
a} :: GetResource)
getResource_typeName :: Lens.Lens' GetResource Prelude.Text
getResource_typeName :: (Text -> f Text) -> GetResource -> f GetResource
getResource_typeName = (GetResource -> Text)
-> (GetResource -> Text -> GetResource)
-> Lens GetResource GetResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Text
typeName :: Text
$sel:typeName:GetResource' :: GetResource -> Text
typeName} -> Text
typeName) (\s :: GetResource
s@GetResource' {} Text
a -> GetResource
s {$sel:typeName:GetResource' :: Text
typeName = Text
a} :: GetResource)
getResource_identifier :: Lens.Lens' GetResource Prelude.Text
getResource_identifier :: (Text -> f Text) -> GetResource -> f GetResource
getResource_identifier = (GetResource -> Text)
-> (GetResource -> Text -> GetResource)
-> Lens GetResource GetResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Text
identifier :: Text
$sel:identifier:GetResource' :: GetResource -> Text
identifier} -> Text
identifier) (\s :: GetResource
s@GetResource' {} Text
a -> GetResource
s {$sel:identifier:GetResource' :: Text
identifier = Text
a} :: GetResource)
instance Core.AWSRequest GetResource where
type AWSResponse GetResource = GetResourceResponse
request :: GetResource -> Request GetResource
request = Service -> GetResource -> Request GetResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResource)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetResource))
-> Logger
-> Service
-> Proxy GetResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResource)))
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
-> Maybe ResourceDescription -> Int -> GetResourceResponse
GetResourceResponse'
(Maybe Text
-> Maybe ResourceDescription -> Int -> GetResourceResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe ResourceDescription -> Int -> GetResourceResponse)
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
"TypeName")
Either
String (Maybe ResourceDescription -> Int -> GetResourceResponse)
-> Either String (Maybe ResourceDescription)
-> Either String (Int -> GetResourceResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ResourceDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResourceDescription")
Either String (Int -> GetResourceResponse)
-> Either String Int -> Either String GetResourceResponse
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 GetResource
instance Prelude.NFData GetResource
instance Core.ToHeaders GetResource where
toHeaders :: GetResource -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetResource -> 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.GetResource" ::
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 GetResource where
toJSON :: GetResource -> Value
toJSON GetResource' {Maybe Text
Text
identifier :: Text
typeName :: Text
roleArn :: Maybe Text
typeVersionId :: Maybe Text
$sel:identifier:GetResource' :: GetResource -> Text
$sel:typeName:GetResource' :: GetResource -> Text
$sel:roleArn:GetResource' :: GetResource -> Maybe Text
$sel:typeVersionId:GetResource' :: GetResource -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"Identifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identifier)
]
)
instance Core.ToPath GetResource where
toPath :: GetResource -> ByteString
toPath = ByteString -> GetResource -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetResource where
toQuery :: GetResource -> QueryString
toQuery = QueryString -> GetResource -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetResourceResponse = GetResourceResponse'
{
GetResourceResponse -> Maybe Text
typeName :: Prelude.Maybe Prelude.Text,
GetResourceResponse -> Maybe ResourceDescription
resourceDescription :: Prelude.Maybe ResourceDescription,
GetResourceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetResourceResponse -> GetResourceResponse -> Bool
(GetResourceResponse -> GetResourceResponse -> Bool)
-> (GetResourceResponse -> GetResourceResponse -> Bool)
-> Eq GetResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceResponse -> GetResourceResponse -> Bool
$c/= :: GetResourceResponse -> GetResourceResponse -> Bool
== :: GetResourceResponse -> GetResourceResponse -> Bool
$c== :: GetResourceResponse -> GetResourceResponse -> Bool
Prelude.Eq, Int -> GetResourceResponse -> ShowS
[GetResourceResponse] -> ShowS
GetResourceResponse -> String
(Int -> GetResourceResponse -> ShowS)
-> (GetResourceResponse -> String)
-> ([GetResourceResponse] -> ShowS)
-> Show GetResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceResponse] -> ShowS
$cshowList :: [GetResourceResponse] -> ShowS
show :: GetResourceResponse -> String
$cshow :: GetResourceResponse -> String
showsPrec :: Int -> GetResourceResponse -> ShowS
$cshowsPrec :: Int -> GetResourceResponse -> ShowS
Prelude.Show, (forall x. GetResourceResponse -> Rep GetResourceResponse x)
-> (forall x. Rep GetResourceResponse x -> GetResourceResponse)
-> Generic GetResourceResponse
forall x. Rep GetResourceResponse x -> GetResourceResponse
forall x. GetResourceResponse -> Rep GetResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResourceResponse x -> GetResourceResponse
$cfrom :: forall x. GetResourceResponse -> Rep GetResourceResponse x
Prelude.Generic)
newGetResourceResponse ::
Prelude.Int ->
GetResourceResponse
newGetResourceResponse :: Int -> GetResourceResponse
newGetResourceResponse Int
pHttpStatus_ =
GetResourceResponse' :: Maybe Text
-> Maybe ResourceDescription -> Int -> GetResourceResponse
GetResourceResponse'
{ $sel:typeName:GetResourceResponse' :: Maybe Text
typeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:resourceDescription:GetResourceResponse' :: Maybe ResourceDescription
resourceDescription = Maybe ResourceDescription
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getResourceResponse_typeName :: Lens.Lens' GetResourceResponse (Prelude.Maybe Prelude.Text)
getResourceResponse_typeName :: (Maybe Text -> f (Maybe Text))
-> GetResourceResponse -> f GetResourceResponse
getResourceResponse_typeName = (GetResourceResponse -> Maybe Text)
-> (GetResourceResponse -> Maybe Text -> GetResourceResponse)
-> Lens
GetResourceResponse GetResourceResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceResponse' {Maybe Text
typeName :: Maybe Text
$sel:typeName:GetResourceResponse' :: GetResourceResponse -> Maybe Text
typeName} -> Maybe Text
typeName) (\s :: GetResourceResponse
s@GetResourceResponse' {} Maybe Text
a -> GetResourceResponse
s {$sel:typeName:GetResourceResponse' :: Maybe Text
typeName = Maybe Text
a} :: GetResourceResponse)
getResourceResponse_resourceDescription :: Lens.Lens' GetResourceResponse (Prelude.Maybe ResourceDescription)
getResourceResponse_resourceDescription :: (Maybe ResourceDescription -> f (Maybe ResourceDescription))
-> GetResourceResponse -> f GetResourceResponse
getResourceResponse_resourceDescription = (GetResourceResponse -> Maybe ResourceDescription)
-> (GetResourceResponse
-> Maybe ResourceDescription -> GetResourceResponse)
-> Lens
GetResourceResponse
GetResourceResponse
(Maybe ResourceDescription)
(Maybe ResourceDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceResponse' {Maybe ResourceDescription
resourceDescription :: Maybe ResourceDescription
$sel:resourceDescription:GetResourceResponse' :: GetResourceResponse -> Maybe ResourceDescription
resourceDescription} -> Maybe ResourceDescription
resourceDescription) (\s :: GetResourceResponse
s@GetResourceResponse' {} Maybe ResourceDescription
a -> GetResourceResponse
s {$sel:resourceDescription:GetResourceResponse' :: Maybe ResourceDescription
resourceDescription = Maybe ResourceDescription
a} :: GetResourceResponse)
getResourceResponse_httpStatus :: Lens.Lens' GetResourceResponse Prelude.Int
getResourceResponse_httpStatus :: (Int -> f Int) -> GetResourceResponse -> f GetResourceResponse
getResourceResponse_httpStatus = (GetResourceResponse -> Int)
-> (GetResourceResponse -> Int -> GetResourceResponse)
-> Lens GetResourceResponse GetResourceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetResourceResponse' :: GetResourceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetResourceResponse
s@GetResourceResponse' {} Int
a -> GetResourceResponse
s {$sel:httpStatus:GetResourceResponse' :: Int
httpStatus = Int
a} :: GetResourceResponse)
instance Prelude.NFData GetResourceResponse