{-# 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.Backup.PutBackupVaultNotifications
-- 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)
--
-- Turns on notifications on a backup vault for the specified topic and
-- events.
module Amazonka.Backup.PutBackupVaultNotifications
  ( -- * Creating a Request
    PutBackupVaultNotifications (..),
    newPutBackupVaultNotifications,

    -- * Request Lenses
    putBackupVaultNotifications_backupVaultName,
    putBackupVaultNotifications_sNSTopicArn,
    putBackupVaultNotifications_backupVaultEvents,

    -- * Destructuring the Response
    PutBackupVaultNotificationsResponse (..),
    newPutBackupVaultNotificationsResponse,
  )
where

import Amazonka.Backup.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:/ 'newPutBackupVaultNotifications' smart constructor.
data PutBackupVaultNotifications = PutBackupVaultNotifications'
  { -- | The name of a logical container where backups are stored. Backup vaults
    -- are identified by names that are unique to the account used to create
    -- them and the Amazon Web Services Region where they are created. They
    -- consist of lowercase letters, numbers, and hyphens.
    PutBackupVaultNotifications -> Text
backupVaultName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) that specifies the topic for a backup
    -- vault’s events; for example,
    -- @arn:aws:sns:us-west-2:111122223333:MyVaultTopic@.
    PutBackupVaultNotifications -> Text
sNSTopicArn :: Prelude.Text,
    -- | An array of events that indicate the status of jobs to back up resources
    -- to the backup vault.
    --
    -- The following events are supported:
    --
    -- @BACKUP_JOB_STARTED@, @BACKUP_JOB_COMPLETED@,
    --
    -- @COPY_JOB_STARTED@, @COPY_JOB_SUCCESSFUL@, @COPY_JOB_FAILED@,
    --
    -- @RESTORE_JOB_STARTED@, @RESTORE_JOB_COMPLETED@, and
    -- @RECOVERY_POINT_MODIFIED@.
    --
    -- To find failed backup jobs, use @BACKUP_JOB_COMPLETED@ and filter using
    -- event metadata.
    --
    -- Other events in the following list are deprecated.
    PutBackupVaultNotifications -> [BackupVaultEvent]
backupVaultEvents :: [BackupVaultEvent]
  }
  deriving (PutBackupVaultNotifications -> PutBackupVaultNotifications -> Bool
(PutBackupVaultNotifications
 -> PutBackupVaultNotifications -> Bool)
-> (PutBackupVaultNotifications
    -> PutBackupVaultNotifications -> Bool)
-> Eq PutBackupVaultNotifications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutBackupVaultNotifications -> PutBackupVaultNotifications -> Bool
$c/= :: PutBackupVaultNotifications -> PutBackupVaultNotifications -> Bool
== :: PutBackupVaultNotifications -> PutBackupVaultNotifications -> Bool
$c== :: PutBackupVaultNotifications -> PutBackupVaultNotifications -> Bool
Prelude.Eq, ReadPrec [PutBackupVaultNotifications]
ReadPrec PutBackupVaultNotifications
Int -> ReadS PutBackupVaultNotifications
ReadS [PutBackupVaultNotifications]
(Int -> ReadS PutBackupVaultNotifications)
-> ReadS [PutBackupVaultNotifications]
-> ReadPrec PutBackupVaultNotifications
-> ReadPrec [PutBackupVaultNotifications]
-> Read PutBackupVaultNotifications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutBackupVaultNotifications]
$creadListPrec :: ReadPrec [PutBackupVaultNotifications]
readPrec :: ReadPrec PutBackupVaultNotifications
$creadPrec :: ReadPrec PutBackupVaultNotifications
readList :: ReadS [PutBackupVaultNotifications]
$creadList :: ReadS [PutBackupVaultNotifications]
readsPrec :: Int -> ReadS PutBackupVaultNotifications
$creadsPrec :: Int -> ReadS PutBackupVaultNotifications
Prelude.Read, Int -> PutBackupVaultNotifications -> ShowS
[PutBackupVaultNotifications] -> ShowS
PutBackupVaultNotifications -> String
(Int -> PutBackupVaultNotifications -> ShowS)
-> (PutBackupVaultNotifications -> String)
-> ([PutBackupVaultNotifications] -> ShowS)
-> Show PutBackupVaultNotifications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBackupVaultNotifications] -> ShowS
$cshowList :: [PutBackupVaultNotifications] -> ShowS
show :: PutBackupVaultNotifications -> String
$cshow :: PutBackupVaultNotifications -> String
showsPrec :: Int -> PutBackupVaultNotifications -> ShowS
$cshowsPrec :: Int -> PutBackupVaultNotifications -> ShowS
Prelude.Show, (forall x.
 PutBackupVaultNotifications -> Rep PutBackupVaultNotifications x)
