{-# 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.RotateEncryptionKey
-- 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)
--
-- Rotates the encryption keys for a cluster.
module Amazonka.Redshift.RotateEncryptionKey
  ( -- * Creating a Request
    RotateEncryptionKey (..),
    newRotateEncryptionKey,

    -- * Request Lenses
    rotateEncryptionKey_clusterIdentifier,

    -- * Destructuring the Response
    RotateEncryptionKeyResponse (..),
    newRotateEncryptionKeyResponse,

    -- * Response Lenses
    rotateEncryptionKeyResponse_cluster,
    rotateEncryptionKeyResponse_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:/ 'newRotateEncryptionKey' smart constructor.
data RotateEncryptionKey = RotateEncryptionKey'
  { -- | The unique identifier of the cluster that you want to rotate the
    -- encryption keys for.
    --
    -- Constraints: Must be the name of valid cluster that has encryption
    -- enabled.
    RotateEncryptionKey -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (RotateEncryptionKey -> RotateEncryptionKey -> Bool
(RotateEncryptionKey -> RotateEncryptionKey -> Bool)
-> (RotateEncryptionKey -> RotateEncryptionKey -> Bool)
-> Eq RotateEncryptionKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RotateEncryptionKey -> RotateEncryptionKey -> Bool
$c/= :: RotateEncryptionKey -> RotateEncryptionKey -> Bool
== :: RotateEncryptionKey -> RotateEncryptionKey -> Bool
$c== :: RotateEncryptionKey -> RotateEncryptionKey -> Bool
Prelude.Eq, ReadPrec [RotateEncryptionKey]
ReadPrec RotateEncryptionKey
Int -> ReadS RotateEncryptionKey
ReadS [RotateEncryptionKey]
(Int -> ReadS RotateEncryptionKey)
-> ReadS [RotateEncryptionKey]
-> ReadPrec RotateEncryptionKey
-> ReadPrec [RotateEncryptionKey]
-> Read RotateEncryptionKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RotateEncryptionKey]
$creadListPrec :: ReadPrec [RotateEncryptionKey]
readPrec :: ReadPrec RotateEncryptionKey
$creadPrec :: ReadPrec RotateEncryptionKey
readList :: ReadS [RotateEncryptionKey]
$creadList :: ReadS [RotateEncryptionKey]
readsPrec :: Int -> ReadS RotateEncryptionKey
$creadsPrec :: Int -> ReadS RotateEncryptionKey
Prelude.Read, Int -> RotateEncryptionKey -> ShowS
[RotateEncryptionKey] -> ShowS
RotateEncryptionKey -> String
(Int -> RotateEncryptionKey -> ShowS)
-> (RotateEncryptionKey -> String)
-> ([RotateEncryptionKey] -> ShowS)
-> Show RotateEncryptionKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RotateEncryptionKey] -> ShowS
$cshowList :: [RotateEncryptionKey] -> ShowS
show :: RotateEncryptionKey -> String
$cshow :: RotateEncryptionKey -> String
showsPrec :: Int -> RotateEncryptionKey -> ShowS
$cshowsPrec :: Int -> RotateEncryptionKey -> ShowS
Prelude.Show, (forall x. RotateEncryptionKey -> Rep RotateEncryptionKey x)
-> (forall x. Rep RotateEncryptionKey x -> RotateEncryptionKey)
-> Generic RotateEncryptionKey
forall x. Rep RotateEncryptionKey x -> RotateEncryptionKey
forall x. RotateEncryptionKey -> Rep RotateEncryptionKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RotateEncryptionKey x -> RotateEncryptionKey
$cfrom :: forall x. RotateEncryptionKey -> Rep RotateEncryptionKey x
Prelude.Generic)

-- |
-- Create a value of 'RotateEncryptionKey' 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', 'rotateEncryptionKey_clusterIdentifier' - The unique identifier of the cluster that you want to rotate the
-- encryption keys for.
--
-- Constraints: Must be the name of valid cluster that has encryption
-- enabled.
newRotateEncryptionKey ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  RotateEncryptionKey
newRotateEncryptionKey :: Text -> RotateEncryptionKey
newRotateEncryptionKey Text
pClusterIdentifier_ =
  RotateEncryptionKey' :: Text -> RotateEncryptionKey
RotateEncryptionKey'
    { $sel:clusterIdentifier:RotateEncryptionKey' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The unique identifier of the cluster that you want to rotate the
-- encryption keys for.
--
-- Constraints: Must be the name of valid cluster that has encryption
-- enabled.
rotateEncryptionKey_clusterIdentifier :: Lens.Lens' RotateEncryptionKey Prelude.Text
rotateEncryptionKey_clusterIdentifier :: (Text -> f Text) -> RotateEncryptionKey -> f RotateEncryptionKey
rotateEncryptionKey_clusterIdentifier = (RotateEncryptionKey -> Text)
-> (RotateEncryptionKey -> Text -> RotateEncryptionKey)
-> Lens RotateEncryptionKey RotateEncryptionKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RotateEncryptionKey' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RotateEncryptionKey' :: RotateEncryptionKey -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: RotateEncryptionKey
s@RotateEncryptionKey' {} Text
a -> RotateEncryptionKey
s {$sel:clusterIdentifier:RotateEncryptionKey' :: Text
clusterIdentifier = Text
a} :: RotateEncryptionKey)

