{-# 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.SecretsManager.StopReplicationToReplica
-- 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)
--
-- Removes the secret from replication and promotes the secret to a
-- regional secret in the replica Region.
module Amazonka.SecretsManager.StopReplicationToReplica
  ( -- * Creating a Request
    StopReplicationToReplica (..),
    newStopReplicationToReplica,

    -- * Request Lenses
    stopReplicationToReplica_secretId,

    -- * Destructuring the Response
    StopReplicationToReplicaResponse (..),
    newStopReplicationToReplicaResponse,

    -- * Response Lenses
    stopReplicationToReplicaResponse_arn,
    stopReplicationToReplicaResponse_httpStatus,
  )
where

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
import Amazonka.SecretsManager.Types

-- | /See:/ 'newStopReplicationToReplica' smart constructor.
data StopReplicationToReplica = StopReplicationToReplica'
  { -- | Response to @StopReplicationToReplica@ of a secret, based on the
    -- @SecretId@.
    StopReplicationToReplica -> Text
secretId :: Prelude.Text
  }
  deriving (StopReplicationToReplica -> StopReplicationToReplica -> Bool
(StopReplicationToReplica -> StopReplicationToReplica -> Bool)
-> (StopReplicationToReplica -> StopReplicationToReplica -> Bool)
-> Eq StopReplicationToReplica
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopReplicationToReplica -> StopReplicationToReplica -> Bool
$c/= :: StopReplicationToReplica -> StopReplicationToReplica -> Bool
== :: StopReplicationToReplica -> StopReplicationToReplica -> Bool
$c== :: StopReplicationToReplica -> StopReplicationToReplica -> Bool
Prelude.Eq, ReadPrec [StopReplicationToReplica]
ReadPrec StopReplicationToReplica
Int -> ReadS StopReplicationToReplica
ReadS [StopReplicationToReplica]
(Int -> ReadS StopReplicationToReplica)
-> ReadS [StopReplicationToReplica]
-> ReadPrec StopReplicationToReplica
-> ReadPrec [StopReplicationToReplica]
-> Read StopReplicationToReplica
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopReplicationToReplica]
$creadListPrec :: ReadPrec [StopReplicationToReplica]
readPrec :: ReadPrec StopReplicationToReplica
$creadPrec :: ReadPrec StopReplicationToReplica
readList :: ReadS [StopReplicationToReplica]
$creadList :: ReadS [StopReplicationToReplica]
readsPrec :: Int -> ReadS StopReplicationToReplica
$creadsPrec :: Int -> ReadS StopReplicationToReplica
Prelude.Read, Int -> StopReplicationToReplica -> ShowS
[StopReplicationToReplica] -> ShowS
StopReplicationToReplica -> String
(Int -> StopReplicationToReplica -> ShowS)
-> (StopReplicationToReplica -> String)
-> ([StopReplicationToReplica] -> ShowS)
-> Show StopReplicationToReplica
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopReplicationToReplica] -> ShowS
$cshowList :: [StopReplicationToReplica] -> ShowS
show :: StopReplicationToReplica -> String
$cshow :: StopReplicationToReplica -> String
showsPrec :: Int -> StopReplicationToReplica -> ShowS
$cshowsPrec :: Int -> StopReplicationToReplica -> ShowS
Prelude.Show, (forall x.
 StopReplicationToReplica -> Rep StopReplicationToReplica x)
-> (forall x.
    Rep StopReplicationToReplica x -> StopReplicationToReplica)
-> Generic StopReplicationToReplica
forall x.
Rep StopReplicationToReplica x -> StopReplicationToReplica
forall x.
StopReplicationToReplica -> Rep StopReplicationToReplica x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopReplicationToReplica x -> StopReplicationToReplica
$cfrom :: forall x.
StopReplicationToReplica -> Rep StopReplicationToReplica x
Prelude.Generic)

-- |
-- Create a value of 'StopReplicationToReplica' 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:
--
-- 'secretId', 'stopReplicationToReplica_secretId' - Response to @StopReplicationToReplica@ of a secret, based on the
-- @SecretId@.
newStopReplicationToReplica ::
  -- | 'secretId'
  Prelude.Text ->
  StopReplicationToReplica
