{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudHSM.CreateHapg
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This is documentation for __AWS CloudHSM Classic__. For more
-- information, see
-- <http://aws.amazon.com/cloudhsm/faqs-classic/ AWS CloudHSM Classic FAQs>,
-- the
-- <https://docs.aws.amazon.com/cloudhsm/classic/userguide/ AWS CloudHSM Classic User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/classic/APIReference/ AWS CloudHSM Classic API Reference>.
--
-- __For information about the current version of AWS CloudHSM__, see
-- <http://aws.amazon.com/cloudhsm/ AWS CloudHSM>, the
-- <https://docs.aws.amazon.com/cloudhsm/latest/userguide/ AWS CloudHSM User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/latest/APIReference/ AWS CloudHSM API Reference>.
--
-- Creates a high-availability partition group. A high-availability
-- partition group is a group of partitions that spans multiple physical
-- HSMs.
module Amazonka.CloudHSM.CreateHapg
  ( -- * Creating a Request
    CreateHapg (..),
    newCreateHapg,

    -- * Request Lenses
    createHapg_label,

    -- * Destructuring the Response
    CreateHapgResponse (..),
    newCreateHapgResponse,

    -- * Response Lenses
    createHapgResponse_hapgArn,
    createHapgResponse_httpStatus,
  )
where

import Amazonka.CloudHSM.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

-- | Contains the inputs for the CreateHapgRequest action.
--
-- /See:/ 'newCreateHapg' smart constructor.
data CreateHapg = CreateHapg'
  { -- | The label of the new high-availability partition group.
    CreateHapg -> Text
label :: Prelude.Text
  }
  deriving (CreateHapg -> CreateHapg -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHapg -> CreateHapg -> Bool
$c/= :: CreateHapg -> CreateHapg -> Bool
== :: CreateHapg -> CreateHapg -> Bool
$c== :: CreateHapg -> CreateHapg -> Bool
Prelude.Eq, ReadPrec [CreateHapg]
ReadPrec CreateHapg
Int -> ReadS CreateHapg
ReadS [CreateHapg]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHapg]
$creadListPrec :: ReadPrec [CreateHapg]
readPrec :: ReadPrec CreateHapg
$creadPrec :: ReadPrec CreateHapg
readList :: ReadS [CreateHapg]
$creadList :: ReadS [CreateHapg]
readsPrec :: Int -> ReadS CreateHapg
$creadsPrec :: Int -> ReadS CreateHapg
Prelude.Read, Int -> CreateHapg -> ShowS
[CreateHapg] -> ShowS
CreateHapg -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHapg] -> ShowS
$cshowList :: [CreateHapg] -> ShowS
show :: CreateHapg -> String
$cshow :: CreateHapg -> String
showsPrec :: Int -> CreateHapg -> ShowS
$cshowsPrec :: Int -> CreateHapg -> ShowS
Prelude.Show, forall x. Rep CreateHapg x -> CreateHapg
forall x. CreateHapg -> Rep CreateHapg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateHapg x -> CreateHapg
$cfrom :: forall x. CreateHapg -> Rep CreateHapg x
Prelude.Generic)

-- |
-- Create a value of 'CreateHapg' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'label', 'createHapg_label' - The label of the new high-availability partition group.
newCreateHapg ::
  -- | 'label'
  Prelude.Text ->
  CreateHapg
newCreateHapg :: Text -> CreateHapg
newCreateHapg Text
pLabel_ = CreateHapg' {$sel:label:CreateHapg' :: Text
label = Text
pLabel_}

-- | The label of the new high-availability partition group.
createHapg_label :: Lens.Lens' CreateHapg Prelude.Text
createHapg_label :: Lens' CreateHapg Text
createHapg_label = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHapg' {Text
label :: Text
$sel:label:CreateHapg' :: CreateHapg -> Text
label} -> Text
label) (\s :: CreateHapg
s@CreateHapg' {} Text
a -> CreateHapg
s {$sel:label:CreateHapg' :: Text
label = Text
a} :: CreateHapg)

instance Core.AWSRequest CreateHapg where
  type AWSResponse CreateHapg = CreateHapgResponse
  request :: (Service -> Service) -> CreateHapg -> Request CreateHapg
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 CreateHapg
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateHapg)))
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 Text -> Int -> CreateHapgResponse
CreateHapgResponse'
            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
"HapgArn")
            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 CreateHapg where
  hashWithSalt :: Int -> CreateHapg -> Int
hashWithSalt Int
_salt CreateHapg' {Text
label :: Text
$sel:label:CreateHapg' :: CreateHapg -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
label

instance Prelude.NFData CreateHapg where
  rnf :: CreateHapg -> ()
rnf CreateHapg' {Text
label :: Text
$sel:label:CreateHapg' :: CreateHapg -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
label

