{-# 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.ModifyLunaClient
-- 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>.
--
-- Modifies the certificate used by the client.
--
-- This action can potentially start a workflow to install the new
-- certificate on the client\'s HSMs.
module Amazonka.CloudHSM.ModifyLunaClient
  ( -- * Creating a Request
    ModifyLunaClient (..),
    newModifyLunaClient,

    -- * Request Lenses
    modifyLunaClient_clientArn,
    modifyLunaClient_certificate,

    -- * Destructuring the Response
    ModifyLunaClientResponse (..),
    newModifyLunaClientResponse,

    -- * Response Lenses
    modifyLunaClientResponse_clientArn,
    modifyLunaClientResponse_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

-- | /See:/ 'newModifyLunaClient' smart constructor.
data ModifyLunaClient = ModifyLunaClient'
  { -- | The ARN of the client.
    ModifyLunaClient -> Text
clientArn :: Prelude.Text,
    -- | The new certificate for the client.
    ModifyLunaClient -> Text
certificate :: Prelude.Text
  }
  deriving (ModifyLunaClient -> ModifyLunaClient -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyLunaClient -> ModifyLunaClient -> Bool
$c/= :: ModifyLunaClient -> ModifyLunaClient -> Bool
== :: ModifyLunaClient -> ModifyLunaClient -> Bool
$c== :: ModifyLunaClient -> ModifyLunaClient -> Bool
Prelude.Eq, ReadPrec [ModifyLunaClient]
ReadPrec ModifyLunaClient
Int -> ReadS ModifyLunaClient
ReadS [ModifyLunaClient]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyLunaClient]
$creadListPrec :: ReadPrec [ModifyLunaClient]
readPrec :: ReadPrec ModifyLunaClient
$creadPrec :: ReadPrec ModifyLunaClient
readList :: ReadS [ModifyLunaClient]
$creadList :: ReadS [ModifyLunaClient]
readsPrec :: Int -> ReadS ModifyLunaClient
$creadsPrec :: Int -> ReadS ModifyLunaClient
Prelude.Read, Int -> ModifyLunaClient -> ShowS
[ModifyLunaClient] -> ShowS
ModifyLunaClient -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyLunaClient] -> ShowS
$cshowList :: [ModifyLunaClient] -> ShowS
show :: ModifyLunaClient -> String
$cshow :: ModifyLunaClient -> String
showsPrec :: Int -> ModifyLunaClient -> ShowS
$cshowsPrec :: Int -> ModifyLunaClient -> ShowS
Prelude.Show, forall x. Rep ModifyLunaClient x -> ModifyLunaClient
forall x. ModifyLunaClient -> Rep ModifyLunaClient x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyLunaClient x -> ModifyLunaClient
$cfrom :: forall x. ModifyLunaClient -> Rep ModifyLunaClient x
Prelude.Generic)

-- |
-- Create a value of 'ModifyLunaClient' 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:
--
-- 'clientArn', 'modifyLunaClient_clientArn' - The ARN of the client.
--
-- 'certificate', 'modifyLunaClient_certificate' - The new certificate for the client.
newModifyLunaClient ::
  -- | 'clientArn'
  Prelude.Text ->
  -- | 'certificate'
  Prelude.Text ->
  ModifyLunaClient
newModifyLunaClient :: Text -> Text -> ModifyLunaClient
newModifyLunaClient Text
pClientArn_ Text
pCertificate_ =
  ModifyLunaClient'
    { $sel:clientArn:ModifyLunaClient' :: Text
clientArn = Text
pClientArn_,
      $sel:certificate:ModifyLunaClient' :: Text
certificate = Text
pCertificate_
    }

-- | The ARN of the client.
modifyLunaClient_clientArn :: Lens.Lens' ModifyLunaClient Prelude.Text
modifyLunaClient_clientArn :: Lens' ModifyLunaClient Text
modifyLunaClient_clientArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyLunaClient' {Text
clientArn :: Text
$sel:clientArn:ModifyLunaClient' :: ModifyLunaClient -> Text
clientArn} -> Text
clientArn) (\s :: ModifyLunaClient
s@ModifyLunaClient' {} Text
a -> ModifyLunaClient
s {$sel:clientArn:ModifyLunaClient' :: Text
clientArn = Text
a} :: ModifyLunaClient)

-- | The new certificate for the client.
modifyLunaClient_certificate :: Lens.Lens' ModifyLunaClient Prelude.Text
modifyLunaClient_certificate :: Lens' ModifyLunaClient Text
modifyLunaClient_certificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyLunaClient' {Text
certificate :: Text
$sel:certificate:ModifyLunaClient' :: ModifyLunaClient -> Text
certificate} -> Text
certificate) (\s :: ModifyLunaClient
s@ModifyLunaClient' {} Text
a -> ModifyLunaClient
s {$sel:certificate:ModifyLunaClient' :: Text
certificate = Text
a} :: ModifyLunaClient)

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

instance Prelude.NFData ModifyLunaClient where
  rnf :: ModifyLunaClient -> ()
rnf ModifyLunaClient' {Text
certificate :: Text
clientArn :: Text
$sel:certificate:ModifyLunaClient' :: ModifyLunaClient -> Text
$sel:clientArn:ModifyLunaClient' :: ModifyLunaClient -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clientArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
certificate

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

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

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

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

-- |
-- Create a value of 'ModifyLunaClientResponse' 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:
--
-- 'clientArn', 'modifyLunaClientResponse_clientArn' - The ARN of the client.
--
-- 'httpStatus', 'modifyLunaClientResponse_httpStatus' - The response's http status code.
newModifyLunaClientResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ModifyLunaClientResponse
newModifyLunaClientResponse :: Int -> ModifyLunaClientResponse
newModifyLunaClientResponse Int
pHttpStatus_ =
  ModifyLunaClientResponse'
    { $sel:clientArn:ModifyLunaClientResponse' :: Maybe Text
clientArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ModifyLunaClientResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the client.
modifyLunaClientResponse_clientArn :: Lens.Lens' ModifyLunaClientResponse (Prelude.Maybe Prelude.Text)
modifyLunaClientResponse_clientArn :: Lens' ModifyLunaClientResponse (Maybe Text)
modifyLunaClientResponse_clientArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyLunaClientResponse' {Maybe Text
clientArn :: Maybe Text
$sel:clientArn:ModifyLunaClientResponse' :: ModifyLunaClientResponse -> Maybe Text
clientArn} -> Maybe Text
clientArn) (\s :: ModifyLunaClientResponse
s@ModifyLunaClientResponse' {} Maybe Text
a -> ModifyLunaClientResponse
s {$sel:clientArn:ModifyLunaClientResponse' :: Maybe Text
clientArn = Maybe Text
a} :: ModifyLunaClientResponse)

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

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