newStopReplicationToReplica :: Text -> StopReplicationToReplica
newStopReplicationToReplica Text
pSecretId_ =
  StopReplicationToReplica' :: Text -> StopReplicationToReplica
StopReplicationToReplica' {$sel:secretId:StopReplicationToReplica' :: Text
secretId = Text
pSecretId_}

-- | Response to @StopReplicationToReplica@ of a secret, based on the
-- @SecretId@.
stopReplicationToReplica_secretId :: Lens.Lens' StopReplicationToReplica Prelude.Text
stopReplicationToReplica_secretId :: (Text -> f Text)
-> StopReplicationToReplica -> f StopReplicationToReplica
stopReplicationToReplica_secretId = (StopReplicationToReplica -> Text)
-> (StopReplicationToReplica -> Text -> StopReplicationToReplica)
-> Lens StopReplicationToReplica StopReplicationToReplica Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopReplicationToReplica' {Text
secretId :: Text
$sel:secretId:StopReplicationToReplica' :: StopReplicationToReplica -> Text
secretId} -> Text
secretId) (\s :: StopReplicationToReplica
s@StopReplicationToReplica' {} Text
a -> StopReplicationToReplica
s {$sel:secretId:StopReplicationToReplica' :: Text
secretId = Text
a} :: StopReplicationToReplica)

instance Core.AWSRequest StopReplicationToReplica where
  type
    AWSResponse StopReplicationToReplica =
      StopReplicationToReplicaResponse
  request :: StopReplicationToReplica -> Request StopReplicationToReplica
request = Service
-> StopReplicationToReplica -> Request StopReplicationToReplica
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopReplicationToReplica
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopReplicationToReplica)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopReplicationToReplica))
-> Logger
-> Service
-> Proxy StopReplicationToReplica
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopReplicationToReplica)))
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 -> StopReplicationToReplicaResponse
StopReplicationToReplicaResponse'
            (Maybe Text -> Int -> StopReplicationToReplicaResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StopReplicationToReplicaResponse)
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
"ARN")
            Either String (Int -> StopReplicationToReplicaResponse)
-> Either String Int
-> Either String StopReplicationToReplicaResponse
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 StopReplicationToReplica

instance Prelude.NFData StopReplicationToReplica

instance Core.ToHeaders StopReplicationToReplica where
  toHeaders :: StopReplicationToReplica -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopReplicationToReplica -> 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
"secretsmanager.StopReplicationToReplica" ::
                          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 StopReplicationToReplica where
  toJSON :: StopReplicationToReplica -> Value
toJSON StopReplicationToReplica' {Text
secretId :: Text
$sel:secretId:StopReplicationToReplica' :: StopReplicationToReplica -> 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
"SecretId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
secretId)]
      )

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

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

-- | /See:/ 'newStopReplicationToReplicaResponse' smart constructor.
data StopReplicationToReplicaResponse = StopReplicationToReplicaResponse'
  { -- | Response @StopReplicationToReplica@ of a secret, based on the @ARN,@.
    StopReplicationToReplicaResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StopReplicationToReplicaResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopReplicationToReplicaResponse
-> StopReplicationToReplicaResponse -> Bool
(StopReplicationToReplicaResponse
 -> StopReplicationToReplicaResponse -> Bool)
-> (StopReplicationToReplicaResponse
    -> StopReplicationToReplicaResponse -> Bool)
-> Eq StopReplicationToReplicaResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopReplicationToReplicaResponse
-> StopReplicationToReplicaResponse -> Bool
$c/= :: StopReplicationToReplicaResponse
-> StopReplicationToReplicaResponse -> Bool
== :: StopReplicationToReplicaResponse
-> StopReplicationToReplicaResponse -> Bool
$c== :: StopReplicationToReplicaResponse
-> StopReplicationToReplicaResponse -> Bool
Prelude.Eq, ReadPrec [StopReplicationToReplicaResponse]
ReadPrec StopReplicationToReplicaResponse
Int -> ReadS StopReplicationToReplicaResponse
ReadS [StopReplicationToReplicaResponse]
(Int -> ReadS StopReplicationToReplicaResponse)
-> ReadS [StopReplicationToReplicaResponse]
-> ReadPrec StopReplicationToReplicaResponse
-> ReadPrec [StopReplicationToReplicaResponse]
-> Read StopReplicationToReplicaResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopReplicationToReplicaResponse]
$creadListPrec :: ReadPrec [StopReplicationToReplicaResponse]
readPrec :: ReadPrec StopReplicationToReplicaResponse
$creadPrec :: ReadPrec StopReplicationToReplicaResponse
readList :: ReadS [StopReplicationToReplicaResponse]
$creadList :: ReadS [StopReplicationToReplicaResponse]
readsPrec :: Int -> ReadS StopReplicationToReplicaResponse
$creadsPrec :: Int -> ReadS StopReplicationToReplicaResponse
Prelude.Read, Int -> StopReplicationToReplicaResponse -> ShowS
[StopReplicationToReplicaResponse] -> ShowS
StopReplicationToReplicaResponse -> String
(Int -> StopReplicationToReplicaResponse -> ShowS)
-> (StopReplicationToReplicaResponse -> String)
-> ([StopReplicationToReplicaResponse] -> ShowS)
-> Show StopReplicationToReplicaResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopReplicationToReplicaResponse] -> ShowS
$cshowList :: [StopReplicationToReplicaResponse] -> ShowS
show :: StopReplicationToReplicaResponse -> String
$cshow :: StopReplicationToReplicaResponse -> String
showsPrec :: Int -> StopReplicationToReplicaResponse -> ShowS
$cshowsPrec :: Int -> StopReplicationToReplicaResponse -> ShowS
Prelude.Show, (forall x.
 StopReplicationToReplicaResponse
 -> Rep StopReplicationToReplicaResponse x)
-> (forall x.
    Rep StopReplicationToReplicaResponse x
    -> StopReplicationToReplicaResponse)
-> Generic StopReplicationToReplicaResponse
forall x.
Rep StopReplicationToReplicaResponse x
-> StopReplicationToReplicaResponse
forall x.
StopReplicationToReplicaResponse
-> Rep StopReplicationToReplicaResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopReplicationToReplicaResponse x
-> StopReplicationToReplicaResponse
$cfrom :: forall x.
StopReplicationToReplicaResponse
-> Rep StopReplicationToReplicaResponse x
Prelude.Generic)

-- |
-- Create a value of 'StopReplicationToReplicaResponse' 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:
--
-- 'arn', 'stopReplicationToReplicaResponse_arn' - Response @StopReplicationToReplica@ of a secret, based on the @ARN,@.
--
-- 'httpStatus', 'stopReplicationToReplicaResponse_httpStatus' - The response's http status code.
newStopReplicationToReplicaResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopReplicationToReplicaResponse
newStopReplicationToReplicaResponse :: Int -> StopReplicationToReplicaResponse
newStopReplicationToReplicaResponse Int
pHttpStatus_ =
  StopReplicationToReplicaResponse' :: Maybe Text -> Int -> StopReplicationToReplicaResponse
StopReplicationToReplicaResponse'
    { $sel:arn:StopReplicationToReplicaResponse' :: Maybe Text
arn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopReplicationToReplicaResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Response @StopReplicationToReplica@ of a secret, based on the @ARN,@.
stopReplicationToReplicaResponse_arn :: Lens.Lens' StopReplicationToReplicaResponse (Prelude.Maybe Prelude.Text)
stopReplicationToReplicaResponse_arn :: (Maybe Text -> f (Maybe Text))
-> StopReplicationToReplicaResponse
-> f StopReplicationToReplicaResponse
stopReplicationToReplicaResponse_arn = (StopReplicationToReplicaResponse -> Maybe Text)
-> (StopReplicationToReplicaResponse
    -> Maybe Text -> StopReplicationToReplicaResponse)
-> Lens
     StopReplicationToReplicaResponse
     StopReplicationToReplicaResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopReplicationToReplicaResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:StopReplicationToReplicaResponse' :: StopReplicationToReplicaResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: StopReplicationToReplicaResponse
s@StopReplicationToReplicaResponse' {} Maybe Text
a -> StopReplicationToReplicaResponse
s {$sel:arn:StopReplicationToReplicaResponse' :: Maybe Text
arn = Maybe Text
a} :: StopReplicationToReplicaResponse)

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

instance
  Prelude.NFData
    StopReplicationToReplicaResponse