{-# 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.ModifyBackupAttributes
-- 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 attributes for AWS CloudHSM backup.
module Amazonka.CloudHSMV2.ModifyBackupAttributes
  ( -- * Creating a Request
    ModifyBackupAttributes (..),
    newModifyBackupAttributes,

    -- * Request Lenses
    modifyBackupAttributes_backupId,
    modifyBackupAttributes_neverExpires,

    -- * Destructuring the Response
    ModifyBackupAttributesResponse (..),
    newModifyBackupAttributesResponse,

    -- * Response Lenses
    modifyBackupAttributesResponse_backup,
    modifyBackupAttributesResponse_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:/ 'newModifyBackupAttributes' smart constructor.
data ModifyBackupAttributes = ModifyBackupAttributes'
  { -- | The identifier (ID) of the backup to modify. To find the ID of a backup,
    -- use the DescribeBackups operation.
    ModifyBackupAttributes -> Text
backupId :: Prelude.Text,
    -- | Specifies whether the service should exempt a backup from the retention
    -- policy for the cluster. @True@ exempts a backup from the retention
    -- policy. @False@ means the service applies the backup retention policy
    -- defined at the cluster.
    ModifyBackupAttributes -> Bool
neverExpires :: Prelude.Bool
  }
  deriving (ModifyBackupAttributes -> ModifyBackupAttributes -> Bool
(ModifyBackupAttributes -> ModifyBackupAttributes -> Bool)
-> (ModifyBackupAttributes -> ModifyBackupAttributes -> Bool)
-> Eq ModifyBackupAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyBackupAttributes -> ModifyBackupAttributes -> Bool
$c/= :: ModifyBackupAttributes -> ModifyBackupAttributes -> Bool
== :: ModifyBackupAttributes -> ModifyBackupAttributes -> Bool
$c== :: ModifyBackupAttributes -> ModifyBackupAttributes -> Bool
Prelude.Eq, ReadPrec [ModifyBackupAttributes]
ReadPrec ModifyBackupAttributes
Int -> ReadS ModifyBackupAttributes
ReadS [ModifyBackupAttributes]
(Int -> ReadS ModifyBackupAttributes)
-> ReadS [ModifyBackupAttributes]
-> ReadPrec ModifyBackupAttributes
-> ReadPrec [ModifyBackupAttributes]
-> Read ModifyBackupAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyBackupAttributes]
$creadListPrec :: ReadPrec [ModifyBackupAttributes]
readPrec :: ReadPrec ModifyBackupAttributes
$creadPrec :: ReadPrec ModifyBackupAttributes
readList :: ReadS [ModifyBackupAttributes]
$creadList :: ReadS [ModifyBackupAttributes]
readsPrec :: Int -> ReadS ModifyBackupAttributes
$creadsPrec :: Int -> ReadS ModifyBackupAttributes
Prelude.Read, Int -> ModifyBackupAttributes -> ShowS
[ModifyBackupAttributes] -> ShowS
ModifyBackupAttributes -> String
(Int -> ModifyBackupAttributes -> ShowS)
-> (ModifyBackupAttributes -> String)
-> ([ModifyBackupAttributes] -> ShowS)
-> Show ModifyBackupAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyBackupAttributes] -> ShowS
$cshowList :: [ModifyBackupAttributes] -> ShowS
show :: ModifyBackupAttributes -> String
$cshow :: ModifyBackupAttributes -> String
showsPrec :: Int -> ModifyBackupAttributes -> ShowS
$cshowsPrec :: Int -> ModifyBackupAttributes -> ShowS
Prelude.Show, (forall x. ModifyBackupAttributes -> Rep ModifyBackupAttributes x)
-> (forall x.
    Rep ModifyBackupAttributes x -> ModifyBackupAttributes)
-> Generic ModifyBackupAttributes
forall x. Rep ModifyBackupAttributes x -> ModifyBackupAttributes
forall x. ModifyBackupAttributes -> Rep ModifyBackupAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyBackupAttributes x -> ModifyBackupAttributes
$cfrom :: forall x. ModifyBackupAttributes -> Rep ModifyBackupAttributes x
Prelude.Generic)

-- |
-- Create a value of 'ModifyBackupAttributes' 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:
--
-- 'backupId', 'modifyBackupAttributes_backupId' - The identifier (ID) of the backup to modify. To find the ID of a backup,
-- use the DescribeBackups operation.
--
-- 'neverExpires', 'modifyBackupAttributes_neverExpires' - Specifies whether the service should exempt a backup from the retention
-- policy for the cluster. @True@ exempts a backup from the retention
-- policy. @False@ means the service applies the backup retention policy
-- defined at the cluster.
newModifyBackupAttributes ::
  -- | 'backupId'
  Prelude.Text ->
  -- | 'neverExpires'
  Prelude.Bool ->
  ModifyBackupAttributes
newModifyBackupAttributes :: Text -> Bool -> ModifyBackupAttributes
newModifyBackupAttributes Text
pBackupId_ Bool
pNeverExpires_ =
  ModifyBackupAttributes' :: Text -> Bool -> ModifyBackupAttributes
ModifyBackupAttributes'
    { $sel:backupId:ModifyBackupAttributes' :: Text
backupId = Text
pBackupId_,
      $sel:neverExpires:ModifyBackupAttributes' :: Bool
neverExpires = Bool
pNeverExpires_
    }

-- | The identifier (ID) of the backup to modify. To find the ID of a backup,
-- use the DescribeBackups operation.
modifyBackupAttributes_backupId :: Lens.Lens' ModifyBackupAttributes Prelude.Text
modifyBackupAttributes_backupId :: (Text -> f Text)
-> ModifyBackupAttributes -> f ModifyBackupAttributes
modifyBackupAttributes_backupId = (ModifyBackupAttributes -> Text)
-> (ModifyBackupAttributes -> Text -> ModifyBackupAttributes)
-> Lens ModifyBackupAttributes ModifyBackupAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyBackupAttributes' {Text
backupId :: Text
$sel:backupId:ModifyBackupAttributes' :: ModifyBackupAttributes -> Text
backupId} -> Text
backupId) (\s :: ModifyBackupAttributes
s@ModifyBackupAttributes' {} Text
a -> ModifyBackupAttributes
s {$sel:backupId:ModifyBackupAttributes' :: Text
backupId = Text
a} :: ModifyBackupAttributes)

-- | Specifies whether the service should exempt a backup from the retention
-- policy for the cluster. @True@ exempts a backup from the retention
-- policy. @False@ means the service applies the backup retention policy
-- defined at the cluster.
modifyBackupAttributes_neverExpires :: Lens.Lens' ModifyBackupAttributes Prelude.Bool
modifyBackupAttributes_neverExpires :: (Bool -> f Bool)
-> ModifyBackupAttributes -> f ModifyBackupAttributes
modifyBackupAttributes_neverExpires = (ModifyBackupAttributes -> Bool)
-> (ModifyBackupAttributes -> Bool -> ModifyBackupAttributes)
-> Lens ModifyBackupAttributes ModifyBackupAttributes Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyBackupAttributes' {Bool
neverExpires :: Bool
$sel:neverExpires:ModifyBackupAttributes' :: ModifyBackupAttributes -> Bool
neverExpires} -> Bool
neverExpires) (\s :: ModifyBackupAttributes
s@ModifyBackupAttributes' {} Bool
a -> ModifyBackupAttributes
s {$sel:neverExpires:ModifyBackupAttributes' :: Bool
neverExpires = Bool
a} :: ModifyBackupAttributes)

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

instance Prelude.NFData ModifyBackupAttributes

instance Core.ToHeaders ModifyBackupAttributes where
  toHeaders :: ModifyBackupAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ModifyBackupAttributes -> 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.ModifyBackupAttributes" ::
                          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 ModifyBackupAttributes where
  toJSON :: ModifyBackupAttributes -> Value
toJSON ModifyBackupAttributes' {Bool
Text
neverExpires :: Bool
backupId :: Text
$sel:neverExpires:ModifyBackupAttributes' :: ModifyBackupAttributes -> Bool
$sel:backupId:ModifyBackupAttributes' :: ModifyBackupAttributes -> 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
"BackupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
backupId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"NeverExpires" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
neverExpires)
          ]
      )

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

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

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

-- |
-- Create a value of 'ModifyBackupAttributesResponse' 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:
--
-- 'backup', 'modifyBackupAttributesResponse_backup' - Undocumented member.
--
-- 'httpStatus', 'modifyBackupAttributesResponse_httpStatus' - The response's http status code.
newModifyBackupAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ModifyBackupAttributesResponse
newModifyBackupAttributesResponse :: Int -> ModifyBackupAttributesResponse
newModifyBackupAttributesResponse Int
pHttpStatus_ =
  ModifyBackupAttributesResponse' :: Maybe Backup -> Int -> ModifyBackupAttributesResponse
ModifyBackupAttributesResponse'
    { $sel:backup:ModifyBackupAttributesResponse' :: Maybe Backup
backup =
        Maybe Backup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ModifyBackupAttributesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
modifyBackupAttributesResponse_backup :: Lens.Lens' ModifyBackupAttributesResponse (Prelude.Maybe Backup)
modifyBackupAttributesResponse_backup :: (Maybe Backup -> f (Maybe Backup))
-> ModifyBackupAttributesResponse
-> f ModifyBackupAttributesResponse
modifyBackupAttributesResponse_backup = (ModifyBackupAttributesResponse -> Maybe Backup)
-> (ModifyBackupAttributesResponse
    -> Maybe Backup -> ModifyBackupAttributesResponse)
-> Lens
     ModifyBackupAttributesResponse
     ModifyBackupAttributesResponse
     (Maybe Backup)
     (Maybe Backup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyBackupAttributesResponse' {Maybe Backup
backup :: Maybe Backup
$sel:backup:ModifyBackupAttributesResponse' :: ModifyBackupAttributesResponse -> Maybe Backup
backup} -> Maybe Backup
backup) (\s :: ModifyBackupAttributesResponse
s@ModifyBackupAttributesResponse' {} Maybe Backup
a -> ModifyBackupAttributesResponse
s {$sel:backup:ModifyBackupAttributesResponse' :: Maybe Backup
backup = Maybe Backup
a} :: ModifyBackupAttributesResponse)

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

instance
  Prelude.NFData
    ModifyBackupAttributesResponse