{-# 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.Kinesis.DisableEnhancedMonitoring
-- 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 enhanced monitoring.
module Amazonka.Kinesis.DisableEnhancedMonitoring
  ( -- * Creating a Request
    DisableEnhancedMonitoring (..),
    newDisableEnhancedMonitoring,

    -- * Request Lenses
    disableEnhancedMonitoring_streamName,
    disableEnhancedMonitoring_shardLevelMetrics,

    -- * Destructuring the Response
    EnhancedMonitoringOutput (..),
    newEnhancedMonitoringOutput,

    -- * Response Lenses
    enhancedMonitoringOutput_desiredShardLevelMetrics,
    enhancedMonitoringOutput_currentShardLevelMetrics,
    enhancedMonitoringOutput_streamName,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input for DisableEnhancedMonitoring.
--
-- /See:/ 'newDisableEnhancedMonitoring' smart constructor.
data DisableEnhancedMonitoring = DisableEnhancedMonitoring'
  { -- | The name of the Kinesis data stream for which to disable enhanced
    -- monitoring.
    DisableEnhancedMonitoring -> Text
streamName :: Prelude.Text,
    -- | List of shard-level metrics to disable.
    --
    -- The following are the valid shard-level metrics. The value \"@ALL@\"
    -- disables every metric.
    --
    -- -   @IncomingBytes@
    --
    -- -   @IncomingRecords@
    --
    -- -   @OutgoingBytes@
    --
    -- -   @OutgoingRecords@
    --
    -- -   @WriteProvisionedThroughputExceeded@
    --
    -- -   @ReadProvisionedThroughputExceeded@
    --
    -- -   @IteratorAgeMilliseconds@
    --
    -- -   @ALL@
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/kinesis/latest/dev/monitoring-with-cloudwatch.html Monitoring the Amazon Kinesis Data Streams Service with Amazon CloudWatch>
    -- in the /Amazon Kinesis Data Streams Developer Guide/.
    DisableEnhancedMonitoring -> [MetricsName]
shardLevelMetrics :: [MetricsName]
  }
  deriving (DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool
(DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool)
-> (DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool)
-> Eq DisableEnhancedMonitoring
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool
$c/= :: DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool
== :: DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool
$c== :: DisableEnhancedMonitoring -> DisableEnhancedMonitoring -> Bool
Prelude.Eq, ReadPrec [DisableEnhancedMonitoring]
ReadPrec DisableEnhancedMonitoring
Int -> ReadS DisableEnhancedMonitoring
ReadS [DisableEnhancedMonitoring]
(Int -> ReadS DisableEnhancedMonitoring)
-> ReadS [DisableEnhancedMonitoring]
-> ReadPrec DisableEnhancedMonitoring
-> ReadPrec [DisableEnhancedMonitoring]
-> Read DisableEnhancedMonitoring
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableEnhancedMonitoring]
$creadListPrec :: ReadPrec [DisableEnhancedMonitoring]
readPrec :: ReadPrec DisableEnhancedMonitoring
$creadPrec :: ReadPrec DisableEnhancedMonitoring
readList :: ReadS [DisableEnhancedMonitoring]
$creadList :: ReadS [DisableEnhancedMonitoring]
readsPrec :: Int -> ReadS DisableEnhancedMonitoring
$creadsPrec :: Int -> ReadS DisableEnhancedMonitoring
Prelude.Read, Int -> DisableEnhancedMonitoring -> ShowS
[DisableEnhancedMonitoring] -> ShowS
DisableEnhancedMonitoring -> String
(Int -> DisableEnhancedMonitoring -> ShowS)
-> (DisableEnhancedMonitoring -> String)
-> ([DisableEnhancedMonitoring] -> ShowS)
-> Show DisableEnhancedMonitoring
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableEnhancedMonitoring] -> ShowS
$cshowList :: [DisableEnhancedMonitoring] -> ShowS
show :: DisableEnhancedMonitoring -> String
$cshow :: DisableEnhancedMonitoring -> String
showsPrec :: Int -> DisableEnhancedMonitoring -> ShowS
$cshowsPrec :: Int -> DisableEnhancedMonitoring -> ShowS
Prelude.Show, (forall x.
 DisableEnhancedMonitoring -> Rep DisableEnhancedMonitoring x)
-> (forall x.
    Rep DisableEnhancedMonitoring x -> DisableEnhancedMonitoring)
-> Generic DisableEnhancedMonitoring
forall x.
Rep DisableEnhancedMonitoring x -> DisableEnhancedMonitoring
forall x.
DisableEnhancedMonitoring -> Rep DisableEnhancedMonitoring x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableEnhancedMonitoring x -> DisableEnhancedMonitoring
$cfrom :: forall x.
DisableEnhancedMonitoring -> Rep DisableEnhancedMonitoring x
Prelude.Generic)

