{-# 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.CloudHSMV2.ModifyCluster
-- 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)
--
-- Modifies AWS CloudHSM cluster.
module Amazonka.CloudHSMV2.ModifyCluster
  ( -- * Creating a Request
    ModifyCluster (..),
    newModifyCluster,

    -- * Request Lenses
    modifyCluster_backupRetentionPolicy,
    modifyCluster_clusterId,

    -- * Destructuring the Response
    ModifyClusterResponse (..),
    newModifyClusterResponse,

    -- * Response Lenses
    modifyClusterResponse_cluster,
    modifyClusterResponse_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

-- | /See:/ 'newModifyCluster' smart constructor.
data ModifyCluster = ModifyCluster'
  { -- | A policy that defines how the service retains backups.
    ModifyCluster -> BackupRetentionPolicy
backupRetentionPolicy :: BackupRetentionPolicy,
    -- | The identifier (ID) of the cluster that you want to modify. To find the
    -- cluster ID, use DescribeClusters.
    ModifyCluster -> Text
clusterId :: Prelude.Text
  }
  deriving (ModifyCluster -> ModifyCluster -> Bool
(ModifyCluster -> ModifyCluster -> Bool)
-> (ModifyCluster -> ModifyCluster -> Bool) -> Eq ModifyCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyCluster -> ModifyCluster -> Bool
$c/= :: ModifyCluster -> ModifyCluster -> Bool
== :: ModifyCluster -> ModifyCluster -> Bool
$c== :: ModifyCluster -> ModifyCluster -> Bool
Prelude.Eq, ReadPrec [ModifyCluster]
ReadPrec ModifyCluster
Int -> ReadS ModifyCluster
ReadS [ModifyCluster]
(Int -> ReadS ModifyCluster)
-> ReadS [ModifyCluster]
-> ReadPrec ModifyCluster
-> ReadPrec [ModifyCluster]
-> Read ModifyCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyCluster]
$creadListPrec :: ReadPrec [ModifyCluster]
readPrec :: ReadPrec ModifyCluster
$creadPrec :: ReadPrec ModifyCluster
readList :: ReadS [ModifyCluster]
$creadList :: ReadS [ModifyCluster]
readsPrec :: Int -> ReadS ModifyCluster
$creadsPrec :: Int -> ReadS ModifyCluster
Prelude.Read, Int -> ModifyCluster -> ShowS
[ModifyCluster] -> ShowS
ModifyCluster -> String
(Int -> ModifyCluster -> ShowS)
-> (ModifyCluster -> String)
-> ([ModifyCluster] -> ShowS)
-> Show ModifyCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyCluster] -> ShowS
$cshowList :: [ModifyCluster] -> ShowS
show :: ModifyCluster -> String
$cshow :: ModifyCluster -> String
showsPrec :: Int -> ModifyCluster -> ShowS
$cshowsPrec :: Int -> ModifyCluster -> ShowS
Prelude.Show, (forall x. ModifyCluster -> Rep ModifyCluster x)
-> (forall x. Rep ModifyCluster x -> ModifyCluster)
-> Generic ModifyCluster
forall x. Rep ModifyCluster x -> ModifyCluster
forall x. ModifyCluster -> Rep ModifyCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyCluster x -> ModifyCluster
$cfrom :: forall x. ModifyCluster -> Rep ModifyCluster x
Prelude.Generic)

-- |
-- Create a value of 'ModifyCluster' 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:
--
-- 'backupRetentionPolicy', 'modifyCluster_backupRetentionPolicy' - A policy that defines how the service retains backups.
--
-- 'clusterId', 'modifyCluster_clusterId' - The identifier (ID) of the cluster that you want to modify. To find the
-- cluster ID, use DescribeClusters.
newModifyCluster ::
  -- | 'backupRetentionPolicy'
  BackupRetentionPolicy ->
  -- | 'clusterId'
  Prelude.Text ->
  ModifyCluster
newModifyCluster :: BackupRetentionPolicy -> Text -> ModifyCluster
newModifyCluster BackupRetentionPolicy
pBackupRetentionPolicy_ Text
pClusterId_ =
  ModifyCluster' :: BackupRetentionPolicy -> Text -> ModifyCluster
ModifyCluster'
    { $sel:backupRetentionPolicy:ModifyCluster' :: BackupRetentionPolicy
backupRetentionPolicy =
        BackupRetentionPolicy
pBackupRetentionPolicy_,
      $sel:clusterId:ModifyCluster' :: Text
clusterId = Text
pClusterId_
    }