-> (forall x.
    Rep PutBackupVaultNotifications x -> PutBackupVaultNotifications)
-> Generic PutBackupVaultNotifications
forall x.
Rep PutBackupVaultNotifications x -> PutBackupVaultNotifications
forall x.
PutBackupVaultNotifications -> Rep PutBackupVaultNotifications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutBackupVaultNotifications x -> PutBackupVaultNotifications
$cfrom :: forall x.
PutBackupVaultNotifications -> Rep PutBackupVaultNotifications x
Prelude.Generic)

-- |
-- Create a value of 'PutBackupVaultNotifications' 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:
--
-- 'backupVaultName', 'putBackupVaultNotifications_backupVaultName' - The name of a logical container where backups are stored. Backup vaults
-- are identified by names that are unique to the account used to create
-- them and the Amazon Web Services Region where they are created. They
-- consist of lowercase letters, numbers, and hyphens.
--
-- 'sNSTopicArn', 'putBackupVaultNotifications_sNSTopicArn' - The Amazon Resource Name (ARN) that specifies the topic for a backup
-- vault’s events; for example,
-- @arn:aws:sns:us-west-2:111122223333:MyVaultTopic@.
--
-- 'backupVaultEvents', 'putBackupVaultNotifications_backupVaultEvents' - An array of events that indicate the status of jobs to back up resources
-- to the backup vault.
--
-- The following events are supported:
--
-- @BACKUP_JOB_STARTED@, @BACKUP_JOB_COMPLETED@,
--
-- @COPY_JOB_STARTED@, @COPY_JOB_SUCCESSFUL@, @COPY_JOB_FAILED@,
--
-- @RESTORE_JOB_STARTED@, @RESTORE_JOB_COMPLETED@, and
-- @RECOVERY_POINT_MODIFIED@.
--
-- To find failed backup jobs, use @BACKUP_JOB_COMPLETED@ and filter using
-- event metadata.
--
-- Other events in the following list are deprecated.
newPutBackupVaultNotifications ::
  -- | 'backupVaultName'
  Prelude.Text ->
  -- | 'sNSTopicArn'
  Prelude.Text ->
  PutBackupVaultNotifications
newPutBackupVaultNotifications :: Text -> Text -> PutBackupVaultNotifications
newPutBackupVaultNotifications
  Text
pBackupVaultName_
  Text
pSNSTopicArn_ =
    PutBackupVaultNotifications' :: Text -> Text -> [BackupVaultEvent] -> PutBackupVaultNotifications
PutBackupVaultNotifications'
      { $sel:backupVaultName:PutBackupVaultNotifications' :: Text
backupVaultName =
          Text
pBackupVaultName_,
        $sel:sNSTopicArn:PutBackupVaultNotifications' :: Text
sNSTopicArn = Text
pSNSTopicArn_,
        $sel:backupVaultEvents:PutBackupVaultNotifications' :: [BackupVaultEvent]
backupVaultEvents = [BackupVaultEvent]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The name of a logical container where backups are stored. Backup vaults
-- are identified by names that are unique to the account used to create
-- them and the Amazon Web Services Region where they are created. They
-- consist of lowercase letters, numbers, and hyphens.
putBackupVaultNotifications_backupVaultName :: Lens.Lens' PutBackupVaultNotifications Prelude.Text
putBackupVaultNotifications_backupVaultName :: (Text -> f Text)
-> PutBackupVaultNotifications -> f PutBackupVaultNotifications
putBackupVaultNotifications_backupVaultName = (PutBackupVaultNotifications -> Text)
-> (PutBackupVaultNotifications
    -> Text -> PutBackupVaultNotifications)
-> Lens
     PutBackupVaultNotifications PutBackupVaultNotifications Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBackupVaultNotifications' {Text
backupVaultName :: Text
$sel:backupVaultName:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> Text
backupVaultName} -> Text
backupVaultName) (\s :: PutBackupVaultNotifications
s@PutBackupVaultNotifications' {} Text
a -> PutBackupVaultNotifications
s {$sel:backupVaultName:PutBackupVaultNotifications' :: Text
backupVaultName = Text
a} :: PutBackupVaultNotifications)

-- | The Amazon Resource Name (ARN) that specifies the topic for a backup
-- vault’s events; for example,
-- @arn:aws:sns:us-west-2:111122223333:MyVaultTopic@.
putBackupVaultNotifications_sNSTopicArn :: Lens.Lens' PutBackupVaultNotifications Prelude.Text
putBackupVaultNotifications_sNSTopicArn :: (Text -> f Text)
-> PutBackupVaultNotifications -> f PutBackupVaultNotifications
putBackupVaultNotifications_sNSTopicArn = (PutBackupVaultNotifications -> Text)
-> (PutBackupVaultNotifications
    -> Text -> PutBackupVaultNotifications)
