{-# 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.CloudHSMV2.CreateHsm
(
CreateHsm (..),
newCreateHsm,
createHsm_ipAddress,
createHsm_clusterId,
createHsm_availabilityZone,
CreateHsmResponse (..),
newCreateHsmResponse,
createHsmResponse_hsm,
createHsmResponse_httpStatus,
)
where
import Amazonka.CloudHSMV2.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateHsm = CreateHsm'
{
CreateHsm -> Maybe Text
ipAddress :: Prelude.Maybe Prelude.Text,
CreateHsm -> Text
clusterId :: Prelude.Text,
CreateHsm -> Text
availabilityZone :: Prelude.Text
}
deriving (CreateHsm -> CreateHsm -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHsm -> CreateHsm -> Bool
$c/= :: CreateHsm -> CreateHsm -> Bool
== :: CreateHsm -> CreateHsm -> Bool
$c== :: CreateHsm -> CreateHsm -> Bool
Prelude.Eq, ReadPrec [CreateHsm]
ReadPrec CreateHsm
Int -> ReadS CreateHsm
ReadS [CreateHsm]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHsm]
$creadListPrec :: ReadPrec [CreateHsm]
readPrec :: ReadPrec CreateHsm
$creadPrec :: ReadPrec CreateHsm
readList :: ReadS [CreateHsm]
$creadList :: ReadS [CreateHsm]
readsPrec :: Int -> ReadS CreateHsm
$creadsPrec :: Int -> ReadS CreateHsm
Prelude.Read, Int -> CreateHsm -> ShowS
[CreateHsm] -> ShowS
CreateHsm -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHsm] -> ShowS
$cshowList :: [CreateHsm] -> ShowS
show :: CreateHsm -> String
$cshow :: CreateHsm -> String
showsPrec :: Int -> CreateHsm -> ShowS
$cshowsPrec :: Int -> CreateHsm -> ShowS
Prelude.Show, forall x. Rep CreateHsm x -> CreateHsm
forall x. CreateHsm -> Rep CreateHsm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateHsm x -> CreateHsm
$cfrom :: forall x. CreateHsm -> Rep CreateHsm x
Prelude.Generic)
newCreateHsm ::
Prelude.Text ->
Prelude.Text ->
CreateHsm
newCreateHsm :: Text -> Text -> CreateHsm
newCreateHsm Text
pClusterId_ Text
pAvailabilityZone_ =
CreateHsm'
{ $sel:ipAddress:CreateHsm' :: Maybe Text
ipAddress = forall a. Maybe a
Prelude.Nothing,
$sel:clusterId:CreateHsm' :: Text
clusterId = Text
pClusterId_,
$sel:availabilityZone:CreateHsm' :: Text
availabilityZone = Text
pAvailabilityZone_
}
createHsm_ipAddress :: Lens.Lens' CreateHsm (Prelude.Maybe Prelude.Text)
createHsm_ipAddress :: Lens' CreateHsm (Maybe Text)
createHsm_ipAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHsm' {Maybe Text
ipAddress :: Maybe Text
$sel:ipAddress:CreateHsm' :: CreateHsm -> Maybe Text
ipAddress} -> Maybe Text
ipAddress) (\s :: CreateHsm
s@CreateHsm' {} Maybe Text
a -> CreateHsm
s {$sel:ipAddress:CreateHsm' :: Maybe Text
ipAddress = Maybe Text
a} :: CreateHsm)
createHsm_clusterId :: Lens.Lens' CreateHsm Prelude.Text
createHsm_clusterId :: Lens' CreateHsm Text
createHsm_clusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHsm' {Text
clusterId :: Text
$sel:clusterId:CreateHsm' :: CreateHsm -> Text
clusterId} -> Text
clusterId) (\s :: CreateHsm
s@CreateHsm' {} Text
a -> CreateHsm
s {$sel:clusterId:CreateHsm' :: Text
clusterId = Text
a} :: CreateHsm)
createHsm_availabilityZone :: Lens.Lens' CreateHsm Prelude.Text
createHsm_availabilityZone :: Lens' CreateHsm Text
createHsm_availabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHsm' {Text
availabilityZone :: Text
$sel:availabilityZone:CreateHsm' :: CreateHsm -> Text
availabilityZone} -> Text
availabilityZone) (\s :: CreateHsm
s@CreateHsm' {} Text
a -> CreateHsm
s {$sel:availabilityZone:CreateHsm' :: Text
availabilityZone = Text
a} :: CreateHsm)
instance Core.AWSRequest CreateHsm where
type AWSResponse CreateHsm = CreateHsmResponse
request :: (Service -> Service) -> CreateHsm -> Request CreateHsm
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateHsm
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateHsm)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Hsm -> Int -> CreateHsmResponse
CreateHsmResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Hsm")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateHsm where
hashWithSalt :: Int -> CreateHsm -> Int
hashWithSalt Int
_salt CreateHsm' {Maybe Text
Text
availabilityZone :: Text
clusterId :: Text
ipAddress :: Maybe Text
$sel:availabilityZone:CreateHsm' :: CreateHsm -> Text
$sel:clusterId:CreateHsm' :: CreateHsm -> Text
$sel:ipAddress:CreateHsm' :: CreateHsm -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipAddress
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
availabilityZone
instance Prelude.NFData CreateHsm where
rnf :: CreateHsm -> ()
rnf CreateHsm' {Maybe Text
Text
availabilityZone :: Text
clusterId :: Text
ipAddress :: Maybe Text
$sel:availabilityZone:CreateHsm' :: CreateHsm -> Text
$sel:clusterId:CreateHsm' :: CreateHsm -> Text
$sel:ipAddress:CreateHsm' :: CreateHsm -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipAddress
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clusterId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
availabilityZone
instance Data.ToHeaders CreateHsm where
toHeaders :: CreateHsm -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"BaldrApiService.CreateHsm" :: Prelude.ByteString),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON CreateHsm where
toJSON :: CreateHsm -> Value
toJSON CreateHsm' {Maybe Text
Text
availabilityZone :: Text
clusterId :: Text
ipAddress :: Maybe Text
$sel:availabilityZone:CreateHsm' :: CreateHsm -> Text
$sel:clusterId:CreateHsm' :: CreateHsm -> Text
$sel:ipAddress:CreateHsm' :: CreateHsm -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"IpAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ipAddress,
forall a. a -> Maybe a
Prelude.Just (Key
"ClusterId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clusterId),
forall a. a -> Maybe a
Prelude.Just
(Key
"AvailabilityZone" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
availabilityZone)
]
)
instance Data.ToPath CreateHsm where
toPath :: CreateHsm -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreateHsm where
toQuery :: CreateHsm -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreateHsmResponse = CreateHsmResponse'
{
CreateHsmResponse -> Maybe Hsm
hsm :: Prelude.Maybe Hsm,
CreateHsmResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateHsmResponse -> CreateHsmResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHsmResponse -> CreateHsmResponse -> Bool
$c/= :: CreateHsmResponse -> CreateHsmResponse -> Bool
== :: CreateHsmResponse -> CreateHsmResponse -> Bool
$c== :: CreateHsmResponse -> CreateHsmResponse -> Bool
Prelude.Eq, ReadPrec [CreateHsmResponse]
ReadPrec CreateHsmResponse
Int -> ReadS CreateHsmResponse
ReadS [CreateHsmResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHsmResponse]
$creadListPrec :: ReadPrec [CreateHsmResponse]
readPrec :: ReadPrec CreateHsmResponse
$creadPrec :: ReadPrec CreateHsmResponse
readList :: ReadS [CreateHsmResponse]
$creadList :: ReadS [CreateHsmResponse]
readsPrec :: Int -> ReadS CreateHsmResponse
$creadsPrec :: Int -> ReadS CreateHsmResponse
Prelude.Read, Int -> CreateHsmResponse -> ShowS
[CreateHsmResponse] -> ShowS
CreateHsmResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHsmResponse] -> ShowS
$cshowList :: [CreateHsmResponse] -> ShowS
show :: CreateHsmResponse -> String
$cshow :: CreateHsmResponse -> String
showsPrec :: Int -> CreateHsmResponse -> ShowS
$cshowsPrec :: Int -> CreateHsmResponse -> ShowS
Prelude.Show, forall x. Rep CreateHsmResponse x -> CreateHsmResponse
forall x. CreateHsmResponse -> Rep CreateHsmResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateHsmResponse x -> CreateHsmResponse
$cfrom :: forall x. CreateHsmResponse -> Rep CreateHsmResponse x
Prelude.Generic)
newCreateHsmResponse ::
Prelude.Int ->
CreateHsmResponse
newCreateHsmResponse :: Int -> CreateHsmResponse
newCreateHsmResponse Int
pHttpStatus_ =
CreateHsmResponse'
{ $sel:hsm:CreateHsmResponse' :: Maybe Hsm
hsm = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateHsmResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createHsmResponse_hsm :: Lens.Lens' CreateHsmResponse (Prelude.Maybe Hsm)
createHsmResponse_hsm :: Lens' CreateHsmResponse (Maybe Hsm)
createHsmResponse_hsm = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHsmResponse' {Maybe Hsm
hsm :: Maybe Hsm
$sel:hsm:CreateHsmResponse' :: CreateHsmResponse -> Maybe Hsm
hsm} -> Maybe Hsm
hsm) (\s :: CreateHsmResponse
s@CreateHsmResponse' {} Maybe Hsm
a -> CreateHsmResponse
s {$sel:hsm:CreateHsmResponse' :: Maybe Hsm
hsm = Maybe Hsm
a} :: CreateHsmResponse)
createHsmResponse_httpStatus :: Lens.Lens' CreateHsmResponse Prelude.Int
createHsmResponse_httpStatus :: Lens' CreateHsmResponse Int
createHsmResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHsmResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateHsmResponse' :: CreateHsmResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateHsmResponse
s@CreateHsmResponse' {} Int
a -> CreateHsmResponse
s {$sel:httpStatus:CreateHsmResponse' :: Int
httpStatus = Int
a} :: CreateHsmResponse)
instance Prelude.NFData CreateHsmResponse where
rnf :: CreateHsmResponse -> ()
rnf CreateHsmResponse' {Int
Maybe Hsm
httpStatus :: Int
hsm :: Maybe Hsm
$sel:httpStatus:CreateHsmResponse' :: CreateHsmResponse -> Int
$sel:hsm:CreateHsmResponse' :: CreateHsmResponse -> Maybe Hsm
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Hsm
hsm
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus