{-# 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.DMS.UpdateSubscriptionsToEventBridge
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Migrates 10 active and enabled Amazon SNS subscriptions at a time and
-- converts them to corresponding Amazon EventBridge rules. By default,
-- this operation migrates subscriptions only when all your replication
-- instance versions are 3.4.6 or higher. If any replication instances are
-- from versions earlier than 3.4.6, the operation raises an error and
-- tells you to upgrade these instances to version 3.4.6 or higher. To
-- enable migration regardless of version, set the @Force@ option to true.
-- However, if you don\'t upgrade instances earlier than version 3.4.6,
-- some types of events might not be available when you use Amazon
-- EventBridge.
--
-- To call this operation, make sure that you have certain permissions
-- added to your user account. For more information, see
-- <https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Events.html#CHAP_Events-migrate-to-eventbridge Migrating event subscriptions to Amazon EventBridge>
-- in the /Amazon Web Services Database Migration Service User Guide/.
module Amazonka.DMS.UpdateSubscriptionsToEventBridge
  ( -- * Creating a Request
    UpdateSubscriptionsToEventBridge (..),
    newUpdateSubscriptionsToEventBridge,

    -- * Request Lenses
    updateSubscriptionsToEventBridge_forceMove,

    -- * Destructuring the Response
    UpdateSubscriptionsToEventBridgeResponse (..),
    newUpdateSubscriptionsToEventBridgeResponse,

    -- * Response Lenses
    updateSubscriptionsToEventBridgeResponse_result,
    updateSubscriptionsToEventBridgeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.DMS.Types
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:/ 'newUpdateSubscriptionsToEventBridge' smart constructor.
data UpdateSubscriptionsToEventBridge = UpdateSubscriptionsToEventBridge'
  { -- | When set to true, this operation migrates DMS subscriptions for Amazon
    -- SNS notifications no matter what your replication instance version is.
    -- If not set or set to false, this operation runs only when all your
    -- replication instances are from DMS version 3.4.6 or higher.
    UpdateSubscriptionsToEventBridge -> Maybe Bool
forceMove :: Prelude.Maybe Prelude.Bool
  }
  deriving (UpdateSubscriptionsToEventBridge
-> UpdateSubscriptionsToEventBridge -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSubscriptionsToEventBridge
-> UpdateSubscriptionsToEventBridge -> Bool
$c/= :: UpdateSubscriptionsToEventBridge
-> UpdateSubscriptionsToEventBridge -> Bool
== :: UpdateSubscriptionsToEventBridge
-> UpdateSubscriptionsToEventBridge -> Bool
$c== :: UpdateSubscriptionsToEventBridge
-> UpdateSubscriptionsToEventBridge -> Bool
Prelude.Eq, ReadPrec [UpdateSubscriptionsToEventBridge]
ReadPrec UpdateSubscriptionsToEventBridge
Int -> ReadS UpdateSubscriptionsToEventBridge
ReadS [UpdateSubscriptionsToEventBridge]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSubscriptionsToEventBridge]
$creadListPrec :: ReadPrec [UpdateSubscriptionsToEventBridge]
readPrec :: ReadPrec UpdateSubscriptionsToEventBridge
$creadPrec :: ReadPrec UpdateSubscriptionsToEventBridge
readList :: ReadS [UpdateSubscriptionsToEventBridge]
$creadList :: ReadS [UpdateSubscriptionsToEventBridge]
readsPrec :: Int -> ReadS UpdateSubscriptionsToEventBridge
$creadsPrec :: Int -> ReadS UpdateSubscriptionsToEventBridge
Prelude.Read, Int -> UpdateSubscriptionsToEventBridge -> ShowS
[UpdateSubscriptionsToEventBridge] -> ShowS
UpdateSubscriptionsToEventBridge -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSubscriptionsToEventBridge] -> ShowS
$cshowList :: [UpdateSubscriptionsToEventBridge] -> ShowS
show :: UpdateSubscriptionsToEventBridge -> String
$cshow :: UpdateSubscriptionsToEventBridge -> String
showsPrec :: Int -> UpdateSubscriptionsToEventBridge -> ShowS
$cshowsPrec :: Int -> UpdateSubscriptionsToEventBridge -> ShowS
Prelude.Show, forall x.
Rep UpdateSubscriptionsToEventBridge x
-> UpdateSubscriptionsToEventBridge
forall x.
UpdateSubscriptionsToEventBridge
-> Rep UpdateSubscriptionsToEventBridge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSubscriptionsToEventBridge x
-> UpdateSubscriptionsToEventBridge
$cfrom :: forall x.
UpdateSubscriptionsToEventBridge
-> Rep UpdateSubscriptionsToEventBridge x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSubscriptionsToEventBridge' 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:
--
-- 'forceMove', 'updateSubscriptionsToEventBridge_forceMove' - When set to true, this operation migrates DMS subscriptions for Amazon
-- SNS notifications no matter what your replication instance version is.
-- If not set or set to false, this operation runs only when all your
-- replication instances are from DMS version 3.4.6 or higher.
newUpdateSubscriptionsToEventBridge ::
  UpdateSubscriptionsToEventBridge
newUpdateSubscriptionsToEventBridge :: UpdateSubscriptionsToEventBridge
newUpdateSubscriptionsToEventBridge =
  UpdateSubscriptionsToEventBridge'
    { $sel:forceMove:UpdateSubscriptionsToEventBridge' :: Maybe Bool
forceMove =
        forall a. Maybe a
Prelude.Nothing
    }

-- | When set to true, this operation migrates DMS subscriptions for Amazon
-- SNS notifications no matter what your replication instance version is.
-- If not set or set to false, this operation runs only when all your
-- replication instances are from DMS version 3.4.6 or higher.
updateSubscriptionsToEventBridge_forceMove :: Lens.Lens' UpdateSubscriptionsToEventBridge (Prelude.Maybe Prelude.Bool)
updateSubscriptionsToEventBridge_forceMove :: Lens' UpdateSubscriptionsToEventBridge (Maybe Bool)
updateSubscriptionsToEventBridge_forceMove = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSubscriptionsToEventBridge' {Maybe Bool
forceMove :: Maybe Bool
$sel:forceMove:UpdateSubscriptionsToEventBridge' :: UpdateSubscriptionsToEventBridge -> Maybe Bool
forceMove} -> Maybe Bool
forceMove) (\s :: UpdateSubscriptionsToEventBridge
s@UpdateSubscriptionsToEventBridge' {} Maybe Bool
a -> UpdateSubscriptionsToEventBridge
s {$sel:forceMove:UpdateSubscriptionsToEventBridge' :: Maybe Bool
forceMove = Maybe Bool
a} :: UpdateSubscriptionsToEventBridge)

instance
  Core.AWSRequest
    UpdateSubscriptionsToEventBridge
  where
  type
    AWSResponse UpdateSubscriptionsToEventBridge =
      UpdateSubscriptionsToEventBridgeResponse
  request :: (Service -> Service)
-> UpdateSubscriptionsToEventBridge
-> Request UpdateSubscriptionsToEventBridge
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 UpdateSubscriptionsToEventBridge
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse UpdateSubscriptionsToEventBridge)))
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 -> UpdateSubscriptionsToEventBridgeResponse
UpdateSubscriptionsToEventBridgeResponse'
            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
"Result")
            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
    UpdateSubscriptionsToEventBridge
  where
  hashWithSalt :: Int -> UpdateSubscriptionsToEventBridge -> Int
hashWithSalt
    Int
_salt
    UpdateSubscriptionsToEventBridge' {Maybe Bool
forceMove :: Maybe Bool
$sel:forceMove:UpdateSubscriptionsToEventBridge' :: UpdateSubscriptionsToEventBridge -> Maybe Bool
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
forceMove

instance
  Prelude.NFData
    UpdateSubscriptionsToEventBridge
  where
  rnf :: UpdateSubscriptionsToEventBridge -> ()
rnf UpdateSubscriptionsToEventBridge' {Maybe Bool
forceMove :: Maybe Bool
$sel:forceMove:UpdateSubscriptionsToEventBridge' :: UpdateSubscriptionsToEventBridge -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
forceMove

instance
  Data.ToHeaders
    UpdateSubscriptionsToEventBridge
  where
  toHeaders :: UpdateSubscriptionsToEventBridge -> 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
"AmazonDMSv20160101.UpdateSubscriptionsToEventBridge" ::
                          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 UpdateSubscriptionsToEventBridge where
  toJSON :: UpdateSubscriptionsToEventBridge -> Value
toJSON UpdateSubscriptionsToEventBridge' {Maybe Bool
forceMove :: Maybe Bool
$sel:forceMove:UpdateSubscriptionsToEventBridge' :: UpdateSubscriptionsToEventBridge -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"ForceMove" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
forceMove]
      )

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

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