-> Lens
     PutBackupVaultNotifications PutBackupVaultNotifications Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBackupVaultNotifications' {Text
sNSTopicArn :: Text
$sel:sNSTopicArn:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> Text
sNSTopicArn} -> Text
sNSTopicArn) (\s :: PutBackupVaultNotifications
s@PutBackupVaultNotifications' {} Text
a -> PutBackupVaultNotifications
s {$sel:sNSTopicArn:PutBackupVaultNotifications' :: Text
sNSTopicArn = Text
a} :: PutBackupVaultNotifications)

-- | An array of events that indicate the status of jobs to back up resources
-- to the backup vault.
--
-- The following events are supported:
--
-- @BACKUP_JOB_STARTED@, @BACKUP_JOB_COMPLETED@,
--
-- @COPY_JOB_STARTED@, @COPY_JOB_SUCCESSFUL@, @COPY_JOB_FAILED@,
--
-- @RESTORE_JOB_STARTED@, @RESTORE_JOB_COMPLETED@, and
-- @RECOVERY_POINT_MODIFIED@.
--
-- To find failed backup jobs, use @BACKUP_JOB_COMPLETED@ and filter using
-- event metadata.
--
-- Other events in the following list are deprecated.
putBackupVaultNotifications_backupVaultEvents :: Lens.Lens' PutBackupVaultNotifications [BackupVaultEvent]
putBackupVaultNotifications_backupVaultEvents :: ([BackupVaultEvent] -> f [BackupVaultEvent])
-> PutBackupVaultNotifications -> f PutBackupVaultNotifications
putBackupVaultNotifications_backupVaultEvents = (PutBackupVaultNotifications -> [BackupVaultEvent])
-> (PutBackupVaultNotifications
    -> [BackupVaultEvent] -> PutBackupVaultNotifications)
-> Lens
     PutBackupVaultNotifications
     PutBackupVaultNotifications
     [BackupVaultEvent]
     [BackupVaultEvent]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutBackupVaultNotifications' {[BackupVaultEvent]
backupVaultEvents :: [BackupVaultEvent]
$sel:backupVaultEvents:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> [BackupVaultEvent]
backupVaultEvents} -> [BackupVaultEvent]
backupVaultEvents) (\s :: PutBackupVaultNotifications
s@PutBackupVaultNotifications' {} [BackupVaultEvent]
a -> PutBackupVaultNotifications
s {$sel:backupVaultEvents:PutBackupVaultNotifications' :: [BackupVaultEvent]
backupVaultEvents = [BackupVaultEvent]
a} :: PutBackupVaultNotifications) (([BackupVaultEvent] -> f [BackupVaultEvent])
 -> PutBackupVaultNotifications -> f PutBackupVaultNotifications)
-> (([BackupVaultEvent] -> f [BackupVaultEvent])
    -> [BackupVaultEvent] -> f [BackupVaultEvent])
-> ([BackupVaultEvent] -> f [BackupVaultEvent])
-> PutBackupVaultNotifications
-> f PutBackupVaultNotifications
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BackupVaultEvent] -> f [BackupVaultEvent])
-> [BackupVaultEvent] -> f [BackupVaultEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest PutBackupVaultNotifications where
  type
    AWSResponse PutBackupVaultNotifications =
      PutBackupVaultNotificationsResponse
  request :: PutBackupVaultNotifications -> Request PutBackupVaultNotifications
request = Service
-> PutBackupVaultNotifications
-> Request PutBackupVaultNotifications
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutBackupVaultNotifications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutBackupVaultNotifications)))
response =
    AWSResponse PutBackupVaultNotifications
-> Logger
-> Service
-> Proxy PutBackupVaultNotifications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutBackupVaultNotifications)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse PutBackupVaultNotifications
PutBackupVaultNotificationsResponse
PutBackupVaultNotificationsResponse'

instance Prelude.Hashable PutBackupVaultNotifications

instance Prelude.NFData PutBackupVaultNotifications

instance Core.ToHeaders PutBackupVaultNotifications where
  toHeaders :: PutBackupVaultNotifications -> [Header]
toHeaders =
    [Header] -> PutBackupVaultNotifications -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutBackupVaultNotifications where
  toJSON :: PutBackupVaultNotifications -> Value
toJSON PutBackupVaultNotifications' {[BackupVaultEvent]
Text
backupVaultEvents :: [BackupVaultEvent]
sNSTopicArn :: Text
backupVaultName :: Text
$sel:backupVaultEvents:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> [BackupVaultEvent]
$sel:sNSTopicArn:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> Text
$sel:backupVaultName:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> 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
"SNSTopicArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sNSTopicArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BackupVaultEvents" Text -> [BackupVaultEvent] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [BackupVaultEvent]
backupVaultEvents)
          ]
      )

instance Core.ToPath PutBackupVaultNotifications where
  toPath :: PutBackupVaultNotifications -> ByteString
