{-# 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.InitializeCluster
(
InitializeCluster (..),
newInitializeCluster,
initializeCluster_clusterId,
initializeCluster_signedCert,
initializeCluster_trustAnchor,
InitializeClusterResponse (..),
newInitializeClusterResponse,
initializeClusterResponse_stateMessage,
initializeClusterResponse_state,
initializeClusterResponse_httpStatus,
)
where
import Amazonka.CloudHSMV2.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 InitializeCluster = InitializeCluster'
{
InitializeCluster -> Text
clusterId :: Prelude.Text,
InitializeCluster -> Text
signedCert :: Prelude.Text,
InitializeCluster -> Text
trustAnchor :: Prelude.Text
}
deriving (InitializeCluster -> InitializeCluster -> Bool
(InitializeCluster -> InitializeCluster -> Bool)
-> (InitializeCluster -> InitializeCluster -> Bool)
-> Eq InitializeCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitializeCluster -> InitializeCluster -> Bool
$c/= :: InitializeCluster -> InitializeCluster -> Bool
== :: InitializeCluster -> InitializeCluster -> Bool
$c== :: InitializeCluster -> InitializeCluster -> Bool
Prelude.Eq, ReadPrec [InitializeCluster]
ReadPrec InitializeCluster
Int -> ReadS InitializeCluster
ReadS [InitializeCluster]
(Int -> ReadS InitializeCluster)
-> ReadS [InitializeCluster]
-> ReadPrec InitializeCluster
-> ReadPrec [InitializeCluster]
-> Read InitializeCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitializeCluster]
$creadListPrec :: ReadPrec [InitializeCluster]
readPrec :: ReadPrec InitializeCluster
$creadPrec :: ReadPrec InitializeCluster
readList :: ReadS [InitializeCluster]
$creadList :: ReadS [InitializeCluster]
readsPrec :: Int -> ReadS InitializeCluster
$creadsPrec :: Int -> ReadS InitializeCluster
Prelude.Read, Int -> InitializeCluster -> ShowS
[InitializeCluster] -> ShowS
InitializeCluster -> String
(Int -> InitializeCluster -> ShowS)
-> (InitializeCluster -> String)
-> ([InitializeCluster] -> ShowS)
-> Show InitializeCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitializeCluster] -> ShowS
$cshowList :: [InitializeCluster] -> ShowS
show :: InitializeCluster -> String
$cshow :: InitializeCluster -> String
showsPrec :: Int -> InitializeCluster -> ShowS
$cshowsPrec :: Int -> InitializeCluster -> ShowS
Prelude.Show, (forall x. InitializeCluster -> Rep InitializeCluster x)
-> (forall x. Rep InitializeCluster x -> InitializeCluster)
-> Generic InitializeCluster
forall x. Rep InitializeCluster x -> InitializeCluster
forall x. InitializeCluster -> Rep InitializeCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InitializeCluster x -> InitializeCluster
$cfrom :: forall x. InitializeCluster -> Rep InitializeCluster x
Prelude.Generic)
newInitializeCluster ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
InitializeCluster
newInitializeCluster :: Text -> Text -> Text -> InitializeCluster
newInitializeCluster
Text
pClusterId_
Text
pSignedCert_
Text
pTrustAnchor_ =
InitializeCluster' :: Text -> Text -> Text -> InitializeCluster
InitializeCluster'
{ $sel:clusterId:InitializeCluster' :: Text
clusterId = Text
pClusterId_,
$sel:signedCert:InitializeCluster' :: Text
signedCert = Text
pSignedCert_,
$sel:trustAnchor:InitializeCluster' :: Text
trustAnchor = Text
pTrustAnchor_
}
initializeCluster_clusterId :: Lens.Lens' InitializeCluster Prelude.Text
initializeCluster_clusterId :: (Text -> f Text) -> InitializeCluster -> f InitializeCluster
initializeCluster_clusterId = (InitializeCluster -> Text)
-> (InitializeCluster -> Text -> InitializeCluster)
-> Lens InitializeCluster InitializeCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeCluster' {Text
clusterId :: Text
$sel:clusterId:InitializeCluster' :: InitializeCluster -> Text
clusterId} -> Text
clusterId) (\s :: InitializeCluster
s@InitializeCluster' {} Text
a -> InitializeCluster
s {$sel:clusterId:InitializeCluster' :: Text
clusterId = Text
a} :: InitializeCluster)
initializeCluster_signedCert :: Lens.Lens' InitializeCluster Prelude.Text
initializeCluster_signedCert :: (Text -> f Text) -> InitializeCluster -> f InitializeCluster
initializeCluster_signedCert = (InitializeCluster -> Text)
-> (InitializeCluster -> Text -> InitializeCluster)
-> Lens InitializeCluster InitializeCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeCluster' {Text
signedCert :: Text
$sel:signedCert:InitializeCluster' :: InitializeCluster -> Text
signedCert} -> Text
signedCert) (\s :: InitializeCluster
s@InitializeCluster' {} Text
a -> InitializeCluster
s {$sel:signedCert:InitializeCluster' :: Text
signedCert = Text
a} :: InitializeCluster)
initializeCluster_trustAnchor :: Lens.Lens' InitializeCluster Prelude.Text
initializeCluster_trustAnchor :: (Text -> f Text) -> InitializeCluster -> f InitializeCluster
initializeCluster_trustAnchor = (InitializeCluster -> Text)
-> (InitializeCluster -> Text -> InitializeCluster)
-> Lens InitializeCluster InitializeCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeCluster' {Text
trustAnchor :: Text
$sel:trustAnchor:InitializeCluster' :: InitializeCluster -> Text
trustAnchor} -> Text
trustAnchor) (\s :: InitializeCluster
s@InitializeCluster' {} Text
a -> InitializeCluster
s {$sel:trustAnchor:InitializeCluster' :: Text
trustAnchor = Text
a} :: InitializeCluster)
instance Core.AWSRequest InitializeCluster where
type
AWSResponse InitializeCluster =
InitializeClusterResponse
request :: InitializeCluster -> Request InitializeCluster
request = Service -> InitializeCluster -> Request InitializeCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy InitializeCluster
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitializeCluster)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse InitializeCluster))
-> Logger
-> Service
-> Proxy InitializeCluster
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitializeCluster)))
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 ClusterState -> Int -> InitializeClusterResponse
InitializeClusterResponse'
(Maybe Text
-> Maybe ClusterState -> Int -> InitializeClusterResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe ClusterState -> Int -> InitializeClusterResponse)
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
"StateMessage")
Either
String (Maybe ClusterState -> Int -> InitializeClusterResponse)
-> Either String (Maybe ClusterState)
-> Either String (Int -> InitializeClusterResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ClusterState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"State")
Either String (Int -> InitializeClusterResponse)
-> Either String Int -> Either String InitializeClusterResponse
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 InitializeCluster
instance Prelude.NFData InitializeCluster
instance Core.ToHeaders InitializeCluster where
toHeaders :: InitializeCluster -> ResponseHeaders
toHeaders =
ResponseHeaders -> InitializeCluster -> 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
"BaldrApiService.InitializeCluster" ::
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 InitializeCluster where
toJSON :: InitializeCluster -> Value
toJSON InitializeCluster' {Text
trustAnchor :: Text
signedCert :: Text
clusterId :: Text
$sel:trustAnchor:InitializeCluster' :: InitializeCluster -> Text
$sel:signedCert:InitializeCluster' :: InitializeCluster -> Text
$sel:clusterId:InitializeCluster' :: InitializeCluster -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClusterId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SignedCert" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
signedCert),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TrustAnchor" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
trustAnchor)
]
)
instance Core.ToPath InitializeCluster where
toPath :: InitializeCluster -> ByteString
toPath = ByteString -> InitializeCluster -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery InitializeCluster where
toQuery :: InitializeCluster -> QueryString
toQuery = QueryString -> InitializeCluster -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data InitializeClusterResponse = InitializeClusterResponse'
{
InitializeClusterResponse -> Maybe Text
stateMessage :: Prelude.Maybe Prelude.Text,
InitializeClusterResponse -> Maybe ClusterState
state :: Prelude.Maybe ClusterState,
InitializeClusterResponse -> Int
httpStatus :: Prelude.Int
}
deriving (InitializeClusterResponse -> InitializeClusterResponse -> Bool
(InitializeClusterResponse -> InitializeClusterResponse -> Bool)
-> (InitializeClusterResponse -> InitializeClusterResponse -> Bool)
-> Eq InitializeClusterResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitializeClusterResponse -> InitializeClusterResponse -> Bool
$c/= :: InitializeClusterResponse -> InitializeClusterResponse -> Bool
== :: InitializeClusterResponse -> InitializeClusterResponse -> Bool
$c== :: InitializeClusterResponse -> InitializeClusterResponse -> Bool
Prelude.Eq, ReadPrec [InitializeClusterResponse]
ReadPrec InitializeClusterResponse
Int -> ReadS InitializeClusterResponse
ReadS [InitializeClusterResponse]
(Int -> ReadS InitializeClusterResponse)
-> ReadS [InitializeClusterResponse]
-> ReadPrec InitializeClusterResponse
-> ReadPrec [InitializeClusterResponse]
-> Read InitializeClusterResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitializeClusterResponse]
$creadListPrec :: ReadPrec [InitializeClusterResponse]
readPrec :: ReadPrec InitializeClusterResponse
$creadPrec :: ReadPrec InitializeClusterResponse
readList :: ReadS [InitializeClusterResponse]
$creadList :: ReadS [InitializeClusterResponse]
readsPrec :: Int -> ReadS InitializeClusterResponse
$creadsPrec :: Int -> ReadS InitializeClusterResponse
Prelude.Read, Int -> InitializeClusterResponse -> ShowS
[InitializeClusterResponse] -> ShowS
InitializeClusterResponse -> String
(Int -> InitializeClusterResponse -> ShowS)
-> (InitializeClusterResponse -> String)
-> ([InitializeClusterResponse] -> ShowS)
-> Show InitializeClusterResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitializeClusterResponse] -> ShowS
$cshowList :: [InitializeClusterResponse] -> ShowS
show :: InitializeClusterResponse -> String
$cshow :: InitializeClusterResponse -> String
showsPrec :: Int -> InitializeClusterResponse -> ShowS
$cshowsPrec :: Int -> InitializeClusterResponse -> ShowS
Prelude.Show, (forall x.
InitializeClusterResponse -> Rep InitializeClusterResponse x)
-> (forall x.
Rep InitializeClusterResponse x -> InitializeClusterResponse)
-> Generic InitializeClusterResponse
forall x.
Rep InitializeClusterResponse x -> InitializeClusterResponse
forall x.
InitializeClusterResponse -> Rep InitializeClusterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InitializeClusterResponse x -> InitializeClusterResponse
$cfrom :: forall x.
InitializeClusterResponse -> Rep InitializeClusterResponse x
Prelude.Generic)
newInitializeClusterResponse ::
Prelude.Int ->
InitializeClusterResponse
newInitializeClusterResponse :: Int -> InitializeClusterResponse
newInitializeClusterResponse Int
pHttpStatus_ =
InitializeClusterResponse' :: Maybe Text
-> Maybe ClusterState -> Int -> InitializeClusterResponse
InitializeClusterResponse'
{ $sel:stateMessage:InitializeClusterResponse' :: Maybe Text
stateMessage =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:state:InitializeClusterResponse' :: Maybe ClusterState
state = Maybe ClusterState
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:InitializeClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
}
initializeClusterResponse_stateMessage :: Lens.Lens' InitializeClusterResponse (Prelude.Maybe Prelude.Text)
initializeClusterResponse_stateMessage :: (Maybe Text -> f (Maybe Text))
-> InitializeClusterResponse -> f InitializeClusterResponse
initializeClusterResponse_stateMessage = (InitializeClusterResponse -> Maybe Text)
-> (InitializeClusterResponse
-> Maybe Text -> InitializeClusterResponse)
-> Lens
InitializeClusterResponse
InitializeClusterResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeClusterResponse' {Maybe Text
stateMessage :: Maybe Text
$sel:stateMessage:InitializeClusterResponse' :: InitializeClusterResponse -> Maybe Text
stateMessage} -> Maybe Text
stateMessage) (\s :: InitializeClusterResponse
s@InitializeClusterResponse' {} Maybe Text
a -> InitializeClusterResponse
s {$sel:stateMessage:InitializeClusterResponse' :: Maybe Text
stateMessage = Maybe Text
a} :: InitializeClusterResponse)
initializeClusterResponse_state :: Lens.Lens' InitializeClusterResponse (Prelude.Maybe ClusterState)
initializeClusterResponse_state :: (Maybe ClusterState -> f (Maybe ClusterState))
-> InitializeClusterResponse -> f InitializeClusterResponse
initializeClusterResponse_state = (InitializeClusterResponse -> Maybe ClusterState)
-> (InitializeClusterResponse
-> Maybe ClusterState -> InitializeClusterResponse)
-> Lens
InitializeClusterResponse
InitializeClusterResponse
(Maybe ClusterState)
(Maybe ClusterState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeClusterResponse' {Maybe ClusterState
state :: Maybe ClusterState
$sel:state:InitializeClusterResponse' :: InitializeClusterResponse -> Maybe ClusterState
state} -> Maybe ClusterState
state) (\s :: InitializeClusterResponse
s@InitializeClusterResponse' {} Maybe ClusterState
a -> InitializeClusterResponse
s {$sel:state:InitializeClusterResponse' :: Maybe ClusterState
state = Maybe ClusterState
a} :: InitializeClusterResponse)
initializeClusterResponse_httpStatus :: Lens.Lens' InitializeClusterResponse Prelude.Int
initializeClusterResponse_httpStatus :: (Int -> f Int)
-> InitializeClusterResponse -> f InitializeClusterResponse
initializeClusterResponse_httpStatus = (InitializeClusterResponse -> Int)
-> (InitializeClusterResponse -> Int -> InitializeClusterResponse)
-> Lens InitializeClusterResponse InitializeClusterResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitializeClusterResponse' {Int
httpStatus :: Int
$sel:httpStatus:InitializeClusterResponse' :: InitializeClusterResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: InitializeClusterResponse
s@InitializeClusterResponse' {} Int
a -> InitializeClusterResponse
s {$sel:httpStatus:InitializeClusterResponse' :: Int
httpStatus = Int
a} :: InitializeClusterResponse)
instance Prelude.NFData InitializeClusterResponse