-- | A policy that defines how the service retains backups.
modifyCluster_backupRetentionPolicy :: Lens.Lens' ModifyCluster BackupRetentionPolicy
modifyCluster_backupRetentionPolicy :: (BackupRetentionPolicy -> f BackupRetentionPolicy)
-> ModifyCluster -> f ModifyCluster
modifyCluster_backupRetentionPolicy = (ModifyCluster -> BackupRetentionPolicy)
-> (ModifyCluster -> BackupRetentionPolicy -> ModifyCluster)
-> Lens
     ModifyCluster
     ModifyCluster
     BackupRetentionPolicy
     BackupRetentionPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCluster' {BackupRetentionPolicy
backupRetentionPolicy :: BackupRetentionPolicy
$sel:backupRetentionPolicy:ModifyCluster' :: ModifyCluster -> BackupRetentionPolicy
backupRetentionPolicy} -> BackupRetentionPolicy
backupRetentionPolicy) (\s :: ModifyCluster
s@ModifyCluster' {} BackupRetentionPolicy
a -> ModifyCluster
s {$sel:backupRetentionPolicy:ModifyCluster' :: BackupRetentionPolicy
backupRetentionPolicy = BackupRetentionPolicy
a} :: ModifyCluster)

-- | The identifier (ID) of the cluster that you want to modify. To find the
-- cluster ID, use DescribeClusters.
modifyCluster_clusterId :: Lens.Lens' ModifyCluster Prelude.Text
modifyCluster_clusterId :: (Text -> f Text) -> ModifyCluster -> f ModifyCluster
modifyCluster_clusterId = (ModifyCluster -> Text)
-> (ModifyCluster -> Text -> ModifyCluster)
-> Lens ModifyCluster ModifyCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCluster' {Text
clusterId :: Text
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
clusterId} -> Text
clusterId) (\s :: ModifyCluster
s@ModifyCluster' {} Text
a -> ModifyCluster
s {$sel:clusterId:ModifyCluster' :: Text
clusterId = Text
a} :: ModifyCluster)

instance Core.AWSRequest ModifyCluster where
  type
    AWSResponse ModifyCluster =
      ModifyClusterResponse
  request :: ModifyCluster -> Request ModifyCluster
request = Service -> ModifyCluster -> Request ModifyCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ModifyCluster))
-> Logger
-> Service
-> Proxy ModifyCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyCluster)))
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 Cluster -> Int -> ModifyClusterResponse
ModifyClusterResponse'
            (Maybe Cluster -> Int -> ModifyClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> ModifyClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Cluster)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Cluster")
            Either String (Int -> ModifyClusterResponse)
-> Either String Int -> Either String ModifyClusterResponse
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 ModifyCluster

instance Prelude.NFData ModifyCluster

instance Core.ToHeaders ModifyCluster where
  toHeaders :: ModifyCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ModifyCluster -> 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.ModifyCluster" ::
                          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 ModifyCluster where
  toJSON :: ModifyCluster -> Value
toJSON ModifyCluster' {Text
BackupRetentionPolicy
clusterId :: Text
backupRetentionPolicy :: BackupRetentionPolicy
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
$sel:backupRetentionPolicy:ModifyCluster' :: ModifyCluster -> BackupRetentionPolicy
..} =
    [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
"BackupRetentionPolicy"
                  Text -> BackupRetentionPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= BackupRetentionPolicy
backupRetentionPolicy
              ),
            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)
          ]
      )

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

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

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

-- |
-- Create a value of 'ModifyClusterResponse' 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:
--
-- 'cluster', 'modifyClusterResponse_cluster' - Undocumented member.
--
-- 'httpStatus', 'modifyClusterResponse_httpStatus' - The response's http status code.
newModifyClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ModifyClusterResponse
newModifyClusterResponse :: Int -> ModifyClusterResponse
newModifyClusterResponse Int
pHttpStatus_ =
  ModifyClusterResponse' :: Maybe Cluster -> Int -> ModifyClusterResponse
ModifyClusterResponse'
    { $sel:cluster:ModifyClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ModifyClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
modifyClusterResponse_cluster :: Lens.Lens' ModifyClusterResponse (Prelude.Maybe Cluster)
modifyClusterResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> ModifyClusterResponse -> f ModifyClusterResponse
modifyClusterResponse_cluster = (ModifyClusterResponse -> Maybe Cluster)
-> (ModifyClusterResponse
    -> Maybe Cluster -> ModifyClusterResponse)
-> Lens
     ModifyClusterResponse
     ModifyClusterResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:ModifyClusterResponse' :: ModifyClusterResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: ModifyClusterResponse
s@ModifyClusterResponse' {} Maybe Cluster
a -> ModifyClusterResponse
s {$sel:cluster:ModifyClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: ModifyClusterResponse)

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

instance Prelude.NFData ModifyClusterResponse