instance Core.AWSRequest RotateEncryptionKey where
  type
    AWSResponse RotateEncryptionKey =
      RotateEncryptionKeyResponse
  request :: RotateEncryptionKey -> Request RotateEncryptionKey
request = Service -> RotateEncryptionKey -> Request RotateEncryptionKey
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy RotateEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RotateEncryptionKey)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse RotateEncryptionKey))
-> Logger
-> Service
-> Proxy RotateEncryptionKey
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RotateEncryptionKey)))
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
"RotateEncryptionKeyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> RotateEncryptionKeyResponse
RotateEncryptionKeyResponse'
            (Maybe Cluster -> Int -> RotateEncryptionKeyResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> RotateEncryptionKeyResponse)
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 -> RotateEncryptionKeyResponse)
-> Either String Int -> Either String RotateEncryptionKeyResponse
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 RotateEncryptionKey

instance Prelude.NFData RotateEncryptionKey

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

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

instance Core.ToQuery RotateEncryptionKey where
  toQuery :: RotateEncryptionKey -> QueryString
toQuery RotateEncryptionKey' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RotateEncryptionKey' :: RotateEncryptionKey -> 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
"RotateEncryptionKey" :: 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:/ 'newRotateEncryptionKeyResponse' smart constructor.
data RotateEncryptionKeyResponse = RotateEncryptionKeyResponse'
  { RotateEncryptionKeyResponse -> Maybe Cluster
cluster :: Prelude.Maybe Cluster,
    -- | The response's http status code.
    RotateEncryptionKeyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RotateEncryptionKeyResponse -> RotateEncryptionKeyResponse -> Bool
(RotateEncryptionKeyResponse
 -> RotateEncryptionKeyResponse -> Bool)
-> (RotateEncryptionKeyResponse
    -> RotateEncryptionKeyResponse -> Bool)
-> Eq RotateEncryptionKeyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RotateEncryptionKeyResponse -> RotateEncryptionKeyResponse -> Bool
$c/= :: RotateEncryptionKeyResponse -> RotateEncryptionKeyResponse -> Bool
== :: RotateEncryptionKeyResponse -> RotateEncryptionKeyResponse -> Bool
$c== :: RotateEncryptionKeyResponse -> RotateEncryptionKeyResponse -> Bool
Prelude.Eq, ReadPrec [RotateEncryptionKeyResponse]
ReadPrec RotateEncryptionKeyResponse
Int -> ReadS RotateEncryptionKeyResponse
ReadS [RotateEncryptionKeyResponse]
(Int -> ReadS RotateEncryptionKeyResponse)
-> ReadS [RotateEncryptionKeyResponse]
-> ReadPrec RotateEncryptionKeyResponse
-> ReadPrec [RotateEncryptionKeyResponse]
-> Read RotateEncryptionKeyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RotateEncryptionKeyResponse]
$creadListPrec :: ReadPrec [RotateEncryptionKeyResponse]
readPrec :: ReadPrec RotateEncryptionKeyResponse
$creadPrec :: ReadPrec RotateEncryptionKeyResponse
readList :: ReadS [RotateEncryptionKeyResponse]
$creadList :: ReadS [RotateEncryptionKeyResponse]
readsPrec :: Int -> ReadS RotateEncryptionKeyResponse
$creadsPrec :: Int -> ReadS RotateEncryptionKeyResponse
Prelude.Read, Int -> RotateEncryptionKeyResponse -> ShowS
[RotateEncryptionKeyResponse] -> ShowS
RotateEncryptionKeyResponse -> String
(Int -> RotateEncryptionKeyResponse -> ShowS)
-> (RotateEncryptionKeyResponse -> String)
-> ([RotateEncryptionKeyResponse] -> ShowS)
-> Show RotateEncryptionKeyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RotateEncryptionKeyResponse] -> ShowS
$cshowList :: [RotateEncryptionKeyResponse] -> ShowS
show :: RotateEncryptionKeyResponse -> String
$cshow :: RotateEncryptionKeyResponse -> String
showsPrec :: Int -> RotateEncryptionKeyResponse -> ShowS
$cshowsPrec :: Int -> RotateEncryptionKeyResponse -> ShowS
Prelude.Show, (forall x.
 RotateEncryptionKeyResponse -> Rep RotateEncryptionKeyResponse x)
-> (forall x.
    Rep RotateEncryptionKeyResponse x -> RotateEncryptionKeyResponse)
-> Generic RotateEncryptionKeyResponse
forall x.
Rep RotateEncryptionKeyResponse x -> RotateEncryptionKeyResponse
forall x.
RotateEncryptionKeyResponse -> Rep RotateEncryptionKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RotateEncryptionKeyResponse x -> RotateEncryptionKeyResponse
$cfrom :: forall x.
RotateEncryptionKeyResponse -> Rep RotateEncryptionKeyResponse x
Prelude.Generic)

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

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

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

instance Prelude.NFData RotateEncryptionKeyResponse