{-# 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.DisableLogging
-- 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)
--
-- Stops logging information, such as queries and connection attempts, for
-- the specified Amazon Redshift cluster.
module Amazonka.Redshift.DisableLogging
  ( -- * Creating a Request
    DisableLogging (..),
    newDisableLogging,

    -- * Request Lenses
    disableLogging_clusterIdentifier,

    -- * Destructuring the Response
    LoggingStatus (..),
    newLoggingStatus,

    -- * Response Lenses
    loggingStatus_lastFailureTime,
    loggingStatus_lastSuccessfulDeliveryTime,
    loggingStatus_s3KeyPrefix,
    loggingStatus_bucketName,
    loggingStatus_loggingEnabled,
    loggingStatus_lastFailureMessage,
  )
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:/ 'newDisableLogging' smart constructor.
data DisableLogging = DisableLogging'
  { -- | The identifier of the cluster on which logging is to be stopped.
    --
    -- Example: @examplecluster@
    DisableLogging -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (DisableLogging -> DisableLogging -> Bool
(DisableLogging -> DisableLogging -> Bool)
-> (DisableLogging -> DisableLogging -> Bool) -> Eq DisableLogging
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableLogging -> DisableLogging -> Bool
$c/= :: DisableLogging -> DisableLogging -> Bool
== :: DisableLogging -> DisableLogging -> Bool
$c== :: DisableLogging -> DisableLogging -> Bool
Prelude.Eq, ReadPrec [DisableLogging]
ReadPrec DisableLogging
Int -> ReadS DisableLogging
ReadS [DisableLogging]
(Int -> ReadS DisableLogging)
-> ReadS [DisableLogging]
-> ReadPrec DisableLogging
-> ReadPrec [DisableLogging]
-> Read DisableLogging
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableLogging]
$creadListPrec :: ReadPrec [DisableLogging]
readPrec :: ReadPrec DisableLogging
$creadPrec :: ReadPrec DisableLogging
readList :: ReadS [DisableLogging]
$creadList :: ReadS [DisableLogging]
readsPrec :: Int -> ReadS DisableLogging
$creadsPrec :: Int -> ReadS DisableLogging
Prelude.Read, Int -> DisableLogging -> ShowS
[DisableLogging] -> ShowS
DisableLogging -> String
(Int -> DisableLogging -> ShowS)
-> (DisableLogging -> String)
-> ([DisableLogging] -> ShowS)
-> Show DisableLogging
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableLogging] -> ShowS
$cshowList :: [DisableLogging] -> ShowS
show :: DisableLogging -> String
$cshow :: DisableLogging -> String
showsPrec :: Int -> DisableLogging -> ShowS
$cshowsPrec :: Int -> DisableLogging -> ShowS
Prelude.Show, (forall x. DisableLogging -> Rep DisableLogging x)
-> (forall x. Rep DisableLogging x -> DisableLogging)
-> Generic DisableLogging
forall x. Rep DisableLogging x -> DisableLogging
forall x. DisableLogging -> Rep DisableLogging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableLogging x -> DisableLogging
$cfrom :: forall x. DisableLogging -> Rep DisableLogging x
Prelude.Generic)

-- |
-- Create a value of 'DisableLogging' 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', 'disableLogging_clusterIdentifier' - The identifier of the cluster on which logging is to be stopped.
--
-- Example: @examplecluster@
newDisableLogging ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  DisableLogging
newDisableLogging :: Text -> DisableLogging
newDisableLogging Text
pClusterIdentifier_ =
  DisableLogging' :: Text -> DisableLogging
DisableLogging'
    { $sel:clusterIdentifier:DisableLogging' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The identifier of the cluster on which logging is to be stopped.
--
-- Example: @examplecluster@
disableLogging_clusterIdentifier :: Lens.Lens' DisableLogging Prelude.Text
disableLogging_clusterIdentifier :: (Text -> f Text) -> DisableLogging -> f DisableLogging
disableLogging_clusterIdentifier = (DisableLogging -> Text)
-> (DisableLogging -> Text -> DisableLogging)
-> Lens DisableLogging DisableLogging Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableLogging' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableLogging' :: DisableLogging -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: DisableLogging
s@DisableLogging' {} Text
a -> DisableLogging
s {$sel:clusterIdentifier:DisableLogging' :: Text
clusterIdentifier = Text
a} :: DisableLogging)

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

instance Prelude.Hashable DisableLogging

instance Prelude.NFData DisableLogging

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

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

instance Core.ToQuery DisableLogging where
  toQuery :: DisableLogging -> QueryString
toQuery DisableLogging' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DisableLogging' :: DisableLogging -> 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
"DisableLogging" :: 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
      ]