{-# 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-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)
--
-- 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 a customer master
-- key (CMK) from Key Management Service, use DeleteSnapshotCopyGrant to
-- delete the grant that grants Amazon Redshift permission to the CMK 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.Lens as Lens
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
(DisableSnapshotCopy -> DisableSnapshotCopy -> Bool)
-> (DisableSnapshotCopy -> DisableSnapshotCopy -> Bool)
-> Eq DisableSnapshotCopy
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]
(Int -> ReadS DisableSnapshotCopy)
-> ReadS [DisableSnapshotCopy]
-> ReadPrec DisableSnapshotCopy
-> ReadPrec [DisableSnapshotCopy]
-> Read 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
(Int -> DisableSnapshotCopy -> ShowS)
-> (DisableSnapshotCopy -> String)
-> ([DisableSnapshotCopy] -> ShowS)
-> Show DisableSnapshotCopy
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. DisableSnapshotCopy -> Rep DisableSnapshotCopy x)
-> (forall x. Rep DisableSnapshotCopy x -> DisableSnapshotCopy)
-> Generic DisableSnapshotCopy
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' :: Text -> DisableSnapshotCopy
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 :: (Text -> f Text) -> DisableSnapshotCopy -> f DisableSnapshotCopy
disableSnapshotCopy_clusterIdentifier = (DisableSnapshotCopy -> Text)
-> (DisableSnapshotCopy -> Text -> DisableSnapshotCopy)
-> Lens DisableSnapshotCopy DisableSnapshotCopy Text Text
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 :: DisableSnapshotCopy -> Request DisableSnapshotCopy
request = Service -> DisableSnapshotCopy -> Request DisableSnapshotCopy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableSnapshotCopy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableSnapshotCopy)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DisableSnapshotCopy))
-> Logger
-> Service
-> Proxy DisableSnapshotCopy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableSnapshotCopy)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe Cluster -> Int -> DisableSnapshotCopyResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> DisableSnapshotCopyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Cluster)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Cluster")
            Either String (Int -> DisableSnapshotCopyResponse)
-> Either String Int -> Either String DisableSnapshotCopyResponse
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 DisableSnapshotCopy

instance Prelude.NFData DisableSnapshotCopy

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

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

instance Core.ToQuery DisableSnapshotCopy where
  toQuery :: DisableSnapshotCopy -> QueryString
toQuery DisableSnapshotCopy' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableSnapshotCopy' :: DisableSnapshotCopy -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DisableSnapshotCopy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DisableSnapshotCopyResponse
 -> DisableSnapshotCopyResponse -> Bool)
-> (DisableSnapshotCopyResponse
    -> DisableSnapshotCopyResponse -> Bool)
-> Eq DisableSnapshotCopyResponse
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]
(Int -> ReadS DisableSnapshotCopyResponse)
-> ReadS [DisableSnapshotCopyResponse]
-> ReadPrec DisableSnapshotCopyResponse
-> ReadPrec [DisableSnapshotCopyResponse]
-> Read 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
(Int -> DisableSnapshotCopyResponse -> ShowS)
-> (DisableSnapshotCopyResponse -> String)
-> ([DisableSnapshotCopyResponse] -> ShowS)
-> Show DisableSnapshotCopyResponse
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.
 DisableSnapshotCopyResponse -> Rep DisableSnapshotCopyResponse x)
-> (forall x.
    Rep DisableSnapshotCopyResponse x -> DisableSnapshotCopyResponse)
-> Generic DisableSnapshotCopyResponse
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' :: Maybe Cluster -> Int -> DisableSnapshotCopyResponse
DisableSnapshotCopyResponse'
    { $sel:cluster:DisableSnapshotCopyResponse' :: Maybe Cluster
cluster =
        Maybe 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 :: (Maybe Cluster -> f (Maybe Cluster))
-> DisableSnapshotCopyResponse -> f DisableSnapshotCopyResponse
disableSnapshotCopyResponse_cluster = (DisableSnapshotCopyResponse -> Maybe Cluster)
-> (DisableSnapshotCopyResponse
    -> Maybe Cluster -> DisableSnapshotCopyResponse)
-> Lens
     DisableSnapshotCopyResponse
     DisableSnapshotCopyResponse
     (Maybe Cluster)
     (Maybe 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 :: (Int -> f Int)
-> DisableSnapshotCopyResponse -> f DisableSnapshotCopyResponse
disableSnapshotCopyResponse_httpStatus = (DisableSnapshotCopyResponse -> Int)
-> (DisableSnapshotCopyResponse
    -> Int -> DisableSnapshotCopyResponse)
-> Lens
     DisableSnapshotCopyResponse DisableSnapshotCopyResponse Int Int
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