instance Data.ToHeaders CreateHapg where
  toHeaders :: CreateHapg -> 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
"CloudHsmFrontendService.CreateHapg" ::
                          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 CreateHapg where
  toJSON :: CreateHapg -> Value
toJSON CreateHapg' {Text
label :: Text
$sel:label:CreateHapg' :: CreateHapg -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Label" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
label)]
      )

instance Data.ToPath CreateHapg where
  toPath :: CreateHapg -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateHapg where
  toQuery :: CreateHapg -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | Contains the output of the CreateHAPartitionGroup action.
--
-- /See:/ 'newCreateHapgResponse' smart constructor.
data CreateHapgResponse = CreateHapgResponse'
  { -- | The ARN of the high-availability partition group.
    CreateHapgResponse -> Maybe Text
hapgArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateHapgResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateHapgResponse -> CreateHapgResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateHapgResponse -> CreateHapgResponse -> Bool
$c/= :: CreateHapgResponse -> CreateHapgResponse -> Bool
== :: CreateHapgResponse -> CreateHapgResponse -> Bool
$c== :: CreateHapgResponse -> CreateHapgResponse -> Bool
Prelude.Eq, ReadPrec [CreateHapgResponse]
ReadPrec CreateHapgResponse
Int -> ReadS CreateHapgResponse
ReadS [CreateHapgResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateHapgResponse]
$creadListPrec :: ReadPrec [CreateHapgResponse]
readPrec :: ReadPrec CreateHapgResponse
$creadPrec :: ReadPrec CreateHapgResponse
readList :: ReadS [CreateHapgResponse]
$creadList :: ReadS [CreateHapgResponse]
readsPrec :: Int -> ReadS CreateHapgResponse
$creadsPrec :: Int -> ReadS CreateHapgResponse
Prelude.Read, Int -> CreateHapgResponse -> ShowS
[CreateHapgResponse] -> ShowS
CreateHapgResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateHapgResponse] -> ShowS
$cshowList :: [CreateHapgResponse] -> ShowS
show :: CreateHapgResponse -> String
$cshow :: CreateHapgResponse -> String
showsPrec :: Int -> CreateHapgResponse -> ShowS
$cshowsPrec :: Int -> CreateHapgResponse -> ShowS
Prelude.Show, forall x. Rep CreateHapgResponse x -> CreateHapgResponse
forall x. CreateHapgResponse -> Rep CreateHapgResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateHapgResponse x -> CreateHapgResponse
$cfrom :: forall x. CreateHapgResponse -> Rep CreateHapgResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateHapgResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'hapgArn', 'createHapgResponse_hapgArn' - The ARN of the high-availability partition group.
--
-- 'httpStatus', 'createHapgResponse_httpStatus' - The response's http status code.
newCreateHapgResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateHapgResponse
newCreateHapgResponse :: Int -> CreateHapgResponse
newCreateHapgResponse Int
pHttpStatus_ =
  CreateHapgResponse'
    { $sel:hapgArn:CreateHapgResponse' :: Maybe Text
hapgArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateHapgResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the high-availability partition group.
createHapgResponse_hapgArn :: Lens.Lens' CreateHapgResponse (Prelude.Maybe Prelude.Text)
createHapgResponse_hapgArn :: Lens' CreateHapgResponse (Maybe Text)
createHapgResponse_hapgArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHapgResponse' {Maybe Text
hapgArn :: Maybe Text
$sel:hapgArn:CreateHapgResponse' :: CreateHapgResponse -> Maybe Text
hapgArn} -> Maybe Text
hapgArn) (\s :: CreateHapgResponse
s@CreateHapgResponse' {} Maybe Text
a -> CreateHapgResponse
s {$sel:hapgArn:CreateHapgResponse' :: Maybe Text
hapgArn = Maybe Text
a} :: CreateHapgResponse)

-- | The response's http status code.
createHapgResponse_httpStatus :: Lens.Lens' CreateHapgResponse Prelude.Int
createHapgResponse_httpStatus :: Lens' CreateHapgResponse Int
createHapgResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateHapgResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateHapgResponse' :: CreateHapgResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateHapgResponse
s@CreateHapgResponse' {} Int
a -> CreateHapgResponse
s {$sel:httpStatus:CreateHapgResponse' :: Int
httpStatus = Int
a} :: CreateHapgResponse)

instance Prelude.NFData CreateHapgResponse where
  rnf :: CreateHapgResponse -> ()
rnf CreateHapgResponse' {Int
Maybe Text
httpStatus :: Int
hapgArn :: Maybe Text
$sel:httpStatus:CreateHapgResponse' :: CreateHapgResponse -> Int
$sel:hapgArn:CreateHapgResponse' :: CreateHapgResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hapgArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus