{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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
(ModifyLunaClient -> ModifyLunaClient -> Bool)
-> (ModifyLunaClient -> ModifyLunaClient -> Bool)
-> Eq ModifyLunaClient
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]
(Int -> ReadS ModifyLunaClient)
-> ReadS [ModifyLunaClient]
-> ReadPrec ModifyLunaClient
-> ReadPrec [ModifyLunaClient]
-> Read 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
(Int -> ModifyLunaClient -> ShowS)
-> (ModifyLunaClient -> String)
-> ([ModifyLunaClient] -> ShowS)
-> Show ModifyLunaClient
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. ModifyLunaClient -> Rep ModifyLunaClient x)
-> (forall x. Rep ModifyLunaClient x -> ModifyLunaClient)
-> Generic ModifyLunaClient
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' :: Text -> Text -> ModifyLunaClient
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 :: (Text -> f Text) -> ModifyLunaClient -> f ModifyLunaClient
modifyLunaClient_clientArn = (ModifyLunaClient -> Text)
-> (ModifyLunaClient -> Text -> ModifyLunaClient)
-> Lens ModifyLunaClient ModifyLunaClient Text Text
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 :: (Text -> f Text) -> ModifyLunaClient -> f ModifyLunaClient
modifyLunaClient_certificate = (ModifyLunaClient -> Text)
-> (ModifyLunaClient -> Text -> ModifyLunaClient)
-> Lens ModifyLunaClient ModifyLunaClient Text Text
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 :: ModifyLunaClient -> Request ModifyLunaClient
request = Service -> ModifyLunaClient -> Request ModifyLunaClient
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyLunaClient
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyLunaClient)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ModifyLunaClient))
-> Logger
-> Service
-> Proxy ModifyLunaClient
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyLunaClient)))
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 -> Int -> ModifyLunaClientResponse
ModifyLunaClientResponse'
            (Maybe Text -> Int -> ModifyLunaClientResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ModifyLunaClientResponse)
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
"ClientArn")
            Either String (Int -> ModifyLunaClientResponse)
-> Either String Int -> Either String ModifyLunaClientResponse
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 ModifyLunaClient

instance Prelude.NFData ModifyLunaClient

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

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

instance Core.ToQuery ModifyLunaClient where
  toQuery :: ModifyLunaClient -> QueryString
toQuery = QueryString -> ModifyLunaClient -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ModifyLunaClientResponse -> ModifyLunaClientResponse -> Bool)
-> (ModifyLunaClientResponse -> ModifyLunaClientResponse -> Bool)
-> Eq ModifyLunaClientResponse
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]
(Int -> ReadS ModifyLunaClientResponse)
-> ReadS [ModifyLunaClientResponse]
-> ReadPrec ModifyLunaClientResponse
-> ReadPrec [ModifyLunaClientResponse]
-> Read 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
(Int -> ModifyLunaClientResponse -> ShowS)
-> (ModifyLunaClientResponse -> String)
-> ([ModifyLunaClientResponse] -> ShowS)
-> Show ModifyLunaClientResponse
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.
 ModifyLunaClientResponse -> Rep ModifyLunaClientResponse x)
-> (forall x.
    Rep ModifyLunaClientResponse x -> ModifyLunaClientResponse)
-> Generic ModifyLunaClientResponse
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' :: Maybe Text -> Int -> ModifyLunaClientResponse
ModifyLunaClientResponse'
    { $sel:clientArn:ModifyLunaClientResponse' :: Maybe Text
clientArn =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ModifyLunaClientResponse -> f ModifyLunaClientResponse
modifyLunaClientResponse_clientArn = (ModifyLunaClientResponse -> Maybe Text)
-> (ModifyLunaClientResponse
    -> Maybe Text -> ModifyLunaClientResponse)
-> Lens
     ModifyLunaClientResponse
     ModifyLunaClientResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> ModifyLunaClientResponse -> f ModifyLunaClientResponse
modifyLunaClientResponse_httpStatus = (ModifyLunaClientResponse -> Int)
-> (ModifyLunaClientResponse -> Int -> ModifyLunaClientResponse)
-> Lens ModifyLunaClientResponse ModifyLunaClientResponse Int Int
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