-- |
--
-- /See:/ 'newUpdateSubscriptionsToEventBridgeResponse' smart constructor.
data UpdateSubscriptionsToEventBridgeResponse = UpdateSubscriptionsToEventBridgeResponse'
  { -- | A string that indicates how many event subscriptions were migrated and
    -- how many remain to be migrated.
    UpdateSubscriptionsToEventBridgeResponse -> Maybe Text
result :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateSubscriptionsToEventBridgeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateSubscriptionsToEventBridgeResponse
-> UpdateSubscriptionsToEventBridgeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSubscriptionsToEventBridgeResponse
-> UpdateSubscriptionsToEventBridgeResponse -> Bool
$c/= :: UpdateSubscriptionsToEventBridgeResponse
-> UpdateSubscriptionsToEventBridgeResponse -> Bool
== :: UpdateSubscriptionsToEventBridgeResponse
-> UpdateSubscriptionsToEventBridgeResponse -> Bool
$c== :: UpdateSubscriptionsToEventBridgeResponse
-> UpdateSubscriptionsToEventBridgeResponse -> Bool
Prelude.Eq, ReadPrec [UpdateSubscriptionsToEventBridgeResponse]
ReadPrec UpdateSubscriptionsToEventBridgeResponse
Int -> ReadS UpdateSubscriptionsToEventBridgeResponse
ReadS [UpdateSubscriptionsToEventBridgeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSubscriptionsToEventBridgeResponse]
$creadListPrec :: ReadPrec [UpdateSubscriptionsToEventBridgeResponse]
readPrec :: ReadPrec UpdateSubscriptionsToEventBridgeResponse
$creadPrec :: ReadPrec UpdateSubscriptionsToEventBridgeResponse
readList :: ReadS [UpdateSubscriptionsToEventBridgeResponse]
$creadList :: ReadS [UpdateSubscriptionsToEventBridgeResponse]
readsPrec :: Int -> ReadS UpdateSubscriptionsToEventBridgeResponse
$creadsPrec :: Int -> ReadS UpdateSubscriptionsToEventBridgeResponse
Prelude.Read, Int -> UpdateSubscriptionsToEventBridgeResponse -> ShowS
[UpdateSubscriptionsToEventBridgeResponse] -> ShowS
UpdateSubscriptionsToEventBridgeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSubscriptionsToEventBridgeResponse] -> ShowS
$cshowList :: [UpdateSubscriptionsToEventBridgeResponse] -> ShowS
show :: UpdateSubscriptionsToEventBridgeResponse -> String
$cshow :: UpdateSubscriptionsToEventBridgeResponse -> String
showsPrec :: Int -> UpdateSubscriptionsToEventBridgeResponse -> ShowS
$cshowsPrec :: Int -> UpdateSubscriptionsToEventBridgeResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateSubscriptionsToEventBridgeResponse x
-> UpdateSubscriptionsToEventBridgeResponse
forall x.
UpdateSubscriptionsToEventBridgeResponse
-> Rep UpdateSubscriptionsToEventBridgeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSubscriptionsToEventBridgeResponse x
-> UpdateSubscriptionsToEventBridgeResponse
$cfrom :: forall x.
UpdateSubscriptionsToEventBridgeResponse
-> Rep UpdateSubscriptionsToEventBridgeResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSubscriptionsToEventBridgeResponse' 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:
--
-- 'result', 'updateSubscriptionsToEventBridgeResponse_result' - A string that indicates how many event subscriptions were migrated and
-- how many remain to be migrated.
--
-- 'httpStatus', 'updateSubscriptionsToEventBridgeResponse_httpStatus' - The response's http status code.
newUpdateSubscriptionsToEventBridgeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSubscriptionsToEventBridgeResponse
newUpdateSubscriptionsToEventBridgeResponse :: Int -> UpdateSubscriptionsToEventBridgeResponse
newUpdateSubscriptionsToEventBridgeResponse
  Int
pHttpStatus_ =
    UpdateSubscriptionsToEventBridgeResponse'
      { $sel:result:UpdateSubscriptionsToEventBridgeResponse' :: Maybe Text
result =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:UpdateSubscriptionsToEventBridgeResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A string that indicates how many event subscriptions were migrated and
-- how many remain to be migrated.
updateSubscriptionsToEventBridgeResponse_result :: Lens.Lens' UpdateSubscriptionsToEventBridgeResponse (Prelude.Maybe Prelude.Text)
updateSubscriptionsToEventBridgeResponse_result :: Lens' UpdateSubscriptionsToEventBridgeResponse (Maybe Text)
updateSubscriptionsToEventBridgeResponse_result = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSubscriptionsToEventBridgeResponse' {Maybe Text
result :: Maybe Text
$sel:result:UpdateSubscriptionsToEventBridgeResponse' :: UpdateSubscriptionsToEventBridgeResponse -> Maybe Text
result} -> Maybe Text
result) (\s :: UpdateSubscriptionsToEventBridgeResponse
s@UpdateSubscriptionsToEventBridgeResponse' {} Maybe Text
a -> UpdateSubscriptionsToEventBridgeResponse
s {$sel:result:UpdateSubscriptionsToEventBridgeResponse' :: Maybe Text
result = Maybe Text
a} :: UpdateSubscriptionsToEventBridgeResponse)

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

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