{-# 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.DescribeLoggingStatus
-- 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)
--
-- Describes whether information, such as queries and connection attempts,
-- is being logged for the specified Amazon Redshift cluster.
module Amazonka.Redshift.DescribeLoggingStatus
  ( -- * Creating a Request
    DescribeLoggingStatus (..),
    newDescribeLoggingStatus,

    -- * Request Lenses
    describeLoggingStatus_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:/ 'newDescribeLoggingStatus' smart constructor.
data DescribeLoggingStatus = DescribeLoggingStatus'
  { -- | The identifier of the cluster from which to get the logging status.
    --
    -- Example: @examplecluster@
    DescribeLoggingStatus -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (DescribeLoggingStatus -> DescribeLoggingStatus -> Bool
(DescribeLoggingStatus -> DescribeLoggingStatus -> Bool)
-> (DescribeLoggingStatus -> DescribeLoggingStatus -> Bool)
-> Eq DescribeLoggingStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLoggingStatus -> DescribeLoggingStatus -> Bool
$c/= :: DescribeLoggingStatus -> DescribeLoggingStatus -> Bool
== :: DescribeLoggingStatus -> DescribeLoggingStatus -> Bool
$c== :: DescribeLoggingStatus -> DescribeLoggingStatus -> Bool
Prelude.Eq, ReadPrec [DescribeLoggingStatus]
ReadPrec DescribeLoggingStatus
Int -> ReadS DescribeLoggingStatus
ReadS [DescribeLoggingStatus]
(Int -> ReadS DescribeLoggingStatus)
-> ReadS [DescribeLoggingStatus]
-> ReadPrec DescribeLoggingStatus
-> ReadPrec [DescribeLoggingStatus]
-> Read DescribeLoggingStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLoggingStatus]
$creadListPrec :: ReadPrec [DescribeLoggingStatus]
readPrec :: ReadPrec DescribeLoggingStatus
$creadPrec :: ReadPrec DescribeLoggingStatus
readList :: ReadS [DescribeLoggingStatus]
$creadList :: ReadS [DescribeLoggingStatus]
readsPrec :: Int -> ReadS DescribeLoggingStatus
$creadsPrec :: Int -> ReadS DescribeLoggingStatus
Prelude.Read, Int -> DescribeLoggingStatus -> ShowS
[DescribeLoggingStatus] -> ShowS
DescribeLoggingStatus -> String
(Int -> DescribeLoggingStatus -> ShowS)
-> (DescribeLoggingStatus -> String)
-> ([DescribeLoggingStatus] -> ShowS)
-> Show DescribeLoggingStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLoggingStatus] -> ShowS
$cshowList :: [DescribeLoggingStatus] -> ShowS
show :: DescribeLoggingStatus -> String
$cshow :: DescribeLoggingStatus -> String
showsPrec :: Int -> DescribeLoggingStatus -> ShowS
$cshowsPrec :: Int -> DescribeLoggingStatus -> ShowS
Prelude.Show, (forall x. DescribeLoggingStatus -> Rep DescribeLoggingStatus x)
-> (forall x. Rep DescribeLoggingStatus x -> DescribeLoggingStatus)
-> Generic DescribeLoggingStatus
forall x. Rep DescribeLoggingStatus x -> DescribeLoggingStatus
forall x. DescribeLoggingStatus -> Rep DescribeLoggingStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLoggingStatus x -> DescribeLoggingStatus
$cfrom :: forall x. DescribeLoggingStatus -> Rep DescribeLoggingStatus x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLoggingStatus' 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', 'describeLoggingStatus_clusterIdentifier' - The identifier of the cluster from which to get the logging status.
--
-- Example: @examplecluster@
newDescribeLoggingStatus ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  DescribeLoggingStatus
newDescribeLoggingStatus :: Text -> DescribeLoggingStatus
newDescribeLoggingStatus Text
pClusterIdentifier_ =
  DescribeLoggingStatus' :: Text -> DescribeLoggingStatus
DescribeLoggingStatus'
    { $sel:clusterIdentifier:DescribeLoggingStatus' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The identifier of the cluster from which to get the logging status.
--
-- Example: @examplecluster@
describeLoggingStatus_clusterIdentifier :: Lens.Lens' DescribeLoggingStatus Prelude.Text
describeLoggingStatus_clusterIdentifier :: (Text -> f Text)
-> DescribeLoggingStatus -> f DescribeLoggingStatus
describeLoggingStatus_clusterIdentifier = (DescribeLoggingStatus -> Text)
-> (DescribeLoggingStatus -> Text -> DescribeLoggingStatus)
-> Lens DescribeLoggingStatus DescribeLoggingStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLoggingStatus' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:DescribeLoggingStatus' :: DescribeLoggingStatus -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: DescribeLoggingStatus
s@DescribeLoggingStatus' {} Text
a -> DescribeLoggingStatus
s {$sel:clusterIdentifier:DescribeLoggingStatus' :: Text
clusterIdentifier = Text
a} :: DescribeLoggingStatus)

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

instance Prelude.NFData DescribeLoggingStatus

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

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

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