{-# 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.Redshift.DisableSnapshotCopy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disables the automatic copying of snapshots from one region to another
-- region for a specified cluster.
--
-- If your cluster and its snapshots are encrypted using an encrypted
-- symmetric key from Key Management Service, use DeleteSnapshotCopyGrant
-- to delete the grant that grants Amazon Redshift permission to the key in
-- the destination region.
module Amazonka.Redshift.DisableSnapshotCopy
  ( -- * Creating a Request
    DisableSnapshotCopy (..),
    newDisableSnapshotCopy,

    -- * Request Lenses
    disableSnapshotCopy_clusterIdentifier,

    -- * Destructuring the Response
    DisableSnapshotCopyResponse (..),
    newDisableSnapshotCopyResponse,

    -- * Response Lenses
    disableSnapshotCopyResponse_cluster,
    disableSnapshotCopyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDisableSnapshotCopy' smart constructor.
data DisableSnapshotCopy = DisableSnapshotCopy'
  { -- | The unique identifier of the source cluster that you want to disable
    -- copying of snapshots to a destination region.
    --
    -- Constraints: Must be the valid name of an existing cluster that has
    -- cross-region snapshot copy enabled.
    DisableSnapshotCopy -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (DisableSnapshotCopy -> DisableSnapshotCopy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableSnapshotCopy -> DisableSnapshotCopy -> Bool
$c/= :: DisableSnapshotCopy -> DisableSnapshotCopy -> Bool
== :: DisableSnapshotCopy -> DisableSnapshotCopy -> Bool
$c== :: DisableSnapshotCopy -> DisableSnapshotCopy -> Bool
Prelude.Eq, ReadPrec [DisableSnapshotCopy]
ReadPrec DisableSnapshotCopy
Int -> ReadS DisableSnapshotCopy
ReadS [DisableSnapshotCopy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableSnapshotCopy]
$creadListPrec :: ReadPrec [DisableSnapshotCopy]
readPrec :: ReadPrec DisableSnapshotCopy
$creadPrec :: ReadPrec DisableSnapshotCopy
readList :: ReadS [DisableSnapshotCopy]
$creadList :: ReadS [DisableSnapshotCopy]
readsPrec :: Int -> ReadS DisableSnapshotCopy
$creadsPrec :: Int -> ReadS DisableSnapshotCopy
Prelude.Read, Int -> DisableSnapshotCopy -> ShowS
[DisableSnapshotCopy] -> ShowS
DisableSnapshotCopy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableSnapshotCopy] -> ShowS
$cshowList :: [DisableSnapshotCopy] -> ShowS
show :: DisableSnapshotCopy -> String
$cshow :: DisableSnapshotCopy -> String
showsPrec :: Int -> DisableSnapshotCopy -> ShowS
$cshowsPrec :: Int -> DisableSnapshotCopy -> ShowS
Prelude.Show, forall x. Rep DisableSnapshotCopy x -> DisableSnapshotCopy
forall x. DisableSnapshotCopy -> Rep DisableSnapshotCopy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableSnapshotCopy x -> DisableSnapshotCopy
$cfrom :: forall x. DisableSnapshotCopy -> Rep DisableSnapshotCopy x
Prelude.Generic)

-- |
-- Create a value of 'DisableSnapshotCopy' 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:
--
-- 'clusterIdentifier', 'disableSnapshotCopy_clusterIdentifier' - The unique identifier of the source cluster that you want to disable
-- copying of snapshots to a destination region.
--
-- Constraints: Must be the valid name of an existing cluster that has
-- cross-region snapshot copy enabled.
newDisableSnapshotCopy ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  DisableSnapshotCopy
newDisableSnapshotCopy :: Text -> DisableSnapshotCopy
newDisableSnapshotCopy Text
pClusterIdentifier_ =
  DisableSnapshotCopy'
    { $sel:clusterIdentifier:DisableSnapshotCopy' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The unique identifier of the source cluster that you want to disable
-- copying of snapshots to a destination region.
--
-- Constraints: Must be the valid name of an existing cluster that has
-- cross-region snapshot copy enabled.
disableSnapshotCopy_clusterIdentifier :: Lens.Lens' DisableSnapshotCopy Prelude.Text
disableSnapshotCopy_clusterIdentifier :: Lens' DisableSnapshotCopy Text
disableSnapshotCopy_clusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableSnapshotCopy' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableSnapshotCopy' :: DisableSnapshotCopy -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: DisableSnapshotCopy
s@DisableSnapshotCopy' {} Text
a -> DisableSnapshotCopy
s {$sel:clusterIdentifier:DisableSnapshotCopy' :: Text
clusterIdentifier = Text
a} :: DisableSnapshotCopy)

instance Core.AWSRequest DisableSnapshotCopy where
  type
    AWSResponse DisableSnapshotCopy =
      DisableSnapshotCopyResponse
  request :: (Service -> Service)
-> DisableSnapshotCopy -> Request DisableSnapshotCopy
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DisableSnapshotCopy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableSnapshotCopy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DisableSnapshotCopyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> DisableSnapshotCopyResponse
DisableSnapshotCopyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Cluster")
            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 DisableSnapshotCopy where
  hashWithSalt :: Int -> DisableSnapshotCopy -> Int
hashWithSalt Int
_salt DisableSnapshotCopy' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableSnapshotCopy' :: DisableSnapshotCopy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterIdentifier

instance Prelude.NFData DisableSnapshotCopy where
  rnf :: DisableSnapshotCopy -> ()
rnf DisableSnapshotCopy' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableSnapshotCopy' :: DisableSnapshotCopy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clusterIdentifier

instance Data.ToHeaders DisableSnapshotCopy where
  toHeaders :: DisableSnapshotCopy -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery DisableSnapshotCopy where
  toQuery :: DisableSnapshotCopy -> QueryString
toQuery DisableSnapshotCopy' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableSnapshotCopy' :: DisableSnapshotCopy -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DisableSnapshotCopy" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ClusterIdentifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
clusterIdentifier
      ]

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

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

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

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

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