-- |
-- Create a value of 'DisableEnhancedMonitoring' 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:
--
-- 'streamName', 'disableEnhancedMonitoring_streamName' - The name of the Kinesis data stream for which to disable enhanced
-- monitoring.
--
-- 'shardLevelMetrics', 'disableEnhancedMonitoring_shardLevelMetrics' - List of shard-level metrics to disable.
--
-- The following are the valid shard-level metrics. The value \"@ALL@\"
-- disables every metric.
--
-- -   @IncomingBytes@
--
-- -   @IncomingRecords@
--
-- -   @OutgoingBytes@
--
-- -   @OutgoingRecords@
--
-- -   @WriteProvisionedThroughputExceeded@
--
-- -   @ReadProvisionedThroughputExceeded@
--
-- -   @IteratorAgeMilliseconds@
--
-- -   @ALL@
--
-- For more information, see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/monitoring-with-cloudwatch.html Monitoring the Amazon Kinesis Data Streams Service with Amazon CloudWatch>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
newDisableEnhancedMonitoring ::
  -- | 'streamName'
  Prelude.Text ->
  DisableEnhancedMonitoring
newDisableEnhancedMonitoring :: Text -> DisableEnhancedMonitoring
newDisableEnhancedMonitoring Text
pStreamName_ =
  DisableEnhancedMonitoring' :: Text -> [MetricsName] -> DisableEnhancedMonitoring
DisableEnhancedMonitoring'
    { $sel:streamName:DisableEnhancedMonitoring' :: Text
streamName =
        Text
pStreamName_,
      $sel:shardLevelMetrics:DisableEnhancedMonitoring' :: [MetricsName]
shardLevelMetrics = [MetricsName]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the Kinesis data stream for which to disable enhanced
-- monitoring.
disableEnhancedMonitoring_streamName :: Lens.Lens' DisableEnhancedMonitoring Prelude.Text
disableEnhancedMonitoring_streamName :: (Text -> f Text)
-> DisableEnhancedMonitoring -> f DisableEnhancedMonitoring
disableEnhancedMonitoring_streamName = (DisableEnhancedMonitoring -> Text)
-> (DisableEnhancedMonitoring -> Text -> DisableEnhancedMonitoring)
-> Lens
     DisableEnhancedMonitoring DisableEnhancedMonitoring Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableEnhancedMonitoring' {Text
streamName :: Text
$sel:streamName:DisableEnhancedMonitoring' :: DisableEnhancedMonitoring -> Text
streamName} -> Text
streamName) (\s :: DisableEnhancedMonitoring
s@DisableEnhancedMonitoring' {} Text
a -> DisableEnhancedMonitoring
s {$sel:streamName:DisableEnhancedMonitoring' :: Text
streamName = Text
a} :: DisableEnhancedMonitoring)