toPath PutBackupVaultNotifications' {[BackupVaultEvent]
Text
backupVaultEvents :: [BackupVaultEvent]
sNSTopicArn :: Text
backupVaultName :: Text
$sel:backupVaultEvents:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> [BackupVaultEvent]
$sel:sNSTopicArn:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> Text
$sel:backupVaultName:PutBackupVaultNotifications' :: PutBackupVaultNotifications -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/backup-vaults/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
backupVaultName,
        ByteString
"/notification-configuration"
      ]

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

-- | /See:/ 'newPutBackupVaultNotificationsResponse' smart constructor.
data PutBackupVaultNotificationsResponse = PutBackupVaultNotificationsResponse'
  {
  }
  deriving (PutBackupVaultNotificationsResponse
-> PutBackupVaultNotificationsResponse -> Bool
(PutBackupVaultNotificationsResponse
 -> PutBackupVaultNotificationsResponse -> Bool)
-> (PutBackupVaultNotificationsResponse
    -> PutBackupVaultNotificationsResponse -> Bool)
-> Eq PutBackupVaultNotificationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutBackupVaultNotificationsResponse
-> PutBackupVaultNotificationsResponse -> Bool
$c/= :: PutBackupVaultNotificationsResponse
-> PutBackupVaultNotificationsResponse -> Bool
== :: PutBackupVaultNotificationsResponse
-> PutBackupVaultNotificationsResponse -> Bool
$c== :: PutBackupVaultNotificationsResponse
-> PutBackupVaultNotificationsResponse -> Bool
Prelude.Eq, ReadPrec [PutBackupVaultNotificationsResponse]
ReadPrec PutBackupVaultNotificationsResponse
Int -> ReadS PutBackupVaultNotificationsResponse
ReadS [PutBackupVaultNotificationsResponse]
(Int -> ReadS PutBackupVaultNotificationsResponse)
-> ReadS [PutBackupVaultNotificationsResponse]
-> ReadPrec PutBackupVaultNotificationsResponse
-> ReadPrec [PutBackupVaultNotificationsResponse]
-> Read PutBackupVaultNotificationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutBackupVaultNotificationsResponse]
$creadListPrec :: ReadPrec [PutBackupVaultNotificationsResponse]
readPrec :: ReadPrec PutBackupVaultNotificationsResponse
$creadPrec :: ReadPrec PutBackupVaultNotificationsResponse
readList :: ReadS [PutBackupVaultNotificationsResponse]
$creadList :: ReadS [PutBackupVaultNotificationsResponse]
readsPrec :: Int -> ReadS PutBackupVaultNotificationsResponse
$creadsPrec :: Int -> ReadS PutBackupVaultNotificationsResponse
Prelude.Read, Int -> PutBackupVaultNotificationsResponse -> ShowS
[PutBackupVaultNotificationsResponse] -> ShowS
PutBackupVaultNotificationsResponse -> String
(Int -> PutBackupVaultNotificationsResponse -> ShowS)
-> (PutBackupVaultNotificationsResponse -> String)
-> ([PutBackupVaultNotificationsResponse] -> ShowS)
-> Show PutBackupVaultNotificationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBackupVaultNotificationsResponse] -> ShowS
$cshowList :: [PutBackupVaultNotificationsResponse] -> ShowS
show :: PutBackupVaultNotificationsResponse -> String
$cshow :: PutBackupVaultNotificationsResponse -> String
showsPrec :: Int -> PutBackupVaultNotificationsResponse -> ShowS
$cshowsPrec :: Int -> PutBackupVaultNotificationsResponse -> ShowS
Prelude.Show, (forall x.
 PutBackupVaultNotificationsResponse
 -> Rep PutBackupVaultNotificationsResponse x)
-> (forall x.
    Rep PutBackupVaultNotificationsResponse x
    -> PutBackupVaultNotificationsResponse)
-> Generic PutBackupVaultNotificationsResponse
forall x.
Rep PutBackupVaultNotificationsResponse x
-> PutBackupVaultNotificationsResponse
forall x.
PutBackupVaultNotificationsResponse
-> Rep PutBackupVaultNotificationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutBackupVaultNotificationsResponse x
-> PutBackupVaultNotificationsResponse
$cfrom :: forall x.
PutBackupVaultNotificationsResponse
-> Rep PutBackupVaultNotificationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutBackupVaultNotificationsResponse' 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.
newPutBackupVaultNotificationsResponse ::
  PutBackupVaultNotificationsResponse
newPutBackupVaultNotificationsResponse :: PutBackupVaultNotificationsResponse
newPutBackupVaultNotificationsResponse =
  PutBackupVaultNotificationsResponse
PutBackupVaultNotificationsResponse'

instance
  Prelude.NFData
    PutBackupVaultNotificationsResponse