-- | List of shard-level metrics to disable.
--
-- The following are the valid shard-level metrics. The value \"@ALL@\"
-- disables every metric.
--
-- -   @IncomingBytes@
--
-- -   @IncomingRecords@
--
-- -   @OutgoingBytes@
--
-- -   @OutgoingRecords@
--
-- -   @WriteProvisionedThroughputExceeded@
--
-- -   @ReadProvisionedThroughputExceeded@
--
-- -   @IteratorAgeMilliseconds@
--
-- -   @ALL@
--
-- For more information, see
-- <https://docs.aws.amazon.com/kinesis/latest/dev/monitoring-with-cloudwatch.html Monitoring the Amazon Kinesis Data Streams Service with Amazon CloudWatch>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
disableEnhancedMonitoring_shardLevelMetrics :: Lens.Lens' DisableEnhancedMonitoring [MetricsName]
disableEnhancedMonitoring_shardLevelMetrics :: ([MetricsName] -> f [MetricsName])
-> DisableEnhancedMonitoring -> f DisableEnhancedMonitoring
disableEnhancedMonitoring_shardLevelMetrics = (DisableEnhancedMonitoring -> [MetricsName])
-> (DisableEnhancedMonitoring
    -> [MetricsName] -> DisableEnhancedMonitoring)
-> Lens
     DisableEnhancedMonitoring
     DisableEnhancedMonitoring
     [MetricsName]
     [MetricsName]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableEnhancedMonitoring' {[MetricsName]
shardLevelMetrics :: [MetricsName]
$sel:shardLevelMetrics:DisableEnhancedMonitoring' :: DisableEnhancedMonitoring -> [MetricsName]
shardLevelMetrics} -> [MetricsName]
shardLevelMetrics) (\s :: DisableEnhancedMonitoring
s@DisableEnhancedMonitoring' {} [MetricsName]
a -> DisableEnhancedMonitoring
s {$sel:shardLevelMetrics:DisableEnhancedMonitoring' :: [MetricsName]
shardLevelMetrics = [MetricsName]
a} :: DisableEnhancedMonitoring) (([MetricsName] -> f [MetricsName])
 -> DisableEnhancedMonitoring -> f DisableEnhancedMonitoring)
-> (([MetricsName] -> f [MetricsName])
    -> [MetricsName] -> f [MetricsName])
-> ([MetricsName] -> f [MetricsName])
-> DisableEnhancedMonitoring
-> f DisableEnhancedMonitoring
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([MetricsName] -> f [MetricsName])
-> [MetricsName] -> f [MetricsName]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DisableEnhancedMonitoring where
  type
    AWSResponse DisableEnhancedMonitoring =
      EnhancedMonitoringOutput
  request :: DisableEnhancedMonitoring -> Request DisableEnhancedMonitoring
request = Service
-> DisableEnhancedMonitoring -> Request DisableEnhancedMonitoring
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableEnhancedMonitoring
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableEnhancedMonitoring)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DisableEnhancedMonitoring))
-> Logger
-> Service
-> Proxy DisableEnhancedMonitoring
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableEnhancedMonitoring)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String EnhancedMonitoringOutput
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DisableEnhancedMonitoring

instance Prelude.NFData DisableEnhancedMonitoring

instance Core.ToHeaders DisableEnhancedMonitoring where
  toHeaders :: DisableEnhancedMonitoring -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisableEnhancedMonitoring -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Kinesis_20131202.DisableEnhancedMonitoring" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DisableEnhancedMonitoring where
  toJSON :: DisableEnhancedMonitoring -> Value
toJSON DisableEnhancedMonitoring' {[MetricsName]
Text
shardLevelMetrics :: [MetricsName]
streamName :: Text
$sel:shardLevelMetrics:DisableEnhancedMonitoring' :: DisableEnhancedMonitoring -> [MetricsName]
$sel:streamName:DisableEnhancedMonitoring' :: DisableEnhancedMonitoring -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ShardLevelMetrics" Text -> [MetricsName] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [MetricsName]
shardLevelMetrics)
          ]
      )

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

instance Core.ToQuery DisableEnhancedMonitoring where
  toQuery :: DisableEnhancedMonitoring -> QueryString
toQuery = QueryString -> DisableEnhancedMonitoring -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty